babylon.module.d.ts 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002
  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 { Matrix } from "babylonjs/Maths/math.vector";
  47943. import { Scene } from "babylonjs/scene";
  47944. import { Camera } from "babylonjs/Cameras/camera";
  47945. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47946. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47947. /**
  47948. * WebXR Camera which holds the views for the xrSession
  47949. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47950. */
  47951. export class WebXRCamera extends FreeCamera {
  47952. private _xrSessionManager;
  47953. private _firstFrame;
  47954. private _referenceQuaternion;
  47955. private _referencedPosition;
  47956. private _xrInvPositionCache;
  47957. private _xrInvQuaternionCache;
  47958. /**
  47959. * Should position compensation execute on first frame.
  47960. * This is used when copying the position from a native (non XR) camera
  47961. */
  47962. compensateOnFirstFrame: boolean;
  47963. /**
  47964. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47965. * @param name the name of the camera
  47966. * @param scene the scene to add the camera to
  47967. * @param _xrSessionManager a constructed xr session manager
  47968. */
  47969. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47970. /**
  47971. * Return the user's height, unrelated to the current ground.
  47972. * This will be the y position of this camera, when ground level is 0.
  47973. */
  47974. get realWorldHeight(): number;
  47975. /** @hidden */
  47976. _updateForDualEyeDebugging(): void;
  47977. /**
  47978. * Sets this camera's transformation based on a non-vr camera
  47979. * @param otherCamera the non-vr camera to copy the transformation from
  47980. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47981. */
  47982. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47983. /**
  47984. * Gets the current instance class name ("WebXRCamera").
  47985. * @returns the class name
  47986. */
  47987. getClassName(): string;
  47988. /**
  47989. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47990. */
  47991. _getViewMatrix(): Matrix;
  47992. private _rotate180;
  47993. private _updateFromXRSession;
  47994. private _updateNumberOfRigCameras;
  47995. private _updateReferenceSpace;
  47996. private _updateReferenceSpaceOffset;
  47997. }
  47998. }
  47999. declare module "babylonjs/XR/webXRFeaturesManager" {
  48000. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48001. import { IDisposable } from "babylonjs/scene";
  48002. /**
  48003. * Defining the interface required for a (webxr) feature
  48004. */
  48005. export interface IWebXRFeature extends IDisposable {
  48006. /**
  48007. * Is this feature attached
  48008. */
  48009. attached: boolean;
  48010. /**
  48011. * Should auto-attach be disabled?
  48012. */
  48013. disableAutoAttach: boolean;
  48014. /**
  48015. * Attach the feature to the session
  48016. * Will usually be called by the features manager
  48017. *
  48018. * @param force should attachment be forced (even when already attached)
  48019. * @returns true if successful.
  48020. */
  48021. attach(force?: boolean): boolean;
  48022. /**
  48023. * Detach the feature from the session
  48024. * Will usually be called by the features manager
  48025. *
  48026. * @returns true if successful.
  48027. */
  48028. detach(): boolean;
  48029. }
  48030. /**
  48031. * A list of the currently available features without referencing them
  48032. */
  48033. export class WebXRFeatureName {
  48034. /**
  48035. * The name of the anchor system feature
  48036. */
  48037. static ANCHOR_SYSTEM: string;
  48038. /**
  48039. * The name of the background remover feature
  48040. */
  48041. static BACKGROUND_REMOVER: string;
  48042. /**
  48043. * The name of the hit test feature
  48044. */
  48045. static HIT_TEST: string;
  48046. /**
  48047. * physics impostors for xr controllers feature
  48048. */
  48049. static PHYSICS_CONTROLLERS: string;
  48050. /**
  48051. * The name of the plane detection feature
  48052. */
  48053. static PLANE_DETECTION: string;
  48054. /**
  48055. * The name of the pointer selection feature
  48056. */
  48057. static POINTER_SELECTION: string;
  48058. /**
  48059. * The name of the teleportation feature
  48060. */
  48061. static TELEPORTATION: string;
  48062. }
  48063. /**
  48064. * Defining the constructor of a feature. Used to register the modules.
  48065. */
  48066. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  48067. /**
  48068. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48069. * It is mainly used in AR sessions.
  48070. *
  48071. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48072. */
  48073. export class WebXRFeaturesManager implements IDisposable {
  48074. private _xrSessionManager;
  48075. private static readonly _AvailableFeatures;
  48076. private _features;
  48077. /**
  48078. * constructs a new features manages.
  48079. *
  48080. * @param _xrSessionManager an instance of WebXRSessionManager
  48081. */
  48082. constructor(_xrSessionManager: WebXRSessionManager);
  48083. /**
  48084. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48085. * Mainly used internally.
  48086. *
  48087. * @param featureName the name of the feature to register
  48088. * @param constructorFunction the function used to construct the module
  48089. * @param version the (babylon) version of the module
  48090. * @param stable is that a stable version of this module
  48091. */
  48092. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48093. /**
  48094. * Returns a constructor of a specific feature.
  48095. *
  48096. * @param featureName the name of the feature to construct
  48097. * @param version the version of the feature to load
  48098. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48099. * @param options optional options provided to the module.
  48100. * @returns a function that, when called, will return a new instance of this feature
  48101. */
  48102. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  48103. /**
  48104. * Can be used to return the list of features currently registered
  48105. *
  48106. * @returns an Array of available features
  48107. */
  48108. static GetAvailableFeatures(): string[];
  48109. /**
  48110. * Gets the versions available for a specific feature
  48111. * @param featureName the name of the feature
  48112. * @returns an array with the available versions
  48113. */
  48114. static GetAvailableVersions(featureName: string): string[];
  48115. /**
  48116. * Return the latest unstable version of this feature
  48117. * @param featureName the name of the feature to search
  48118. * @returns the version number. if not found will return -1
  48119. */
  48120. static GetLatestVersionOfFeature(featureName: string): number;
  48121. /**
  48122. * Return the latest stable version of this feature
  48123. * @param featureName the name of the feature to search
  48124. * @returns the version number. if not found will return -1
  48125. */
  48126. static GetStableVersionOfFeature(featureName: string): number;
  48127. /**
  48128. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48129. * Can be used during a session to start a feature
  48130. * @param featureName the name of feature to attach
  48131. */
  48132. attachFeature(featureName: string): void;
  48133. /**
  48134. * Can be used inside a session or when the session ends to detach a specific feature
  48135. * @param featureName the name of the feature to detach
  48136. */
  48137. detachFeature(featureName: string): void;
  48138. /**
  48139. * Used to disable an already-enabled feature
  48140. * The feature will be disposed and will be recreated once enabled.
  48141. * @param featureName the feature to disable
  48142. * @returns true if disable was successful
  48143. */
  48144. disableFeature(featureName: string | {
  48145. Name: string;
  48146. }): boolean;
  48147. /**
  48148. * dispose this features manager
  48149. */
  48150. dispose(): void;
  48151. /**
  48152. * 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.
  48153. * 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.
  48154. *
  48155. * @param featureName the name of the feature to load or the class of the feature
  48156. * @param version optional version to load. if not provided the latest version will be enabled
  48157. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48158. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48159. * @returns a new constructed feature or throws an error if feature not found.
  48160. */
  48161. enableFeature(featureName: string | {
  48162. Name: string;
  48163. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  48164. /**
  48165. * get the implementation of an enabled feature.
  48166. * @param featureName the name of the feature to load
  48167. * @returns the feature class, if found
  48168. */
  48169. getEnabledFeature(featureName: string): IWebXRFeature;
  48170. /**
  48171. * Get the list of enabled features
  48172. * @returns an array of enabled features
  48173. */
  48174. getEnabledFeatures(): string[];
  48175. }
  48176. }
  48177. declare module "babylonjs/XR/webXRExperienceHelper" {
  48178. import { Observable } from "babylonjs/Misc/observable";
  48179. import { IDisposable, Scene } from "babylonjs/scene";
  48180. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48181. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48182. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48183. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48184. /**
  48185. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48186. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  48187. */
  48188. export class WebXRExperienceHelper implements IDisposable {
  48189. private scene;
  48190. private _nonVRCamera;
  48191. private _originalSceneAutoClear;
  48192. private _supported;
  48193. /**
  48194. * Camera used to render xr content
  48195. */
  48196. camera: WebXRCamera;
  48197. /** A features manager for this xr session */
  48198. featuresManager: WebXRFeaturesManager;
  48199. /**
  48200. * Observers registered here will be triggered after the camera's initial transformation is set
  48201. * This can be used to set a different ground level or an extra rotation.
  48202. *
  48203. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48204. * to the position set after this observable is done executing.
  48205. */
  48206. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48207. /**
  48208. * Fires when the state of the experience helper has changed
  48209. */
  48210. onStateChangedObservable: Observable<WebXRState>;
  48211. /** Session manager used to keep track of xr session */
  48212. sessionManager: WebXRSessionManager;
  48213. /**
  48214. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48215. */
  48216. state: WebXRState;
  48217. /**
  48218. * Creates a WebXRExperienceHelper
  48219. * @param scene The scene the helper should be created in
  48220. */
  48221. private constructor();
  48222. /**
  48223. * Creates the experience helper
  48224. * @param scene the scene to attach the experience helper to
  48225. * @returns a promise for the experience helper
  48226. */
  48227. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48228. /**
  48229. * Disposes of the experience helper
  48230. */
  48231. dispose(): void;
  48232. /**
  48233. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48234. * @param sessionMode options for the XR session
  48235. * @param referenceSpaceType frame of reference of the XR session
  48236. * @param renderTarget the output canvas that will be used to enter XR mode
  48237. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48238. * @returns promise that resolves after xr mode has entered
  48239. */
  48240. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48241. /**
  48242. * Exits XR mode and returns the scene to its original state
  48243. * @returns promise that resolves after xr mode has exited
  48244. */
  48245. exitXRAsync(): Promise<void>;
  48246. private _nonXRToXRCamera;
  48247. private _setState;
  48248. }
  48249. }
  48250. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48251. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48252. import { Observable } from "babylonjs/Misc/observable";
  48253. import { IDisposable } from "babylonjs/scene";
  48254. /**
  48255. * X-Y values for axes in WebXR
  48256. */
  48257. export interface IWebXRMotionControllerAxesValue {
  48258. /**
  48259. * The value of the x axis
  48260. */
  48261. x: number;
  48262. /**
  48263. * The value of the y-axis
  48264. */
  48265. y: number;
  48266. }
  48267. /**
  48268. * changed / previous values for the values of this component
  48269. */
  48270. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48271. /**
  48272. * current (this frame) value
  48273. */
  48274. current: T;
  48275. /**
  48276. * previous (last change) value
  48277. */
  48278. previous: T;
  48279. }
  48280. /**
  48281. * Represents changes in the component between current frame and last values recorded
  48282. */
  48283. export interface IWebXRMotionControllerComponentChanges {
  48284. /**
  48285. * will be populated with previous and current values if axes changed
  48286. */
  48287. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48288. /**
  48289. * will be populated with previous and current values if pressed changed
  48290. */
  48291. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48292. /**
  48293. * will be populated with previous and current values if touched changed
  48294. */
  48295. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48296. /**
  48297. * will be populated with previous and current values if value changed
  48298. */
  48299. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48300. }
  48301. /**
  48302. * This class represents a single component (for example button or thumbstick) of a motion controller
  48303. */
  48304. export class WebXRControllerComponent implements IDisposable {
  48305. /**
  48306. * the id of this component
  48307. */
  48308. id: string;
  48309. /**
  48310. * the type of the component
  48311. */
  48312. type: MotionControllerComponentType;
  48313. private _buttonIndex;
  48314. private _axesIndices;
  48315. private _axes;
  48316. private _changes;
  48317. private _currentValue;
  48318. private _hasChanges;
  48319. private _pressed;
  48320. private _touched;
  48321. /**
  48322. * button component type
  48323. */
  48324. static BUTTON_TYPE: MotionControllerComponentType;
  48325. /**
  48326. * squeeze component type
  48327. */
  48328. static SQUEEZE_TYPE: MotionControllerComponentType;
  48329. /**
  48330. * Thumbstick component type
  48331. */
  48332. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48333. /**
  48334. * Touchpad component type
  48335. */
  48336. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48337. /**
  48338. * trigger component type
  48339. */
  48340. static TRIGGER_TYPE: MotionControllerComponentType;
  48341. /**
  48342. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48343. * the axes data changes
  48344. */
  48345. onAxisValueChangedObservable: Observable<{
  48346. x: number;
  48347. y: number;
  48348. }>;
  48349. /**
  48350. * Observers registered here will be triggered when the state of a button changes
  48351. * State change is either pressed / touched / value
  48352. */
  48353. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48354. /**
  48355. * Creates a new component for a motion controller.
  48356. * It is created by the motion controller itself
  48357. *
  48358. * @param id the id of this component
  48359. * @param type the type of the component
  48360. * @param _buttonIndex index in the buttons array of the gamepad
  48361. * @param _axesIndices indices of the values in the axes array of the gamepad
  48362. */
  48363. constructor(
  48364. /**
  48365. * the id of this component
  48366. */
  48367. id: string,
  48368. /**
  48369. * the type of the component
  48370. */
  48371. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  48372. /**
  48373. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  48374. */
  48375. get axes(): IWebXRMotionControllerAxesValue;
  48376. /**
  48377. * Get the changes. Elements will be populated only if they changed with their previous and current value
  48378. */
  48379. get changes(): IWebXRMotionControllerComponentChanges;
  48380. /**
  48381. * Return whether or not the component changed the last frame
  48382. */
  48383. get hasChanges(): boolean;
  48384. /**
  48385. * is the button currently pressed
  48386. */
  48387. get pressed(): boolean;
  48388. /**
  48389. * is the button currently touched
  48390. */
  48391. get touched(): boolean;
  48392. /**
  48393. * Get the current value of this component
  48394. */
  48395. get value(): number;
  48396. /**
  48397. * Dispose this component
  48398. */
  48399. dispose(): void;
  48400. /**
  48401. * Are there axes correlating to this component
  48402. * @return true is axes data is available
  48403. */
  48404. isAxes(): boolean;
  48405. /**
  48406. * Is this component a button (hence - pressable)
  48407. * @returns true if can be pressed
  48408. */
  48409. isButton(): boolean;
  48410. /**
  48411. * update this component using the gamepad object it is in. Called on every frame
  48412. * @param nativeController the native gamepad controller object
  48413. */
  48414. update(nativeController: IMinimalMotionControllerObject): void;
  48415. }
  48416. }
  48417. declare module "babylonjs/Loading/sceneLoader" {
  48418. import { Observable } from "babylonjs/Misc/observable";
  48419. import { Nullable } from "babylonjs/types";
  48420. import { Scene } from "babylonjs/scene";
  48421. import { Engine } from "babylonjs/Engines/engine";
  48422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48423. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  48424. import { AssetContainer } from "babylonjs/assetContainer";
  48425. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  48426. import { Skeleton } from "babylonjs/Bones/skeleton";
  48427. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  48428. import { WebRequest } from "babylonjs/Misc/webRequest";
  48429. /**
  48430. * Interface used to represent data loading progression
  48431. */
  48432. export interface ISceneLoaderProgressEvent {
  48433. /**
  48434. * Defines if data length to load can be evaluated
  48435. */
  48436. readonly lengthComputable: boolean;
  48437. /**
  48438. * Defines the loaded data length
  48439. */
  48440. readonly loaded: number;
  48441. /**
  48442. * Defines the data length to load
  48443. */
  48444. readonly total: number;
  48445. }
  48446. /**
  48447. * Interface used by SceneLoader plugins to define supported file extensions
  48448. */
  48449. export interface ISceneLoaderPluginExtensions {
  48450. /**
  48451. * Defines the list of supported extensions
  48452. */
  48453. [extension: string]: {
  48454. isBinary: boolean;
  48455. };
  48456. }
  48457. /**
  48458. * Interface used by SceneLoader plugin factory
  48459. */
  48460. export interface ISceneLoaderPluginFactory {
  48461. /**
  48462. * Defines the name of the factory
  48463. */
  48464. name: string;
  48465. /**
  48466. * Function called to create a new plugin
  48467. * @return the new plugin
  48468. */
  48469. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48470. /**
  48471. * The callback that returns true if the data can be directly loaded.
  48472. * @param data string containing the file data
  48473. * @returns if the data can be loaded directly
  48474. */
  48475. canDirectLoad?(data: string): boolean;
  48476. }
  48477. /**
  48478. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48479. */
  48480. export interface ISceneLoaderPluginBase {
  48481. /**
  48482. * The friendly name of this plugin.
  48483. */
  48484. name: string;
  48485. /**
  48486. * The file extensions supported by this plugin.
  48487. */
  48488. extensions: string | ISceneLoaderPluginExtensions;
  48489. /**
  48490. * The callback called when loading from a url.
  48491. * @param scene scene loading this url
  48492. * @param url url to load
  48493. * @param onSuccess callback called when the file successfully loads
  48494. * @param onProgress callback called while file is loading (if the server supports this mode)
  48495. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48496. * @param onError callback called when the file fails to load
  48497. * @returns a file request object
  48498. */
  48499. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48500. /**
  48501. * The callback called when loading from a file object.
  48502. * @param scene scene loading this file
  48503. * @param file defines the file to load
  48504. * @param onSuccess defines the callback to call when data is loaded
  48505. * @param onProgress defines the callback to call during loading process
  48506. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48507. * @param onError defines the callback to call when an error occurs
  48508. * @returns a file request object
  48509. */
  48510. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48511. /**
  48512. * The callback that returns true if the data can be directly loaded.
  48513. * @param data string containing the file data
  48514. * @returns if the data can be loaded directly
  48515. */
  48516. canDirectLoad?(data: string): boolean;
  48517. /**
  48518. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48519. * @param scene scene loading this data
  48520. * @param data string containing the data
  48521. * @returns data to pass to the plugin
  48522. */
  48523. directLoad?(scene: Scene, data: string): any;
  48524. /**
  48525. * The callback that allows custom handling of the root url based on the response url.
  48526. * @param rootUrl the original root url
  48527. * @param responseURL the response url if available
  48528. * @returns the new root url
  48529. */
  48530. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48531. }
  48532. /**
  48533. * Interface used to define a SceneLoader plugin
  48534. */
  48535. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48536. /**
  48537. * Import meshes into a scene.
  48538. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48539. * @param scene The scene to import into
  48540. * @param data The data to import
  48541. * @param rootUrl The root url for scene and resources
  48542. * @param meshes The meshes array to import into
  48543. * @param particleSystems The particle systems array to import into
  48544. * @param skeletons The skeletons array to import into
  48545. * @param onError The callback when import fails
  48546. * @returns True if successful or false otherwise
  48547. */
  48548. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48549. /**
  48550. * Load into a scene.
  48551. * @param scene The scene to load into
  48552. * @param data The data to import
  48553. * @param rootUrl The root url for scene and resources
  48554. * @param onError The callback when import fails
  48555. * @returns True if successful or false otherwise
  48556. */
  48557. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48558. /**
  48559. * Load into an asset container.
  48560. * @param scene The scene to load into
  48561. * @param data The data to import
  48562. * @param rootUrl The root url for scene and resources
  48563. * @param onError The callback when import fails
  48564. * @returns The loaded asset container
  48565. */
  48566. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48567. }
  48568. /**
  48569. * Interface used to define an async SceneLoader plugin
  48570. */
  48571. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48572. /**
  48573. * Import meshes into a scene.
  48574. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48575. * @param scene The scene to import into
  48576. * @param data The data to import
  48577. * @param rootUrl The root url for scene and resources
  48578. * @param onProgress The callback when the load progresses
  48579. * @param fileName Defines the name of the file to load
  48580. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48581. */
  48582. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48583. meshes: AbstractMesh[];
  48584. particleSystems: IParticleSystem[];
  48585. skeletons: Skeleton[];
  48586. animationGroups: AnimationGroup[];
  48587. }>;
  48588. /**
  48589. * Load into a scene.
  48590. * @param scene The scene to load into
  48591. * @param data The data to import
  48592. * @param rootUrl The root url for scene and resources
  48593. * @param onProgress The callback when the load progresses
  48594. * @param fileName Defines the name of the file to load
  48595. * @returns Nothing
  48596. */
  48597. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48598. /**
  48599. * Load into an asset container.
  48600. * @param scene The scene to load into
  48601. * @param data The data to import
  48602. * @param rootUrl The root url for scene and resources
  48603. * @param onProgress The callback when the load progresses
  48604. * @param fileName Defines the name of the file to load
  48605. * @returns The loaded asset container
  48606. */
  48607. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48608. }
  48609. /**
  48610. * Mode that determines how to handle old animation groups before loading new ones.
  48611. */
  48612. export enum SceneLoaderAnimationGroupLoadingMode {
  48613. /**
  48614. * Reset all old animations to initial state then dispose them.
  48615. */
  48616. Clean = 0,
  48617. /**
  48618. * Stop all old animations.
  48619. */
  48620. Stop = 1,
  48621. /**
  48622. * Restart old animations from first frame.
  48623. */
  48624. Sync = 2,
  48625. /**
  48626. * Old animations remains untouched.
  48627. */
  48628. NoSync = 3
  48629. }
  48630. /**
  48631. * Class used to load scene from various file formats using registered plugins
  48632. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  48633. */
  48634. export class SceneLoader {
  48635. /**
  48636. * No logging while loading
  48637. */
  48638. static readonly NO_LOGGING: number;
  48639. /**
  48640. * Minimal logging while loading
  48641. */
  48642. static readonly MINIMAL_LOGGING: number;
  48643. /**
  48644. * Summary logging while loading
  48645. */
  48646. static readonly SUMMARY_LOGGING: number;
  48647. /**
  48648. * Detailled logging while loading
  48649. */
  48650. static readonly DETAILED_LOGGING: number;
  48651. /**
  48652. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48653. */
  48654. static get ForceFullSceneLoadingForIncremental(): boolean;
  48655. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48656. /**
  48657. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48658. */
  48659. static get ShowLoadingScreen(): boolean;
  48660. static set ShowLoadingScreen(value: boolean);
  48661. /**
  48662. * Defines the current logging level (while loading the scene)
  48663. * @ignorenaming
  48664. */
  48665. static get loggingLevel(): number;
  48666. static set loggingLevel(value: number);
  48667. /**
  48668. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48669. */
  48670. static get CleanBoneMatrixWeights(): boolean;
  48671. static set CleanBoneMatrixWeights(value: boolean);
  48672. /**
  48673. * Event raised when a plugin is used to load a scene
  48674. */
  48675. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48676. private static _registeredPlugins;
  48677. private static _getDefaultPlugin;
  48678. private static _getPluginForExtension;
  48679. private static _getPluginForDirectLoad;
  48680. private static _getPluginForFilename;
  48681. private static _getDirectLoad;
  48682. private static _loadData;
  48683. private static _getFileInfo;
  48684. /**
  48685. * Gets a plugin that can load the given extension
  48686. * @param extension defines the extension to load
  48687. * @returns a plugin or null if none works
  48688. */
  48689. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48690. /**
  48691. * Gets a boolean indicating that the given extension can be loaded
  48692. * @param extension defines the extension to load
  48693. * @returns true if the extension is supported
  48694. */
  48695. static IsPluginForExtensionAvailable(extension: string): boolean;
  48696. /**
  48697. * Adds a new plugin to the list of registered plugins
  48698. * @param plugin defines the plugin to add
  48699. */
  48700. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48701. /**
  48702. * Import meshes into a scene
  48703. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48704. * @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)
  48705. * @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)
  48706. * @param scene the instance of BABYLON.Scene to append to
  48707. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48708. * @param onProgress a callback with a progress event for each file being loaded
  48709. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48710. * @param pluginExtension the extension used to determine the plugin
  48711. * @returns The loaded plugin
  48712. */
  48713. 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>;
  48714. /**
  48715. * Import meshes into a scene
  48716. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48717. * @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)
  48718. * @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)
  48719. * @param scene the instance of BABYLON.Scene to append to
  48720. * @param onProgress a callback with a progress event for each file being loaded
  48721. * @param pluginExtension the extension used to determine the plugin
  48722. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48723. */
  48724. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48725. meshes: AbstractMesh[];
  48726. particleSystems: IParticleSystem[];
  48727. skeletons: Skeleton[];
  48728. animationGroups: AnimationGroup[];
  48729. }>;
  48730. /**
  48731. * Load a scene
  48732. * @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)
  48733. * @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)
  48734. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48735. * @param onSuccess a callback with the scene when import succeeds
  48736. * @param onProgress a callback with a progress event for each file being loaded
  48737. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48738. * @param pluginExtension the extension used to determine the plugin
  48739. * @returns The loaded plugin
  48740. */
  48741. 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>;
  48742. /**
  48743. * Load a scene
  48744. * @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)
  48745. * @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)
  48746. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48747. * @param onProgress a callback with a progress event for each file being loaded
  48748. * @param pluginExtension the extension used to determine the plugin
  48749. * @returns The loaded scene
  48750. */
  48751. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48752. /**
  48753. * Append a scene
  48754. * @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)
  48755. * @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)
  48756. * @param scene is the instance of BABYLON.Scene to append to
  48757. * @param onSuccess a callback with the scene when import succeeds
  48758. * @param onProgress a callback with a progress event for each file being loaded
  48759. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48760. * @param pluginExtension the extension used to determine the plugin
  48761. * @returns The loaded plugin
  48762. */
  48763. 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>;
  48764. /**
  48765. * Append a scene
  48766. * @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)
  48767. * @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)
  48768. * @param scene is the instance of BABYLON.Scene to append to
  48769. * @param onProgress a callback with a progress event for each file being loaded
  48770. * @param pluginExtension the extension used to determine the plugin
  48771. * @returns The given scene
  48772. */
  48773. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48774. /**
  48775. * Load a scene into an asset container
  48776. * @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)
  48777. * @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)
  48778. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48779. * @param onSuccess a callback with the scene when import succeeds
  48780. * @param onProgress a callback with a progress event for each file being loaded
  48781. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48782. * @param pluginExtension the extension used to determine the plugin
  48783. * @returns The loaded plugin
  48784. */
  48785. 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>;
  48786. /**
  48787. * Load a scene into an asset container
  48788. * @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)
  48789. * @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)
  48790. * @param scene is the instance of Scene to append to
  48791. * @param onProgress a callback with a progress event for each file being loaded
  48792. * @param pluginExtension the extension used to determine the plugin
  48793. * @returns The loaded asset container
  48794. */
  48795. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48796. /**
  48797. * Import animations from a file into a scene
  48798. * @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)
  48799. * @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)
  48800. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48801. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48802. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48803. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48804. * @param onSuccess a callback with the scene when import succeeds
  48805. * @param onProgress a callback with a progress event for each file being loaded
  48806. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48807. * @param pluginExtension the extension used to determine the plugin
  48808. */
  48809. 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;
  48810. /**
  48811. * Import animations from a file into a scene
  48812. * @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)
  48813. * @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)
  48814. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48815. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48816. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48817. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48818. * @param onSuccess a callback with the scene when import succeeds
  48819. * @param onProgress a callback with a progress event for each file being loaded
  48820. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48821. * @param pluginExtension the extension used to determine the plugin
  48822. * @returns the updated scene with imported animations
  48823. */
  48824. 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>;
  48825. }
  48826. }
  48827. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48828. import { IDisposable, Scene } from "babylonjs/scene";
  48829. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48830. import { Observable } from "babylonjs/Misc/observable";
  48831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48832. import { Nullable } from "babylonjs/types";
  48833. /**
  48834. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48835. */
  48836. export type MotionControllerHandedness = "none" | "left" | "right";
  48837. /**
  48838. * The type of components available in motion controllers.
  48839. * This is not the name of the component.
  48840. */
  48841. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48842. /**
  48843. * The state of a controller component
  48844. */
  48845. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48846. /**
  48847. * The schema of motion controller layout.
  48848. * No object will be initialized using this interface
  48849. * This is used just to define the profile.
  48850. */
  48851. export interface IMotionControllerLayout {
  48852. /**
  48853. * Path to load the assets. Usually relative to the base path
  48854. */
  48855. assetPath: string;
  48856. /**
  48857. * Available components (unsorted)
  48858. */
  48859. components: {
  48860. /**
  48861. * A map of component Ids
  48862. */
  48863. [componentId: string]: {
  48864. /**
  48865. * The type of input the component outputs
  48866. */
  48867. type: MotionControllerComponentType;
  48868. /**
  48869. * The indices of this component in the gamepad object
  48870. */
  48871. gamepadIndices: {
  48872. /**
  48873. * Index of button
  48874. */
  48875. button?: number;
  48876. /**
  48877. * If available, index of x-axis
  48878. */
  48879. xAxis?: number;
  48880. /**
  48881. * If available, index of y-axis
  48882. */
  48883. yAxis?: number;
  48884. };
  48885. /**
  48886. * The mesh's root node name
  48887. */
  48888. rootNodeName: string;
  48889. /**
  48890. * Animation definitions for this model
  48891. */
  48892. visualResponses: {
  48893. [stateKey: string]: {
  48894. /**
  48895. * What property will be animated
  48896. */
  48897. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48898. /**
  48899. * What states influence this visual response
  48900. */
  48901. states: MotionControllerComponentStateType[];
  48902. /**
  48903. * Type of animation - movement or visibility
  48904. */
  48905. valueNodeProperty: "transform" | "visibility";
  48906. /**
  48907. * Base node name to move. Its position will be calculated according to the min and max nodes
  48908. */
  48909. valueNodeName?: string;
  48910. /**
  48911. * Minimum movement node
  48912. */
  48913. minNodeName?: string;
  48914. /**
  48915. * Max movement node
  48916. */
  48917. maxNodeName?: string;
  48918. };
  48919. };
  48920. /**
  48921. * If touch enabled, what is the name of node to display user feedback
  48922. */
  48923. touchPointNodeName?: string;
  48924. };
  48925. };
  48926. /**
  48927. * Is it xr standard mapping or not
  48928. */
  48929. gamepadMapping: "" | "xr-standard";
  48930. /**
  48931. * Base root node of this entire model
  48932. */
  48933. rootNodeName: string;
  48934. /**
  48935. * Defines the main button component id
  48936. */
  48937. selectComponentId: string;
  48938. }
  48939. /**
  48940. * A definition for the layout map in the input profile
  48941. */
  48942. export interface IMotionControllerLayoutMap {
  48943. /**
  48944. * Layouts with handedness type as a key
  48945. */
  48946. [handedness: string]: IMotionControllerLayout;
  48947. }
  48948. /**
  48949. * The XR Input profile schema
  48950. * Profiles can be found here:
  48951. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48952. */
  48953. export interface IMotionControllerProfile {
  48954. /**
  48955. * fallback profiles for this profileId
  48956. */
  48957. fallbackProfileIds: string[];
  48958. /**
  48959. * The layout map, with handedness as key
  48960. */
  48961. layouts: IMotionControllerLayoutMap;
  48962. /**
  48963. * The id of this profile
  48964. * correlates to the profile(s) in the xrInput.profiles array
  48965. */
  48966. profileId: string;
  48967. }
  48968. /**
  48969. * A helper-interface for the 3 meshes needed for controller button animation
  48970. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48971. */
  48972. export interface IMotionControllerButtonMeshMap {
  48973. /**
  48974. * the mesh that defines the pressed value mesh position.
  48975. * This is used to find the max-position of this button
  48976. */
  48977. pressedMesh: AbstractMesh;
  48978. /**
  48979. * the mesh that defines the unpressed value mesh position.
  48980. * This is used to find the min (or initial) position of this button
  48981. */
  48982. unpressedMesh: AbstractMesh;
  48983. /**
  48984. * The mesh that will be changed when value changes
  48985. */
  48986. valueMesh: AbstractMesh;
  48987. }
  48988. /**
  48989. * A helper-interface for the 3 meshes needed for controller axis animation.
  48990. * This will be expanded when touchpad animations are fully supported
  48991. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48992. */
  48993. export interface IMotionControllerMeshMap {
  48994. /**
  48995. * the mesh that defines the maximum value mesh position.
  48996. */
  48997. maxMesh?: AbstractMesh;
  48998. /**
  48999. * the mesh that defines the minimum value mesh position.
  49000. */
  49001. minMesh?: AbstractMesh;
  49002. /**
  49003. * The mesh that will be changed when axis value changes
  49004. */
  49005. valueMesh: AbstractMesh;
  49006. }
  49007. /**
  49008. * The elements needed for change-detection of the gamepad objects in motion controllers
  49009. */
  49010. export interface IMinimalMotionControllerObject {
  49011. /**
  49012. * Available axes of this controller
  49013. */
  49014. axes: number[];
  49015. /**
  49016. * An array of available buttons
  49017. */
  49018. buttons: Array<{
  49019. /**
  49020. * Value of the button/trigger
  49021. */
  49022. value: number;
  49023. /**
  49024. * If the button/trigger is currently touched
  49025. */
  49026. touched: boolean;
  49027. /**
  49028. * If the button/trigger is currently pressed
  49029. */
  49030. pressed: boolean;
  49031. }>;
  49032. /**
  49033. * EXPERIMENTAL haptic support.
  49034. */
  49035. hapticActuators?: Array<{
  49036. pulse: (value: number, duration: number) => Promise<boolean>;
  49037. }>;
  49038. }
  49039. /**
  49040. * An Abstract Motion controller
  49041. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49042. * Each component has an observable to check for changes in value and state
  49043. */
  49044. export abstract class WebXRAbstractMotionController implements IDisposable {
  49045. protected scene: Scene;
  49046. protected layout: IMotionControllerLayout;
  49047. /**
  49048. * The gamepad object correlating to this controller
  49049. */
  49050. gamepadObject: IMinimalMotionControllerObject;
  49051. /**
  49052. * handedness (left/right/none) of this controller
  49053. */
  49054. handedness: MotionControllerHandedness;
  49055. private _initComponent;
  49056. private _modelReady;
  49057. /**
  49058. * A map of components (WebXRControllerComponent) in this motion controller
  49059. * Components have a ComponentType and can also have both button and axis definitions
  49060. */
  49061. readonly components: {
  49062. [id: string]: WebXRControllerComponent;
  49063. };
  49064. /**
  49065. * Disable the model's animation. Can be set at any time.
  49066. */
  49067. disableAnimation: boolean;
  49068. /**
  49069. * Observers registered here will be triggered when the model of this controller is done loading
  49070. */
  49071. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49072. /**
  49073. * The profile id of this motion controller
  49074. */
  49075. abstract profileId: string;
  49076. /**
  49077. * The root mesh of the model. It is null if the model was not yet initialized
  49078. */
  49079. rootMesh: Nullable<AbstractMesh>;
  49080. /**
  49081. * constructs a new abstract motion controller
  49082. * @param scene the scene to which the model of the controller will be added
  49083. * @param layout The profile layout to load
  49084. * @param gamepadObject The gamepad object correlating to this controller
  49085. * @param handedness handedness (left/right/none) of this controller
  49086. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49087. */
  49088. constructor(scene: Scene, layout: IMotionControllerLayout,
  49089. /**
  49090. * The gamepad object correlating to this controller
  49091. */
  49092. gamepadObject: IMinimalMotionControllerObject,
  49093. /**
  49094. * handedness (left/right/none) of this controller
  49095. */
  49096. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49097. /**
  49098. * Dispose this controller, the model mesh and all its components
  49099. */
  49100. dispose(): void;
  49101. /**
  49102. * Returns all components of specific type
  49103. * @param type the type to search for
  49104. * @return an array of components with this type
  49105. */
  49106. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49107. /**
  49108. * get a component based an its component id as defined in layout.components
  49109. * @param id the id of the component
  49110. * @returns the component correlates to the id or undefined if not found
  49111. */
  49112. getComponent(id: string): WebXRControllerComponent;
  49113. /**
  49114. * Get the list of components available in this motion controller
  49115. * @returns an array of strings correlating to available components
  49116. */
  49117. getComponentIds(): string[];
  49118. /**
  49119. * Get the first component of specific type
  49120. * @param type type of component to find
  49121. * @return a controller component or null if not found
  49122. */
  49123. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49124. /**
  49125. * Get the main (Select) component of this controller as defined in the layout
  49126. * @returns the main component of this controller
  49127. */
  49128. getMainComponent(): WebXRControllerComponent;
  49129. /**
  49130. * Loads the model correlating to this controller
  49131. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49132. * @returns A promise fulfilled with the result of the model loading
  49133. */
  49134. loadModel(): Promise<boolean>;
  49135. /**
  49136. * Update this model using the current XRFrame
  49137. * @param xrFrame the current xr frame to use and update the model
  49138. */
  49139. updateFromXRFrame(xrFrame: XRFrame): void;
  49140. /**
  49141. * Backwards compatibility due to a deeply-integrated typo
  49142. */
  49143. get handness(): XREye;
  49144. /**
  49145. * Pulse (vibrate) this controller
  49146. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49147. * Consecutive calls to this function will cancel the last pulse call
  49148. *
  49149. * @param value the strength of the pulse in 0.0...1.0 range
  49150. * @param duration Duration of the pulse in milliseconds
  49151. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49152. * @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
  49153. */
  49154. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49155. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49156. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49157. /**
  49158. * Moves the axis on the controller mesh based on its current state
  49159. * @param axis the index of the axis
  49160. * @param axisValue the value of the axis which determines the meshes new position
  49161. * @hidden
  49162. */
  49163. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49164. /**
  49165. * Update the model itself with the current frame data
  49166. * @param xrFrame the frame to use for updating the model mesh
  49167. */
  49168. protected updateModel(xrFrame: XRFrame): void;
  49169. /**
  49170. * Get the filename and path for this controller's model
  49171. * @returns a map of filename and path
  49172. */
  49173. protected abstract _getFilenameAndPath(): {
  49174. filename: string;
  49175. path: string;
  49176. };
  49177. /**
  49178. * This function is called before the mesh is loaded. It checks for loading constraints.
  49179. * For example, this function can check if the GLB loader is available
  49180. * If this function returns false, the generic controller will be loaded instead
  49181. * @returns Is the client ready to load the mesh
  49182. */
  49183. protected abstract _getModelLoadingConstraints(): boolean;
  49184. /**
  49185. * This function will be called after the model was successfully loaded and can be used
  49186. * for mesh transformations before it is available for the user
  49187. * @param meshes the loaded meshes
  49188. */
  49189. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49190. /**
  49191. * Set the root mesh for this controller. Important for the WebXR controller class
  49192. * @param meshes the loaded meshes
  49193. */
  49194. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49195. /**
  49196. * A function executed each frame that updates the mesh (if needed)
  49197. * @param xrFrame the current xrFrame
  49198. */
  49199. protected abstract _updateModel(xrFrame: XRFrame): void;
  49200. private _getGenericFilenameAndPath;
  49201. private _getGenericParentMesh;
  49202. }
  49203. }
  49204. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49205. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49207. import { Scene } from "babylonjs/scene";
  49208. /**
  49209. * A generic trigger-only motion controller for WebXR
  49210. */
  49211. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49212. /**
  49213. * Static version of the profile id of this controller
  49214. */
  49215. static ProfileId: string;
  49216. profileId: string;
  49217. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49218. protected _getFilenameAndPath(): {
  49219. filename: string;
  49220. path: string;
  49221. };
  49222. protected _getModelLoadingConstraints(): boolean;
  49223. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49224. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49225. protected _updateModel(): void;
  49226. }
  49227. }
  49228. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49229. import { Vector4 } from "babylonjs/Maths/math.vector";
  49230. import { Mesh } from "babylonjs/Meshes/mesh";
  49231. import { Scene } from "babylonjs/scene";
  49232. import { Nullable } from "babylonjs/types";
  49233. /**
  49234. * Class containing static functions to help procedurally build meshes
  49235. */
  49236. export class SphereBuilder {
  49237. /**
  49238. * Creates a sphere mesh
  49239. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49240. * * 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`)
  49241. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49242. * * 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
  49243. * * 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)
  49244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49245. * * 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
  49246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49247. * @param name defines the name of the mesh
  49248. * @param options defines the options used to create the mesh
  49249. * @param scene defines the hosting scene
  49250. * @returns the sphere mesh
  49251. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49252. */
  49253. static CreateSphere(name: string, options: {
  49254. segments?: number;
  49255. diameter?: number;
  49256. diameterX?: number;
  49257. diameterY?: number;
  49258. diameterZ?: number;
  49259. arc?: number;
  49260. slice?: number;
  49261. sideOrientation?: number;
  49262. frontUVs?: Vector4;
  49263. backUVs?: Vector4;
  49264. updatable?: boolean;
  49265. }, scene?: Nullable<Scene>): Mesh;
  49266. }
  49267. }
  49268. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49270. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49271. import { Scene } from "babylonjs/scene";
  49272. /**
  49273. * A profiled motion controller has its profile loaded from an online repository.
  49274. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49275. */
  49276. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49277. private _repositoryUrl;
  49278. private _buttonMeshMapping;
  49279. private _touchDots;
  49280. /**
  49281. * The profile ID of this controller. Will be populated when the controller initializes.
  49282. */
  49283. profileId: string;
  49284. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49285. dispose(): void;
  49286. protected _getFilenameAndPath(): {
  49287. filename: string;
  49288. path: string;
  49289. };
  49290. protected _getModelLoadingConstraints(): boolean;
  49291. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49292. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49293. protected _updateModel(_xrFrame: XRFrame): void;
  49294. }
  49295. }
  49296. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49297. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49298. import { Scene } from "babylonjs/scene";
  49299. /**
  49300. * A construction function type to create a new controller based on an xrInput object
  49301. */
  49302. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49303. /**
  49304. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49305. *
  49306. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49307. * it should be replaced with auto-loaded controllers.
  49308. *
  49309. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49310. */
  49311. export class WebXRMotionControllerManager {
  49312. private static _AvailableControllers;
  49313. private static _Fallbacks;
  49314. private static _ProfileLoadingPromises;
  49315. private static _ProfilesList;
  49316. /**
  49317. * The base URL of the online controller repository. Can be changed at any time.
  49318. */
  49319. static BaseRepositoryUrl: string;
  49320. /**
  49321. * Which repository gets priority - local or online
  49322. */
  49323. static PrioritizeOnlineRepository: boolean;
  49324. /**
  49325. * Use the online repository, or use only locally-defined controllers
  49326. */
  49327. static UseOnlineRepository: boolean;
  49328. /**
  49329. * Clear the cache used for profile loading and reload when requested again
  49330. */
  49331. static ClearProfilesCache(): void;
  49332. /**
  49333. * Register the default fallbacks.
  49334. * This function is called automatically when this file is imported.
  49335. */
  49336. static DefaultFallbacks(): void;
  49337. /**
  49338. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  49339. * @param profileId the profile to which a fallback needs to be found
  49340. * @return an array with corresponding fallback profiles
  49341. */
  49342. static FindFallbackWithProfileId(profileId: string): string[];
  49343. /**
  49344. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  49345. * The order of search:
  49346. *
  49347. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  49348. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  49349. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  49350. * 4) return the generic trigger controller if none were found
  49351. *
  49352. * @param xrInput the xrInput to which a new controller is initialized
  49353. * @param scene the scene to which the model will be added
  49354. * @param forceProfile force a certain profile for this controller
  49355. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  49356. */
  49357. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  49358. /**
  49359. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  49360. *
  49361. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  49362. *
  49363. * @param type the profile type to register
  49364. * @param constructFunction the function to be called when loading this profile
  49365. */
  49366. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  49367. /**
  49368. * Register a fallback to a specific profile.
  49369. * @param profileId the profileId that will receive the fallbacks
  49370. * @param fallbacks A list of fallback profiles
  49371. */
  49372. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  49373. /**
  49374. * Will update the list of profiles available in the repository
  49375. * @return a promise that resolves to a map of profiles available online
  49376. */
  49377. static UpdateProfilesList(): Promise<{
  49378. [profile: string]: string;
  49379. }>;
  49380. private static _LoadProfileFromRepository;
  49381. private static _LoadProfilesFromAvailableControllers;
  49382. }
  49383. }
  49384. declare module "babylonjs/XR/webXRInputSource" {
  49385. import { Observable } from "babylonjs/Misc/observable";
  49386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49387. import { Ray } from "babylonjs/Culling/ray";
  49388. import { Scene } from "babylonjs/scene";
  49389. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49390. /**
  49391. * Configuration options for the WebXR controller creation
  49392. */
  49393. export interface IWebXRControllerOptions {
  49394. /**
  49395. * Should the controller mesh be animated when a user interacts with it
  49396. * The pressed buttons / thumbstick and touchpad animations will be disabled
  49397. */
  49398. disableMotionControllerAnimation?: boolean;
  49399. /**
  49400. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  49401. */
  49402. doNotLoadControllerMesh?: boolean;
  49403. /**
  49404. * Force a specific controller type for this controller.
  49405. * This can be used when creating your own profile or when testing different controllers
  49406. */
  49407. forceControllerProfile?: string;
  49408. /**
  49409. * Defines a rendering group ID for meshes that will be loaded.
  49410. * This is for the default controllers only.
  49411. */
  49412. renderingGroupId?: number;
  49413. }
  49414. /**
  49415. * Represents an XR controller
  49416. */
  49417. export class WebXRInputSource {
  49418. private _scene;
  49419. /** The underlying input source for the controller */
  49420. inputSource: XRInputSource;
  49421. private _options;
  49422. private _tmpVector;
  49423. private _uniqueId;
  49424. /**
  49425. * 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
  49426. */
  49427. grip?: AbstractMesh;
  49428. /**
  49429. * If available, this is the gamepad object related to this controller.
  49430. * Using this object it is possible to get click events and trackpad changes of the
  49431. * webxr controller that is currently being used.
  49432. */
  49433. motionController?: WebXRAbstractMotionController;
  49434. /**
  49435. * Event that fires when the controller is removed/disposed.
  49436. * The object provided as event data is this controller, after associated assets were disposed.
  49437. * uniqueId is still available.
  49438. */
  49439. onDisposeObservable: Observable<WebXRInputSource>;
  49440. /**
  49441. * Will be triggered when the mesh associated with the motion controller is done loading.
  49442. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49443. * A shortened version of controller -> motion controller -> on mesh loaded.
  49444. */
  49445. onMeshLoadedObservable: Observable<AbstractMesh>;
  49446. /**
  49447. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49448. */
  49449. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49450. /**
  49451. * Pointer which can be used to select objects or attach a visible laser to
  49452. */
  49453. pointer: AbstractMesh;
  49454. /**
  49455. * Creates the input source object
  49456. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  49457. * @param _scene the scene which the controller should be associated to
  49458. * @param inputSource the underlying input source for the controller
  49459. * @param _options options for this controller creation
  49460. */
  49461. constructor(_scene: Scene,
  49462. /** The underlying input source for the controller */
  49463. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49464. /**
  49465. * Get this controllers unique id
  49466. */
  49467. get uniqueId(): string;
  49468. /**
  49469. * Disposes of the object
  49470. */
  49471. dispose(): void;
  49472. /**
  49473. * Gets a world space ray coming from the pointer or grip
  49474. * @param result the resulting ray
  49475. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49476. */
  49477. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49478. /**
  49479. * Updates the controller pose based on the given XRFrame
  49480. * @param xrFrame xr frame to update the pose with
  49481. * @param referenceSpace reference space to use
  49482. */
  49483. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49484. }
  49485. }
  49486. declare module "babylonjs/XR/webXRInput" {
  49487. import { Observable } from "babylonjs/Misc/observable";
  49488. import { IDisposable } from "babylonjs/scene";
  49489. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49490. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49491. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49492. /**
  49493. * The schema for initialization options of the XR Input class
  49494. */
  49495. export interface IWebXRInputOptions {
  49496. /**
  49497. * If set to true no model will be automatically loaded
  49498. */
  49499. doNotLoadControllerMeshes?: boolean;
  49500. /**
  49501. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49502. * If not found, the xr input profile data will be used.
  49503. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49504. */
  49505. forceInputProfile?: string;
  49506. /**
  49507. * Do not send a request to the controller repository to load the profile.
  49508. *
  49509. * Instead, use the controllers available in babylon itself.
  49510. */
  49511. disableOnlineControllerRepository?: boolean;
  49512. /**
  49513. * A custom URL for the controllers repository
  49514. */
  49515. customControllersRepositoryURL?: string;
  49516. /**
  49517. * Should the controller model's components not move according to the user input
  49518. */
  49519. disableControllerAnimation?: boolean;
  49520. /**
  49521. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49522. */
  49523. controllerOptions?: IWebXRControllerOptions;
  49524. }
  49525. /**
  49526. * XR input used to track XR inputs such as controllers/rays
  49527. */
  49528. export class WebXRInput implements IDisposable {
  49529. /**
  49530. * the xr session manager for this session
  49531. */
  49532. xrSessionManager: WebXRSessionManager;
  49533. /**
  49534. * the WebXR camera for this session. Mainly used for teleportation
  49535. */
  49536. xrCamera: WebXRCamera;
  49537. private readonly options;
  49538. /**
  49539. * XR controllers being tracked
  49540. */
  49541. controllers: Array<WebXRInputSource>;
  49542. private _frameObserver;
  49543. private _sessionEndedObserver;
  49544. private _sessionInitObserver;
  49545. /**
  49546. * Event when a controller has been connected/added
  49547. */
  49548. onControllerAddedObservable: Observable<WebXRInputSource>;
  49549. /**
  49550. * Event when a controller has been removed/disconnected
  49551. */
  49552. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49553. /**
  49554. * Initializes the WebXRInput
  49555. * @param xrSessionManager the xr session manager for this session
  49556. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49557. * @param options = initialization options for this xr input
  49558. */
  49559. constructor(
  49560. /**
  49561. * the xr session manager for this session
  49562. */
  49563. xrSessionManager: WebXRSessionManager,
  49564. /**
  49565. * the WebXR camera for this session. Mainly used for teleportation
  49566. */
  49567. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49568. private _onInputSourcesChange;
  49569. private _addAndRemoveControllers;
  49570. /**
  49571. * Disposes of the object
  49572. */
  49573. dispose(): void;
  49574. }
  49575. }
  49576. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49577. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49578. import { Observable, EventState } from "babylonjs/Misc/observable";
  49579. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49580. /**
  49581. * This is the base class for all WebXR features.
  49582. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49583. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49584. */
  49585. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49586. protected _xrSessionManager: WebXRSessionManager;
  49587. private _attached;
  49588. private _removeOnDetach;
  49589. /**
  49590. * Should auto-attach be disabled?
  49591. */
  49592. disableAutoAttach: boolean;
  49593. /**
  49594. * Construct a new (abstract) WebXR feature
  49595. * @param _xrSessionManager the xr session manager for this feature
  49596. */
  49597. constructor(_xrSessionManager: WebXRSessionManager);
  49598. /**
  49599. * Is this feature attached
  49600. */
  49601. get attached(): boolean;
  49602. /**
  49603. * attach this feature
  49604. *
  49605. * @param force should attachment be forced (even when already attached)
  49606. * @returns true if successful, false is failed or already attached
  49607. */
  49608. attach(force?: boolean): boolean;
  49609. /**
  49610. * detach this feature.
  49611. *
  49612. * @returns true if successful, false if failed or already detached
  49613. */
  49614. detach(): boolean;
  49615. /**
  49616. * Dispose this feature and all of the resources attached
  49617. */
  49618. dispose(): void;
  49619. /**
  49620. * This is used to register callbacks that will automatically be removed when detach is called.
  49621. * @param observable the observable to which the observer will be attached
  49622. * @param callback the callback to register
  49623. */
  49624. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49625. /**
  49626. * Code in this function will be executed on each xrFrame received from the browser.
  49627. * This function will not execute after the feature is detached.
  49628. * @param _xrFrame the current frame
  49629. */
  49630. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49631. }
  49632. }
  49633. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49634. import { IDisposable, Scene } from "babylonjs/scene";
  49635. import { Nullable } from "babylonjs/types";
  49636. import { Observable } from "babylonjs/Misc/observable";
  49637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49638. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49639. import { Camera } from "babylonjs/Cameras/camera";
  49640. /**
  49641. * Renders a layer on top of an existing scene
  49642. */
  49643. export class UtilityLayerRenderer implements IDisposable {
  49644. /** the original scene that will be rendered on top of */
  49645. originalScene: Scene;
  49646. private _pointerCaptures;
  49647. private _lastPointerEvents;
  49648. private static _DefaultUtilityLayer;
  49649. private static _DefaultKeepDepthUtilityLayer;
  49650. private _sharedGizmoLight;
  49651. private _renderCamera;
  49652. /**
  49653. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49654. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49655. * @returns the camera that is used when rendering the utility layer
  49656. */
  49657. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49658. /**
  49659. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49660. * @param cam the camera that should be used when rendering the utility layer
  49661. */
  49662. setRenderCamera(cam: Nullable<Camera>): void;
  49663. /**
  49664. * @hidden
  49665. * Light which used by gizmos to get light shading
  49666. */
  49667. _getSharedGizmoLight(): HemisphericLight;
  49668. /**
  49669. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49670. */
  49671. pickUtilitySceneFirst: boolean;
  49672. /**
  49673. * 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)
  49674. */
  49675. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49676. /**
  49677. * 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)
  49678. */
  49679. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49680. /**
  49681. * The scene that is rendered on top of the original scene
  49682. */
  49683. utilityLayerScene: Scene;
  49684. /**
  49685. * If the utility layer should automatically be rendered on top of existing scene
  49686. */
  49687. shouldRender: boolean;
  49688. /**
  49689. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49690. */
  49691. onlyCheckPointerDownEvents: boolean;
  49692. /**
  49693. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49694. */
  49695. processAllEvents: boolean;
  49696. /**
  49697. * Observable raised when the pointer move from the utility layer scene to the main scene
  49698. */
  49699. onPointerOutObservable: Observable<number>;
  49700. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49701. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49702. private _afterRenderObserver;
  49703. private _sceneDisposeObserver;
  49704. private _originalPointerObserver;
  49705. /**
  49706. * Instantiates a UtilityLayerRenderer
  49707. * @param originalScene the original scene that will be rendered on top of
  49708. * @param handleEvents boolean indicating if the utility layer should handle events
  49709. */
  49710. constructor(
  49711. /** the original scene that will be rendered on top of */
  49712. originalScene: Scene, handleEvents?: boolean);
  49713. private _notifyObservers;
  49714. /**
  49715. * Renders the utility layers scene on top of the original scene
  49716. */
  49717. render(): void;
  49718. /**
  49719. * Disposes of the renderer
  49720. */
  49721. dispose(): void;
  49722. private _updateCamera;
  49723. }
  49724. }
  49725. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49726. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49728. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49729. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49730. import { Scene } from "babylonjs/scene";
  49731. import { Nullable } from "babylonjs/types";
  49732. import { Color3 } from "babylonjs/Maths/math.color";
  49733. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49734. /**
  49735. * Options interface for the pointer selection module
  49736. */
  49737. export interface IWebXRControllerPointerSelectionOptions {
  49738. /**
  49739. * if provided, this scene will be used to render meshes.
  49740. */
  49741. customUtilityLayerScene?: Scene;
  49742. /**
  49743. * 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)
  49744. * If not disabled, the last picked point will be used to execute a pointer up event
  49745. * If disabled, pointer up event will be triggered right after the pointer down event.
  49746. * Used in screen and gaze target ray mode only
  49747. */
  49748. disablePointerUpOnTouchOut: boolean;
  49749. /**
  49750. * For gaze mode (time to select instead of press)
  49751. */
  49752. forceGazeMode: boolean;
  49753. /**
  49754. * 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
  49755. * to start a new countdown to the pointer down event.
  49756. * Defaults to 1.
  49757. */
  49758. gazeModePointerMovedFactor?: number;
  49759. /**
  49760. * Different button type to use instead of the main component
  49761. */
  49762. overrideButtonId?: string;
  49763. /**
  49764. * use this rendering group id for the meshes (optional)
  49765. */
  49766. renderingGroupId?: number;
  49767. /**
  49768. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49769. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49770. * 3000 means 3 seconds between pointing at something and selecting it
  49771. */
  49772. timeToSelect?: number;
  49773. /**
  49774. * Should meshes created here be added to a utility layer or the main scene
  49775. */
  49776. useUtilityLayer?: boolean;
  49777. /**
  49778. * the xr input to use with this pointer selection
  49779. */
  49780. xrInput: WebXRInput;
  49781. }
  49782. /**
  49783. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49784. */
  49785. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49786. private readonly _options;
  49787. private static _idCounter;
  49788. private _attachController;
  49789. private _controllers;
  49790. private _scene;
  49791. private _tmpVectorForPickCompare;
  49792. /**
  49793. * The module's name
  49794. */
  49795. static readonly Name: string;
  49796. /**
  49797. * The (Babylon) version of this module.
  49798. * This is an integer representing the implementation version.
  49799. * This number does not correspond to the WebXR specs version
  49800. */
  49801. static readonly Version: number;
  49802. /**
  49803. * Disable lighting on the laser pointer (so it will always be visible)
  49804. */
  49805. disablePointerLighting: boolean;
  49806. /**
  49807. * Disable lighting on the selection mesh (so it will always be visible)
  49808. */
  49809. disableSelectionMeshLighting: boolean;
  49810. /**
  49811. * Should the laser pointer be displayed
  49812. */
  49813. displayLaserPointer: boolean;
  49814. /**
  49815. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49816. */
  49817. displaySelectionMesh: boolean;
  49818. /**
  49819. * This color will be set to the laser pointer when selection is triggered
  49820. */
  49821. laserPointerPickedColor: Color3;
  49822. /**
  49823. * Default color of the laser pointer
  49824. */
  49825. laserPointerDefaultColor: Color3;
  49826. /**
  49827. * default color of the selection ring
  49828. */
  49829. selectionMeshDefaultColor: Color3;
  49830. /**
  49831. * This color will be applied to the selection ring when selection is triggered
  49832. */
  49833. selectionMeshPickedColor: Color3;
  49834. /**
  49835. * Optional filter to be used for ray selection. This predicate shares behavior with
  49836. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49837. */
  49838. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49839. /**
  49840. * constructs a new background remover module
  49841. * @param _xrSessionManager the session manager for this module
  49842. * @param _options read-only options to be used in this module
  49843. */
  49844. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49845. /**
  49846. * attach this feature
  49847. * Will usually be called by the features manager
  49848. *
  49849. * @returns true if successful.
  49850. */
  49851. attach(): boolean;
  49852. /**
  49853. * detach this feature.
  49854. * Will usually be called by the features manager
  49855. *
  49856. * @returns true if successful.
  49857. */
  49858. detach(): boolean;
  49859. /**
  49860. * Will get the mesh under a specific pointer.
  49861. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49862. * @param controllerId the controllerId to check
  49863. * @returns The mesh under pointer or null if no mesh is under the pointer
  49864. */
  49865. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49866. /**
  49867. * Get the xr controller that correlates to the pointer id in the pointer event
  49868. *
  49869. * @param id the pointer id to search for
  49870. * @returns the controller that correlates to this id or null if not found
  49871. */
  49872. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49873. protected _onXRFrame(_xrFrame: XRFrame): void;
  49874. private _attachGazeMode;
  49875. private _attachScreenRayMode;
  49876. private _attachTrackedPointerRayMode;
  49877. private _convertNormalToDirectionOfRay;
  49878. private _detachController;
  49879. private _generateNewMeshPair;
  49880. private _pickingMoved;
  49881. private _updatePointerDistance;
  49882. /** @hidden */
  49883. get lasterPointerDefaultColor(): Color3;
  49884. }
  49885. }
  49886. declare module "babylonjs/XR/webXREnterExitUI" {
  49887. import { Nullable } from "babylonjs/types";
  49888. import { Observable } from "babylonjs/Misc/observable";
  49889. import { IDisposable, Scene } from "babylonjs/scene";
  49890. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49891. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49892. /**
  49893. * Button which can be used to enter a different mode of XR
  49894. */
  49895. export class WebXREnterExitUIButton {
  49896. /** button element */
  49897. element: HTMLElement;
  49898. /** XR initialization options for the button */
  49899. sessionMode: XRSessionMode;
  49900. /** Reference space type */
  49901. referenceSpaceType: XRReferenceSpaceType;
  49902. /**
  49903. * Creates a WebXREnterExitUIButton
  49904. * @param element button element
  49905. * @param sessionMode XR initialization session mode
  49906. * @param referenceSpaceType the type of reference space to be used
  49907. */
  49908. constructor(
  49909. /** button element */
  49910. element: HTMLElement,
  49911. /** XR initialization options for the button */
  49912. sessionMode: XRSessionMode,
  49913. /** Reference space type */
  49914. referenceSpaceType: XRReferenceSpaceType);
  49915. /**
  49916. * Extendable function which can be used to update the button's visuals when the state changes
  49917. * @param activeButton the current active button in the UI
  49918. */
  49919. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49920. }
  49921. /**
  49922. * Options to create the webXR UI
  49923. */
  49924. export class WebXREnterExitUIOptions {
  49925. /**
  49926. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49927. */
  49928. customButtons?: Array<WebXREnterExitUIButton>;
  49929. /**
  49930. * A reference space type to use when creating the default button.
  49931. * Default is local-floor
  49932. */
  49933. referenceSpaceType?: XRReferenceSpaceType;
  49934. /**
  49935. * Context to enter xr with
  49936. */
  49937. renderTarget?: Nullable<WebXRRenderTarget>;
  49938. /**
  49939. * A session mode to use when creating the default button.
  49940. * Default is immersive-vr
  49941. */
  49942. sessionMode?: XRSessionMode;
  49943. /**
  49944. * A list of optional features to init the session with
  49945. */
  49946. optionalFeatures?: string[];
  49947. }
  49948. /**
  49949. * UI to allow the user to enter/exit XR mode
  49950. */
  49951. export class WebXREnterExitUI implements IDisposable {
  49952. private scene;
  49953. /** version of the options passed to this UI */
  49954. options: WebXREnterExitUIOptions;
  49955. private _activeButton;
  49956. private _buttons;
  49957. private _overlay;
  49958. /**
  49959. * Fired every time the active button is changed.
  49960. *
  49961. * When xr is entered via a button that launches xr that button will be the callback parameter
  49962. *
  49963. * When exiting xr the callback parameter will be null)
  49964. */
  49965. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49966. /**
  49967. *
  49968. * @param scene babylon scene object to use
  49969. * @param options (read-only) version of the options passed to this UI
  49970. */
  49971. private constructor();
  49972. /**
  49973. * Creates UI to allow the user to enter/exit XR mode
  49974. * @param scene the scene to add the ui to
  49975. * @param helper the xr experience helper to enter/exit xr with
  49976. * @param options options to configure the UI
  49977. * @returns the created ui
  49978. */
  49979. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49980. /**
  49981. * Disposes of the XR UI component
  49982. */
  49983. dispose(): void;
  49984. private _updateButtons;
  49985. }
  49986. }
  49987. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49988. import { Vector3 } from "babylonjs/Maths/math.vector";
  49989. import { Color4 } from "babylonjs/Maths/math.color";
  49990. import { Nullable } from "babylonjs/types";
  49991. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49992. import { Scene } from "babylonjs/scene";
  49993. /**
  49994. * Class containing static functions to help procedurally build meshes
  49995. */
  49996. export class LinesBuilder {
  49997. /**
  49998. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49999. * * 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
  50000. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50001. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50002. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50003. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50004. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50005. * * 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
  50006. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50008. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50009. * @param name defines the name of the new line system
  50010. * @param options defines the options used to create the line system
  50011. * @param scene defines the hosting scene
  50012. * @returns a new line system mesh
  50013. */
  50014. static CreateLineSystem(name: string, options: {
  50015. lines: Vector3[][];
  50016. updatable?: boolean;
  50017. instance?: Nullable<LinesMesh>;
  50018. colors?: Nullable<Color4[][]>;
  50019. useVertexAlpha?: boolean;
  50020. }, scene: Nullable<Scene>): LinesMesh;
  50021. /**
  50022. * Creates a line mesh
  50023. * 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
  50024. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50025. * * The parameter `points` is an array successive Vector3
  50026. * * 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
  50027. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50028. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50029. * * When updating an instance, remember that only point positions can change, not the number of points
  50030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50031. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50032. * @param name defines the name of the new line system
  50033. * @param options defines the options used to create the line system
  50034. * @param scene defines the hosting scene
  50035. * @returns a new line mesh
  50036. */
  50037. static CreateLines(name: string, options: {
  50038. points: Vector3[];
  50039. updatable?: boolean;
  50040. instance?: Nullable<LinesMesh>;
  50041. colors?: Color4[];
  50042. useVertexAlpha?: boolean;
  50043. }, scene?: Nullable<Scene>): LinesMesh;
  50044. /**
  50045. * Creates a dashed line mesh
  50046. * * 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
  50047. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50048. * * The parameter `points` is an array successive Vector3
  50049. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50050. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50051. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50052. * * 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
  50053. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50054. * * When updating an instance, remember that only point positions can change, not the number of points
  50055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50056. * @param name defines the name of the mesh
  50057. * @param options defines the options used to create the mesh
  50058. * @param scene defines the hosting scene
  50059. * @returns the dashed line mesh
  50060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50061. */
  50062. static CreateDashedLines(name: string, options: {
  50063. points: Vector3[];
  50064. dashSize?: number;
  50065. gapSize?: number;
  50066. dashNb?: number;
  50067. updatable?: boolean;
  50068. instance?: LinesMesh;
  50069. useVertexAlpha?: boolean;
  50070. }, scene?: Nullable<Scene>): LinesMesh;
  50071. }
  50072. }
  50073. declare module "babylonjs/Misc/timer" {
  50074. import { Observable, Observer } from "babylonjs/Misc/observable";
  50075. import { Nullable } from "babylonjs/types";
  50076. import { IDisposable } from "babylonjs/scene";
  50077. /**
  50078. * Construction options for a timer
  50079. */
  50080. export interface ITimerOptions<T> {
  50081. /**
  50082. * Time-to-end
  50083. */
  50084. timeout: number;
  50085. /**
  50086. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50087. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50088. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50089. */
  50090. contextObservable: Observable<T>;
  50091. /**
  50092. * Optional parameters when adding an observer to the observable
  50093. */
  50094. observableParameters?: {
  50095. mask?: number;
  50096. insertFirst?: boolean;
  50097. scope?: any;
  50098. };
  50099. /**
  50100. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50101. */
  50102. breakCondition?: (data?: ITimerData<T>) => boolean;
  50103. /**
  50104. * Will be triggered when the time condition has met
  50105. */
  50106. onEnded?: (data: ITimerData<any>) => void;
  50107. /**
  50108. * Will be triggered when the break condition has met (prematurely ended)
  50109. */
  50110. onAborted?: (data: ITimerData<any>) => void;
  50111. /**
  50112. * Optional function to execute on each tick (or count)
  50113. */
  50114. onTick?: (data: ITimerData<any>) => void;
  50115. }
  50116. /**
  50117. * An interface defining the data sent by the timer
  50118. */
  50119. export interface ITimerData<T> {
  50120. /**
  50121. * When did it start
  50122. */
  50123. startTime: number;
  50124. /**
  50125. * Time now
  50126. */
  50127. currentTime: number;
  50128. /**
  50129. * Time passed since started
  50130. */
  50131. deltaTime: number;
  50132. /**
  50133. * How much is completed, in [0.0...1.0].
  50134. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50135. */
  50136. completeRate: number;
  50137. /**
  50138. * What the registered observable sent in the last count
  50139. */
  50140. payload: T;
  50141. }
  50142. /**
  50143. * The current state of the timer
  50144. */
  50145. export enum TimerState {
  50146. /**
  50147. * Timer initialized, not yet started
  50148. */
  50149. INIT = 0,
  50150. /**
  50151. * Timer started and counting
  50152. */
  50153. STARTED = 1,
  50154. /**
  50155. * Timer ended (whether aborted or time reached)
  50156. */
  50157. ENDED = 2
  50158. }
  50159. /**
  50160. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50161. *
  50162. * @param options options with which to initialize this timer
  50163. */
  50164. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50165. /**
  50166. * An advanced implementation of a timer class
  50167. */
  50168. export class AdvancedTimer<T = any> implements IDisposable {
  50169. /**
  50170. * Will notify each time the timer calculates the remaining time
  50171. */
  50172. onEachCountObservable: Observable<ITimerData<T>>;
  50173. /**
  50174. * Will trigger when the timer was aborted due to the break condition
  50175. */
  50176. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50177. /**
  50178. * Will trigger when the timer ended successfully
  50179. */
  50180. onTimerEndedObservable: Observable<ITimerData<T>>;
  50181. /**
  50182. * Will trigger when the timer state has changed
  50183. */
  50184. onStateChangedObservable: Observable<TimerState>;
  50185. private _observer;
  50186. private _contextObservable;
  50187. private _observableParameters;
  50188. private _startTime;
  50189. private _timer;
  50190. private _state;
  50191. private _breakCondition;
  50192. private _timeToEnd;
  50193. private _breakOnNextTick;
  50194. /**
  50195. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50196. * @param options construction options for this advanced timer
  50197. */
  50198. constructor(options: ITimerOptions<T>);
  50199. /**
  50200. * set a breaking condition for this timer. Default is to never break during count
  50201. * @param predicate the new break condition. Returns true to break, false otherwise
  50202. */
  50203. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50204. /**
  50205. * Reset ALL associated observables in this advanced timer
  50206. */
  50207. clearObservables(): void;
  50208. /**
  50209. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50210. *
  50211. * @param timeToEnd how much time to measure until timer ended
  50212. */
  50213. start(timeToEnd?: number): void;
  50214. /**
  50215. * Will force a stop on the next tick.
  50216. */
  50217. stop(): void;
  50218. /**
  50219. * Dispose this timer, clearing all resources
  50220. */
  50221. dispose(): void;
  50222. private _setState;
  50223. private _tick;
  50224. private _stop;
  50225. }
  50226. }
  50227. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50228. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50229. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50230. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50232. import { Vector3 } from "babylonjs/Maths/math.vector";
  50233. import { Material } from "babylonjs/Materials/material";
  50234. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50235. import { Scene } from "babylonjs/scene";
  50236. /**
  50237. * The options container for the teleportation module
  50238. */
  50239. export interface IWebXRTeleportationOptions {
  50240. /**
  50241. * if provided, this scene will be used to render meshes.
  50242. */
  50243. customUtilityLayerScene?: Scene;
  50244. /**
  50245. * Values to configure the default target mesh
  50246. */
  50247. defaultTargetMeshOptions?: {
  50248. /**
  50249. * Fill color of the teleportation area
  50250. */
  50251. teleportationFillColor?: string;
  50252. /**
  50253. * Border color for the teleportation area
  50254. */
  50255. teleportationBorderColor?: string;
  50256. /**
  50257. * Disable the mesh's animation sequence
  50258. */
  50259. disableAnimation?: boolean;
  50260. /**
  50261. * Disable lighting on the material or the ring and arrow
  50262. */
  50263. disableLighting?: boolean;
  50264. /**
  50265. * Override the default material of the torus and arrow
  50266. */
  50267. torusArrowMaterial?: Material;
  50268. };
  50269. /**
  50270. * A list of meshes to use as floor meshes.
  50271. * Meshes can be added and removed after initializing the feature using the
  50272. * addFloorMesh and removeFloorMesh functions
  50273. * If empty, rotation will still work
  50274. */
  50275. floorMeshes?: AbstractMesh[];
  50276. /**
  50277. * use this rendering group id for the meshes (optional)
  50278. */
  50279. renderingGroupId?: number;
  50280. /**
  50281. * Should teleportation move only to snap points
  50282. */
  50283. snapPointsOnly?: boolean;
  50284. /**
  50285. * An array of points to which the teleportation will snap to.
  50286. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50287. */
  50288. snapPositions?: Vector3[];
  50289. /**
  50290. * How close should the teleportation ray be in order to snap to position.
  50291. * Default to 0.8 units (meters)
  50292. */
  50293. snapToPositionRadius?: number;
  50294. /**
  50295. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50296. * If you want to support rotation, make sure your mesh has a direction indicator.
  50297. *
  50298. * When left untouched, the default mesh will be initialized.
  50299. */
  50300. teleportationTargetMesh?: AbstractMesh;
  50301. /**
  50302. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50303. */
  50304. timeToTeleport?: number;
  50305. /**
  50306. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50307. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50308. */
  50309. useMainComponentOnly?: boolean;
  50310. /**
  50311. * Should meshes created here be added to a utility layer or the main scene
  50312. */
  50313. useUtilityLayer?: boolean;
  50314. /**
  50315. * Babylon XR Input class for controller
  50316. */
  50317. xrInput: WebXRInput;
  50318. }
  50319. /**
  50320. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  50321. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  50322. * the input of the attached controllers.
  50323. */
  50324. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  50325. private _options;
  50326. private _controllers;
  50327. private _currentTeleportationControllerId;
  50328. private _floorMeshes;
  50329. private _quadraticBezierCurve;
  50330. private _selectionFeature;
  50331. private _snapToPositions;
  50332. private _snappedToPoint;
  50333. private _teleportationRingMaterial?;
  50334. private _tmpRay;
  50335. private _tmpVector;
  50336. /**
  50337. * The module's name
  50338. */
  50339. static readonly Name: string;
  50340. /**
  50341. * The (Babylon) version of this module.
  50342. * This is an integer representing the implementation version.
  50343. * This number does not correspond to the webxr specs version
  50344. */
  50345. static readonly Version: number;
  50346. /**
  50347. * Is movement backwards enabled
  50348. */
  50349. backwardsMovementEnabled: boolean;
  50350. /**
  50351. * Distance to travel when moving backwards
  50352. */
  50353. backwardsTeleportationDistance: number;
  50354. /**
  50355. * The distance from the user to the inspection point in the direction of the controller
  50356. * A higher number will allow the user to move further
  50357. * defaults to 5 (meters, in xr units)
  50358. */
  50359. parabolicCheckRadius: number;
  50360. /**
  50361. * Should the module support parabolic ray on top of direct ray
  50362. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  50363. * Very helpful when moving between floors / different heights
  50364. */
  50365. parabolicRayEnabled: boolean;
  50366. /**
  50367. * How much rotation should be applied when rotating right and left
  50368. */
  50369. rotationAngle: number;
  50370. /**
  50371. * Is rotation enabled when moving forward?
  50372. * Disabling this feature will prevent the user from deciding the direction when teleporting
  50373. */
  50374. rotationEnabled: boolean;
  50375. /**
  50376. * constructs a new anchor system
  50377. * @param _xrSessionManager an instance of WebXRSessionManager
  50378. * @param _options configuration object for this feature
  50379. */
  50380. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  50381. /**
  50382. * Get the snapPointsOnly flag
  50383. */
  50384. get snapPointsOnly(): boolean;
  50385. /**
  50386. * Sets the snapPointsOnly flag
  50387. * @param snapToPoints should teleportation be exclusively to snap points
  50388. */
  50389. set snapPointsOnly(snapToPoints: boolean);
  50390. /**
  50391. * Add a new mesh to the floor meshes array
  50392. * @param mesh the mesh to use as floor mesh
  50393. */
  50394. addFloorMesh(mesh: AbstractMesh): void;
  50395. /**
  50396. * Add a new snap-to point to fix teleportation to this position
  50397. * @param newSnapPoint The new Snap-To point
  50398. */
  50399. addSnapPoint(newSnapPoint: Vector3): void;
  50400. attach(): boolean;
  50401. detach(): boolean;
  50402. dispose(): void;
  50403. /**
  50404. * Remove a mesh from the floor meshes array
  50405. * @param mesh the mesh to remove
  50406. */
  50407. removeFloorMesh(mesh: AbstractMesh): void;
  50408. /**
  50409. * Remove a mesh from the floor meshes array using its name
  50410. * @param name the mesh name to remove
  50411. */
  50412. removeFloorMeshByName(name: string): void;
  50413. /**
  50414. * 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
  50415. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  50416. * @returns was the point found and removed or not
  50417. */
  50418. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  50419. /**
  50420. * This function sets a selection feature that will be disabled when
  50421. * the forward ray is shown and will be reattached when hidden.
  50422. * This is used to remove the selection rays when moving.
  50423. * @param selectionFeature the feature to disable when forward movement is enabled
  50424. */
  50425. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  50426. protected _onXRFrame(_xrFrame: XRFrame): void;
  50427. private _attachController;
  50428. private _createDefaultTargetMesh;
  50429. private _detachController;
  50430. private _findClosestSnapPointWithRadius;
  50431. private _setTargetMeshPosition;
  50432. private _setTargetMeshVisibility;
  50433. private _showParabolicPath;
  50434. private _teleportForward;
  50435. }
  50436. }
  50437. declare module "babylonjs/XR/webXRDefaultExperience" {
  50438. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50439. import { Scene } from "babylonjs/scene";
  50440. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  50441. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  50442. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50443. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  50444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50445. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  50446. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  50447. /**
  50448. * Options for the default xr helper
  50449. */
  50450. export class WebXRDefaultExperienceOptions {
  50451. /**
  50452. * Enable or disable default UI to enter XR
  50453. */
  50454. disableDefaultUI?: boolean;
  50455. /**
  50456. * Should teleportation not initialize. defaults to false.
  50457. */
  50458. disableTeleportation?: boolean;
  50459. /**
  50460. * Floor meshes that will be used for teleport
  50461. */
  50462. floorMeshes?: Array<AbstractMesh>;
  50463. /**
  50464. * If set to true, the first frame will not be used to reset position
  50465. * The first frame is mainly used when copying transformation from the old camera
  50466. * Mainly used in AR
  50467. */
  50468. ignoreNativeCameraTransformation?: boolean;
  50469. /**
  50470. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  50471. */
  50472. inputOptions?: IWebXRInputOptions;
  50473. /**
  50474. * optional configuration for the output canvas
  50475. */
  50476. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  50477. /**
  50478. * optional UI options. This can be used among other to change session mode and reference space type
  50479. */
  50480. uiOptions?: WebXREnterExitUIOptions;
  50481. /**
  50482. * When loading teleportation and pointer select, use stable versions instead of latest.
  50483. */
  50484. useStablePlugins?: boolean;
  50485. /**
  50486. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  50487. */
  50488. renderingGroupId?: number;
  50489. /**
  50490. * A list of optional features to init the session with
  50491. * If set to true, all features we support will be added
  50492. */
  50493. optionalFeatures?: boolean | string[];
  50494. }
  50495. /**
  50496. * Default experience which provides a similar setup to the previous webVRExperience
  50497. */
  50498. export class WebXRDefaultExperience {
  50499. /**
  50500. * Base experience
  50501. */
  50502. baseExperience: WebXRExperienceHelper;
  50503. /**
  50504. * Enables ui for entering/exiting xr
  50505. */
  50506. enterExitUI: WebXREnterExitUI;
  50507. /**
  50508. * Input experience extension
  50509. */
  50510. input: WebXRInput;
  50511. /**
  50512. * Enables laser pointer and selection
  50513. */
  50514. pointerSelection: WebXRControllerPointerSelection;
  50515. /**
  50516. * Default target xr should render to
  50517. */
  50518. renderTarget: WebXRRenderTarget;
  50519. /**
  50520. * Enables teleportation
  50521. */
  50522. teleportation: WebXRMotionControllerTeleportation;
  50523. private constructor();
  50524. /**
  50525. * Creates the default xr experience
  50526. * @param scene scene
  50527. * @param options options for basic configuration
  50528. * @returns resulting WebXRDefaultExperience
  50529. */
  50530. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50531. /**
  50532. * DIsposes of the experience helper
  50533. */
  50534. dispose(): void;
  50535. }
  50536. }
  50537. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  50538. import { Observable } from "babylonjs/Misc/observable";
  50539. import { Nullable } from "babylonjs/types";
  50540. import { Camera } from "babylonjs/Cameras/camera";
  50541. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  50542. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50543. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  50544. import { Scene } from "babylonjs/scene";
  50545. import { Vector3 } from "babylonjs/Maths/math.vector";
  50546. import { Color3 } from "babylonjs/Maths/math.color";
  50547. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50549. import { Mesh } from "babylonjs/Meshes/mesh";
  50550. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  50551. import { EasingFunction } from "babylonjs/Animations/easing";
  50552. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  50553. import "babylonjs/Meshes/Builders/groundBuilder";
  50554. import "babylonjs/Meshes/Builders/torusBuilder";
  50555. import "babylonjs/Meshes/Builders/cylinderBuilder";
  50556. import "babylonjs/Gamepads/gamepadSceneComponent";
  50557. import "babylonjs/Animations/animatable";
  50558. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  50559. /**
  50560. * Options to modify the vr teleportation behavior.
  50561. */
  50562. export interface VRTeleportationOptions {
  50563. /**
  50564. * The name of the mesh which should be used as the teleportation floor. (default: null)
  50565. */
  50566. floorMeshName?: string;
  50567. /**
  50568. * A list of meshes to be used as the teleportation floor. (default: empty)
  50569. */
  50570. floorMeshes?: Mesh[];
  50571. /**
  50572. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  50573. */
  50574. teleportationMode?: number;
  50575. /**
  50576. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50577. */
  50578. teleportationTime?: number;
  50579. /**
  50580. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50581. */
  50582. teleportationSpeed?: number;
  50583. /**
  50584. * The easing function used in the animation or null for Linear. (default CircleEase)
  50585. */
  50586. easingFunction?: EasingFunction;
  50587. }
  50588. /**
  50589. * Options to modify the vr experience helper's behavior.
  50590. */
  50591. export interface VRExperienceHelperOptions extends WebVROptions {
  50592. /**
  50593. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50594. */
  50595. createDeviceOrientationCamera?: boolean;
  50596. /**
  50597. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50598. */
  50599. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50600. /**
  50601. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50602. */
  50603. laserToggle?: boolean;
  50604. /**
  50605. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50606. */
  50607. floorMeshes?: Mesh[];
  50608. /**
  50609. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50610. */
  50611. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50612. /**
  50613. * Defines if WebXR should be used instead of WebVR (if available)
  50614. */
  50615. useXR?: boolean;
  50616. }
  50617. /**
  50618. * Event containing information after VR has been entered
  50619. */
  50620. export class OnAfterEnteringVRObservableEvent {
  50621. /**
  50622. * If entering vr was successful
  50623. */
  50624. success: boolean;
  50625. }
  50626. /**
  50627. * Helps to quickly add VR support to an existing scene.
  50628. * See https://doc.babylonjs.com/how_to/webvr_helper
  50629. */
  50630. export class VRExperienceHelper {
  50631. /** Options to modify the vr experience helper's behavior. */
  50632. webVROptions: VRExperienceHelperOptions;
  50633. private _scene;
  50634. private _position;
  50635. private _btnVR;
  50636. private _btnVRDisplayed;
  50637. private _webVRsupported;
  50638. private _webVRready;
  50639. private _webVRrequesting;
  50640. private _webVRpresenting;
  50641. private _hasEnteredVR;
  50642. private _fullscreenVRpresenting;
  50643. private _inputElement;
  50644. private _webVRCamera;
  50645. private _vrDeviceOrientationCamera;
  50646. private _deviceOrientationCamera;
  50647. private _existingCamera;
  50648. private _onKeyDown;
  50649. private _onVrDisplayPresentChange;
  50650. private _onVRDisplayChanged;
  50651. private _onVRRequestPresentStart;
  50652. private _onVRRequestPresentComplete;
  50653. /**
  50654. * 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)
  50655. */
  50656. enableGazeEvenWhenNoPointerLock: boolean;
  50657. /**
  50658. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50659. */
  50660. exitVROnDoubleTap: boolean;
  50661. /**
  50662. * Observable raised right before entering VR.
  50663. */
  50664. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50665. /**
  50666. * Observable raised when entering VR has completed.
  50667. */
  50668. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50669. /**
  50670. * Observable raised when exiting VR.
  50671. */
  50672. onExitingVRObservable: Observable<VRExperienceHelper>;
  50673. /**
  50674. * Observable raised when controller mesh is loaded.
  50675. */
  50676. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50677. /** Return this.onEnteringVRObservable
  50678. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50679. */
  50680. get onEnteringVR(): Observable<VRExperienceHelper>;
  50681. /** Return this.onExitingVRObservable
  50682. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50683. */
  50684. get onExitingVR(): Observable<VRExperienceHelper>;
  50685. /** Return this.onControllerMeshLoadedObservable
  50686. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50687. */
  50688. get onControllerMeshLoaded(): Observable<WebVRController>;
  50689. private _rayLength;
  50690. private _useCustomVRButton;
  50691. private _teleportationRequested;
  50692. private _teleportActive;
  50693. private _floorMeshName;
  50694. private _floorMeshesCollection;
  50695. private _teleportationMode;
  50696. private _teleportationTime;
  50697. private _teleportationSpeed;
  50698. private _teleportationEasing;
  50699. private _rotationAllowed;
  50700. private _teleportBackwardsVector;
  50701. private _teleportationTarget;
  50702. private _isDefaultTeleportationTarget;
  50703. private _postProcessMove;
  50704. private _teleportationFillColor;
  50705. private _teleportationBorderColor;
  50706. private _rotationAngle;
  50707. private _haloCenter;
  50708. private _cameraGazer;
  50709. private _padSensibilityUp;
  50710. private _padSensibilityDown;
  50711. private _leftController;
  50712. private _rightController;
  50713. private _gazeColor;
  50714. private _laserColor;
  50715. private _pickedLaserColor;
  50716. private _pickedGazeColor;
  50717. /**
  50718. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50719. */
  50720. onNewMeshSelected: Observable<AbstractMesh>;
  50721. /**
  50722. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50723. * This observable will provide the mesh and the controller used to select the mesh
  50724. */
  50725. onMeshSelectedWithController: Observable<{
  50726. mesh: AbstractMesh;
  50727. controller: WebVRController;
  50728. }>;
  50729. /**
  50730. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50731. */
  50732. onNewMeshPicked: Observable<PickingInfo>;
  50733. private _circleEase;
  50734. /**
  50735. * Observable raised before camera teleportation
  50736. */
  50737. onBeforeCameraTeleport: Observable<Vector3>;
  50738. /**
  50739. * Observable raised after camera teleportation
  50740. */
  50741. onAfterCameraTeleport: Observable<Vector3>;
  50742. /**
  50743. * Observable raised when current selected mesh gets unselected
  50744. */
  50745. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50746. private _raySelectionPredicate;
  50747. /**
  50748. * To be optionaly changed by user to define custom ray selection
  50749. */
  50750. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50751. /**
  50752. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50753. */
  50754. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50755. /**
  50756. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50757. */
  50758. teleportationEnabled: boolean;
  50759. private _defaultHeight;
  50760. private _teleportationInitialized;
  50761. private _interactionsEnabled;
  50762. private _interactionsRequested;
  50763. private _displayGaze;
  50764. private _displayLaserPointer;
  50765. /**
  50766. * The mesh used to display where the user is going to teleport.
  50767. */
  50768. get teleportationTarget(): Mesh;
  50769. /**
  50770. * Sets the mesh to be used to display where the user is going to teleport.
  50771. */
  50772. set teleportationTarget(value: Mesh);
  50773. /**
  50774. * 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
  50775. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50776. * See https://doc.babylonjs.com/resources/baking_transformations
  50777. */
  50778. get gazeTrackerMesh(): Mesh;
  50779. set gazeTrackerMesh(value: Mesh);
  50780. /**
  50781. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50782. */
  50783. updateGazeTrackerScale: boolean;
  50784. /**
  50785. * If the gaze trackers color should be updated when selecting meshes
  50786. */
  50787. updateGazeTrackerColor: boolean;
  50788. /**
  50789. * If the controller laser color should be updated when selecting meshes
  50790. */
  50791. updateControllerLaserColor: boolean;
  50792. /**
  50793. * The gaze tracking mesh corresponding to the left controller
  50794. */
  50795. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50796. /**
  50797. * The gaze tracking mesh corresponding to the right controller
  50798. */
  50799. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50800. /**
  50801. * If the ray of the gaze should be displayed.
  50802. */
  50803. get displayGaze(): boolean;
  50804. /**
  50805. * Sets if the ray of the gaze should be displayed.
  50806. */
  50807. set displayGaze(value: boolean);
  50808. /**
  50809. * If the ray of the LaserPointer should be displayed.
  50810. */
  50811. get displayLaserPointer(): boolean;
  50812. /**
  50813. * Sets if the ray of the LaserPointer should be displayed.
  50814. */
  50815. set displayLaserPointer(value: boolean);
  50816. /**
  50817. * The deviceOrientationCamera used as the camera when not in VR.
  50818. */
  50819. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50820. /**
  50821. * Based on the current WebVR support, returns the current VR camera used.
  50822. */
  50823. get currentVRCamera(): Nullable<Camera>;
  50824. /**
  50825. * The webVRCamera which is used when in VR.
  50826. */
  50827. get webVRCamera(): WebVRFreeCamera;
  50828. /**
  50829. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50830. */
  50831. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50832. /**
  50833. * The html button that is used to trigger entering into VR.
  50834. */
  50835. get vrButton(): Nullable<HTMLButtonElement>;
  50836. private get _teleportationRequestInitiated();
  50837. /**
  50838. * Defines whether or not Pointer lock should be requested when switching to
  50839. * full screen.
  50840. */
  50841. requestPointerLockOnFullScreen: boolean;
  50842. /**
  50843. * If asking to force XR, this will be populated with the default xr experience
  50844. */
  50845. xr: WebXRDefaultExperience;
  50846. /**
  50847. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50848. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50849. */
  50850. xrTestDone: boolean;
  50851. /**
  50852. * Instantiates a VRExperienceHelper.
  50853. * Helps to quickly add VR support to an existing scene.
  50854. * @param scene The scene the VRExperienceHelper belongs to.
  50855. * @param webVROptions Options to modify the vr experience helper's behavior.
  50856. */
  50857. constructor(scene: Scene,
  50858. /** Options to modify the vr experience helper's behavior. */
  50859. webVROptions?: VRExperienceHelperOptions);
  50860. private completeVRInit;
  50861. private _onDefaultMeshLoaded;
  50862. private _onResize;
  50863. private _onFullscreenChange;
  50864. /**
  50865. * Gets a value indicating if we are currently in VR mode.
  50866. */
  50867. get isInVRMode(): boolean;
  50868. private onVrDisplayPresentChange;
  50869. private onVRDisplayChanged;
  50870. private moveButtonToBottomRight;
  50871. private displayVRButton;
  50872. private updateButtonVisibility;
  50873. private _cachedAngularSensibility;
  50874. /**
  50875. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50876. * Otherwise, will use the fullscreen API.
  50877. */
  50878. enterVR(): void;
  50879. /**
  50880. * Attempt to exit VR, or fullscreen.
  50881. */
  50882. exitVR(): void;
  50883. /**
  50884. * The position of the vr experience helper.
  50885. */
  50886. get position(): Vector3;
  50887. /**
  50888. * Sets the position of the vr experience helper.
  50889. */
  50890. set position(value: Vector3);
  50891. /**
  50892. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50893. */
  50894. enableInteractions(): void;
  50895. private get _noControllerIsActive();
  50896. private beforeRender;
  50897. private _isTeleportationFloor;
  50898. /**
  50899. * Adds a floor mesh to be used for teleportation.
  50900. * @param floorMesh the mesh to be used for teleportation.
  50901. */
  50902. addFloorMesh(floorMesh: Mesh): void;
  50903. /**
  50904. * Removes a floor mesh from being used for teleportation.
  50905. * @param floorMesh the mesh to be removed.
  50906. */
  50907. removeFloorMesh(floorMesh: Mesh): void;
  50908. /**
  50909. * Enables interactions and teleportation using the VR controllers and gaze.
  50910. * @param vrTeleportationOptions options to modify teleportation behavior.
  50911. */
  50912. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50913. private _onNewGamepadConnected;
  50914. private _tryEnableInteractionOnController;
  50915. private _onNewGamepadDisconnected;
  50916. private _enableInteractionOnController;
  50917. private _checkTeleportWithRay;
  50918. private _checkRotate;
  50919. private _checkTeleportBackwards;
  50920. private _enableTeleportationOnController;
  50921. private _createTeleportationCircles;
  50922. private _displayTeleportationTarget;
  50923. private _hideTeleportationTarget;
  50924. private _rotateCamera;
  50925. private _moveTeleportationSelectorTo;
  50926. private _workingVector;
  50927. private _workingQuaternion;
  50928. private _workingMatrix;
  50929. /**
  50930. * Time Constant Teleportation Mode
  50931. */
  50932. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50933. /**
  50934. * Speed Constant Teleportation Mode
  50935. */
  50936. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50937. /**
  50938. * Teleports the users feet to the desired location
  50939. * @param location The location where the user's feet should be placed
  50940. */
  50941. teleportCamera(location: Vector3): void;
  50942. private _convertNormalToDirectionOfRay;
  50943. private _castRayAndSelectObject;
  50944. private _notifySelectedMeshUnselected;
  50945. /**
  50946. * Permanently set new colors for the laser pointer
  50947. * @param color the new laser color
  50948. * @param pickedColor the new laser color when picked mesh detected
  50949. */
  50950. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50951. /**
  50952. * Set lighting enabled / disabled on the laser pointer of both controllers
  50953. * @param enabled should the lighting be enabled on the laser pointer
  50954. */
  50955. setLaserLightingState(enabled?: boolean): void;
  50956. /**
  50957. * Permanently set new colors for the gaze pointer
  50958. * @param color the new gaze color
  50959. * @param pickedColor the new gaze color when picked mesh detected
  50960. */
  50961. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50962. /**
  50963. * Sets the color of the laser ray from the vr controllers.
  50964. * @param color new color for the ray.
  50965. */
  50966. changeLaserColor(color: Color3): void;
  50967. /**
  50968. * Sets the color of the ray from the vr headsets gaze.
  50969. * @param color new color for the ray.
  50970. */
  50971. changeGazeColor(color: Color3): void;
  50972. /**
  50973. * Exits VR and disposes of the vr experience helper
  50974. */
  50975. dispose(): void;
  50976. /**
  50977. * Gets the name of the VRExperienceHelper class
  50978. * @returns "VRExperienceHelper"
  50979. */
  50980. getClassName(): string;
  50981. }
  50982. }
  50983. declare module "babylonjs/Cameras/VR/index" {
  50984. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50985. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50986. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50987. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50988. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50989. export * from "babylonjs/Cameras/VR/webVRCamera";
  50990. }
  50991. declare module "babylonjs/Cameras/RigModes/index" {
  50992. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50993. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50994. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50995. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50996. }
  50997. declare module "babylonjs/Cameras/index" {
  50998. export * from "babylonjs/Cameras/Inputs/index";
  50999. export * from "babylonjs/Cameras/cameraInputsManager";
  51000. export * from "babylonjs/Cameras/camera";
  51001. export * from "babylonjs/Cameras/targetCamera";
  51002. export * from "babylonjs/Cameras/freeCamera";
  51003. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51004. export * from "babylonjs/Cameras/touchCamera";
  51005. export * from "babylonjs/Cameras/arcRotateCamera";
  51006. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51007. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51008. export * from "babylonjs/Cameras/flyCamera";
  51009. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51010. export * from "babylonjs/Cameras/followCamera";
  51011. export * from "babylonjs/Cameras/followCameraInputsManager";
  51012. export * from "babylonjs/Cameras/gamepadCamera";
  51013. export * from "babylonjs/Cameras/Stereoscopic/index";
  51014. export * from "babylonjs/Cameras/universalCamera";
  51015. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51016. export * from "babylonjs/Cameras/VR/index";
  51017. export * from "babylonjs/Cameras/RigModes/index";
  51018. }
  51019. declare module "babylonjs/Collisions/index" {
  51020. export * from "babylonjs/Collisions/collider";
  51021. export * from "babylonjs/Collisions/collisionCoordinator";
  51022. export * from "babylonjs/Collisions/pickingInfo";
  51023. export * from "babylonjs/Collisions/intersectionInfo";
  51024. export * from "babylonjs/Collisions/meshCollisionData";
  51025. }
  51026. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51027. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51028. import { Vector3 } from "babylonjs/Maths/math.vector";
  51029. import { Ray } from "babylonjs/Culling/ray";
  51030. import { Plane } from "babylonjs/Maths/math.plane";
  51031. /**
  51032. * Contains an array of blocks representing the octree
  51033. */
  51034. export interface IOctreeContainer<T> {
  51035. /**
  51036. * Blocks within the octree
  51037. */
  51038. blocks: Array<OctreeBlock<T>>;
  51039. }
  51040. /**
  51041. * Class used to store a cell in an octree
  51042. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51043. */
  51044. export class OctreeBlock<T> {
  51045. /**
  51046. * Gets the content of the current block
  51047. */
  51048. entries: T[];
  51049. /**
  51050. * Gets the list of block children
  51051. */
  51052. blocks: Array<OctreeBlock<T>>;
  51053. private _depth;
  51054. private _maxDepth;
  51055. private _capacity;
  51056. private _minPoint;
  51057. private _maxPoint;
  51058. private _boundingVectors;
  51059. private _creationFunc;
  51060. /**
  51061. * Creates a new block
  51062. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51063. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51064. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51065. * @param depth defines the current depth of this block in the octree
  51066. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51067. * @param creationFunc defines a callback to call when an element is added to the block
  51068. */
  51069. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51070. /**
  51071. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51072. */
  51073. get capacity(): number;
  51074. /**
  51075. * Gets the minimum vector (in world space) of the block's bounding box
  51076. */
  51077. get minPoint(): Vector3;
  51078. /**
  51079. * Gets the maximum vector (in world space) of the block's bounding box
  51080. */
  51081. get maxPoint(): Vector3;
  51082. /**
  51083. * Add a new element to this block
  51084. * @param entry defines the element to add
  51085. */
  51086. addEntry(entry: T): void;
  51087. /**
  51088. * Remove an element from this block
  51089. * @param entry defines the element to remove
  51090. */
  51091. removeEntry(entry: T): void;
  51092. /**
  51093. * Add an array of elements to this block
  51094. * @param entries defines the array of elements to add
  51095. */
  51096. addEntries(entries: T[]): void;
  51097. /**
  51098. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51099. * @param frustumPlanes defines the frustum planes to test
  51100. * @param selection defines the array to store current content if selection is positive
  51101. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51102. */
  51103. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51104. /**
  51105. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51106. * @param sphereCenter defines the bounding sphere center
  51107. * @param sphereRadius defines the bounding sphere radius
  51108. * @param selection defines the array to store current content if selection is positive
  51109. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51110. */
  51111. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51112. /**
  51113. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51114. * @param ray defines the ray to test with
  51115. * @param selection defines the array to store current content if selection is positive
  51116. */
  51117. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51118. /**
  51119. * Subdivide the content into child blocks (this block will then be empty)
  51120. */
  51121. createInnerBlocks(): void;
  51122. /**
  51123. * @hidden
  51124. */
  51125. 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;
  51126. }
  51127. }
  51128. declare module "babylonjs/Culling/Octrees/octree" {
  51129. import { SmartArray } from "babylonjs/Misc/smartArray";
  51130. import { Vector3 } from "babylonjs/Maths/math.vector";
  51131. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51133. import { Ray } from "babylonjs/Culling/ray";
  51134. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51135. import { Plane } from "babylonjs/Maths/math.plane";
  51136. /**
  51137. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51138. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51139. */
  51140. export class Octree<T> {
  51141. /** 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.) */
  51142. maxDepth: number;
  51143. /**
  51144. * Blocks within the octree containing objects
  51145. */
  51146. blocks: Array<OctreeBlock<T>>;
  51147. /**
  51148. * Content stored in the octree
  51149. */
  51150. dynamicContent: T[];
  51151. private _maxBlockCapacity;
  51152. private _selectionContent;
  51153. private _creationFunc;
  51154. /**
  51155. * Creates a octree
  51156. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51157. * @param creationFunc function to be used to instatiate the octree
  51158. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51159. * @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.)
  51160. */
  51161. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51162. /** 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.) */
  51163. maxDepth?: number);
  51164. /**
  51165. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51166. * @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);
  51167. * @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);
  51168. * @param entries meshes to be added to the octree blocks
  51169. */
  51170. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51171. /**
  51172. * Adds a mesh to the octree
  51173. * @param entry Mesh to add to the octree
  51174. */
  51175. addMesh(entry: T): void;
  51176. /**
  51177. * Remove an element from the octree
  51178. * @param entry defines the element to remove
  51179. */
  51180. removeMesh(entry: T): void;
  51181. /**
  51182. * Selects an array of meshes within the frustum
  51183. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51184. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51185. * @returns array of meshes within the frustum
  51186. */
  51187. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51188. /**
  51189. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51190. * @param sphereCenter defines the bounding sphere center
  51191. * @param sphereRadius defines the bounding sphere radius
  51192. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51193. * @returns an array of objects that intersect the sphere
  51194. */
  51195. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51196. /**
  51197. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51198. * @param ray defines the ray to test with
  51199. * @returns array of intersected objects
  51200. */
  51201. intersectsRay(ray: Ray): SmartArray<T>;
  51202. /**
  51203. * Adds a mesh into the octree block if it intersects the block
  51204. */
  51205. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51206. /**
  51207. * Adds a submesh into the octree block if it intersects the block
  51208. */
  51209. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51210. }
  51211. }
  51212. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51213. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51214. import { Scene } from "babylonjs/scene";
  51215. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51217. import { Ray } from "babylonjs/Culling/ray";
  51218. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51219. import { Collider } from "babylonjs/Collisions/collider";
  51220. module "babylonjs/scene" {
  51221. interface Scene {
  51222. /**
  51223. * @hidden
  51224. * Backing Filed
  51225. */
  51226. _selectionOctree: Octree<AbstractMesh>;
  51227. /**
  51228. * Gets the octree used to boost mesh selection (picking)
  51229. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51230. */
  51231. selectionOctree: Octree<AbstractMesh>;
  51232. /**
  51233. * Creates or updates the octree used to boost selection (picking)
  51234. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51235. * @param maxCapacity defines the maximum capacity per leaf
  51236. * @param maxDepth defines the maximum depth of the octree
  51237. * @returns an octree of AbstractMesh
  51238. */
  51239. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51240. }
  51241. }
  51242. module "babylonjs/Meshes/abstractMesh" {
  51243. interface AbstractMesh {
  51244. /**
  51245. * @hidden
  51246. * Backing Field
  51247. */
  51248. _submeshesOctree: Octree<SubMesh>;
  51249. /**
  51250. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51251. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51252. * @param maxCapacity defines the maximum size of each block (64 by default)
  51253. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51254. * @returns the new octree
  51255. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51256. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51257. */
  51258. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51259. }
  51260. }
  51261. /**
  51262. * Defines the octree scene component responsible to manage any octrees
  51263. * in a given scene.
  51264. */
  51265. export class OctreeSceneComponent {
  51266. /**
  51267. * The component name help to identify the component in the list of scene components.
  51268. */
  51269. readonly name: string;
  51270. /**
  51271. * The scene the component belongs to.
  51272. */
  51273. scene: Scene;
  51274. /**
  51275. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51276. */
  51277. readonly checksIsEnabled: boolean;
  51278. /**
  51279. * Creates a new instance of the component for the given scene
  51280. * @param scene Defines the scene to register the component in
  51281. */
  51282. constructor(scene: Scene);
  51283. /**
  51284. * Registers the component in a given scene
  51285. */
  51286. register(): void;
  51287. /**
  51288. * Return the list of active meshes
  51289. * @returns the list of active meshes
  51290. */
  51291. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51292. /**
  51293. * Return the list of active sub meshes
  51294. * @param mesh The mesh to get the candidates sub meshes from
  51295. * @returns the list of active sub meshes
  51296. */
  51297. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51298. private _tempRay;
  51299. /**
  51300. * Return the list of sub meshes intersecting with a given local ray
  51301. * @param mesh defines the mesh to find the submesh for
  51302. * @param localRay defines the ray in local space
  51303. * @returns the list of intersecting sub meshes
  51304. */
  51305. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51306. /**
  51307. * Return the list of sub meshes colliding with a collider
  51308. * @param mesh defines the mesh to find the submesh for
  51309. * @param collider defines the collider to evaluate the collision against
  51310. * @returns the list of colliding sub meshes
  51311. */
  51312. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51313. /**
  51314. * Rebuilds the elements related to this component in case of
  51315. * context lost for instance.
  51316. */
  51317. rebuild(): void;
  51318. /**
  51319. * Disposes the component and the associated ressources.
  51320. */
  51321. dispose(): void;
  51322. }
  51323. }
  51324. declare module "babylonjs/Culling/Octrees/index" {
  51325. export * from "babylonjs/Culling/Octrees/octree";
  51326. export * from "babylonjs/Culling/Octrees/octreeBlock";
  51327. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  51328. }
  51329. declare module "babylonjs/Culling/index" {
  51330. export * from "babylonjs/Culling/boundingBox";
  51331. export * from "babylonjs/Culling/boundingInfo";
  51332. export * from "babylonjs/Culling/boundingSphere";
  51333. export * from "babylonjs/Culling/Octrees/index";
  51334. export * from "babylonjs/Culling/ray";
  51335. }
  51336. declare module "babylonjs/Gizmos/gizmo" {
  51337. import { Nullable } from "babylonjs/types";
  51338. import { IDisposable } from "babylonjs/scene";
  51339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51340. import { Mesh } from "babylonjs/Meshes/mesh";
  51341. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51342. /**
  51343. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  51344. */
  51345. export class Gizmo implements IDisposable {
  51346. /** The utility layer the gizmo will be added to */
  51347. gizmoLayer: UtilityLayerRenderer;
  51348. /**
  51349. * The root mesh of the gizmo
  51350. */
  51351. _rootMesh: Mesh;
  51352. private _attachedMesh;
  51353. /**
  51354. * Ratio for the scale of the gizmo (Default: 1)
  51355. */
  51356. scaleRatio: number;
  51357. /**
  51358. * If a custom mesh has been set (Default: false)
  51359. */
  51360. protected _customMeshSet: boolean;
  51361. /**
  51362. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  51363. * * When set, interactions will be enabled
  51364. */
  51365. get attachedMesh(): Nullable<AbstractMesh>;
  51366. set attachedMesh(value: Nullable<AbstractMesh>);
  51367. /**
  51368. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51369. * @param mesh The mesh to replace the default mesh of the gizmo
  51370. */
  51371. setCustomMesh(mesh: Mesh): void;
  51372. /**
  51373. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  51374. */
  51375. updateGizmoRotationToMatchAttachedMesh: boolean;
  51376. /**
  51377. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  51378. */
  51379. updateGizmoPositionToMatchAttachedMesh: boolean;
  51380. /**
  51381. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  51382. */
  51383. updateScale: boolean;
  51384. protected _interactionsEnabled: boolean;
  51385. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51386. private _beforeRenderObserver;
  51387. private _tempVector;
  51388. /**
  51389. * Creates a gizmo
  51390. * @param gizmoLayer The utility layer the gizmo will be added to
  51391. */
  51392. constructor(
  51393. /** The utility layer the gizmo will be added to */
  51394. gizmoLayer?: UtilityLayerRenderer);
  51395. /**
  51396. * Updates the gizmo to match the attached mesh's position/rotation
  51397. */
  51398. protected _update(): void;
  51399. /**
  51400. * Disposes of the gizmo
  51401. */
  51402. dispose(): void;
  51403. }
  51404. }
  51405. declare module "babylonjs/Gizmos/planeDragGizmo" {
  51406. import { Observable } from "babylonjs/Misc/observable";
  51407. import { Nullable } from "babylonjs/types";
  51408. import { Vector3 } from "babylonjs/Maths/math.vector";
  51409. import { Color3 } from "babylonjs/Maths/math.color";
  51410. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51412. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51413. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51414. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51415. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51416. import { Scene } from "babylonjs/scene";
  51417. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51418. /**
  51419. * Single plane drag gizmo
  51420. */
  51421. export class PlaneDragGizmo extends Gizmo {
  51422. /**
  51423. * Drag behavior responsible for the gizmos dragging interactions
  51424. */
  51425. dragBehavior: PointerDragBehavior;
  51426. private _pointerObserver;
  51427. /**
  51428. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51429. */
  51430. snapDistance: number;
  51431. /**
  51432. * Event that fires each time the gizmo snaps to a new location.
  51433. * * snapDistance is the the change in distance
  51434. */
  51435. onSnapObservable: Observable<{
  51436. snapDistance: number;
  51437. }>;
  51438. private _plane;
  51439. private _coloredMaterial;
  51440. private _hoverMaterial;
  51441. private _isEnabled;
  51442. private _parent;
  51443. /** @hidden */
  51444. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  51445. /** @hidden */
  51446. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51447. /**
  51448. * Creates a PlaneDragGizmo
  51449. * @param gizmoLayer The utility layer the gizmo will be added to
  51450. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  51451. * @param color The color of the gizmo
  51452. */
  51453. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51454. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51455. /**
  51456. * If the gizmo is enabled
  51457. */
  51458. set isEnabled(value: boolean);
  51459. get isEnabled(): boolean;
  51460. /**
  51461. * Disposes of the gizmo
  51462. */
  51463. dispose(): void;
  51464. }
  51465. }
  51466. declare module "babylonjs/Gizmos/positionGizmo" {
  51467. import { Observable } from "babylonjs/Misc/observable";
  51468. import { Nullable } from "babylonjs/types";
  51469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51470. import { Mesh } from "babylonjs/Meshes/mesh";
  51471. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51472. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  51473. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  51474. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51475. /**
  51476. * Gizmo that enables dragging a mesh along 3 axis
  51477. */
  51478. export class PositionGizmo extends Gizmo {
  51479. /**
  51480. * Internal gizmo used for interactions on the x axis
  51481. */
  51482. xGizmo: AxisDragGizmo;
  51483. /**
  51484. * Internal gizmo used for interactions on the y axis
  51485. */
  51486. yGizmo: AxisDragGizmo;
  51487. /**
  51488. * Internal gizmo used for interactions on the z axis
  51489. */
  51490. zGizmo: AxisDragGizmo;
  51491. /**
  51492. * Internal gizmo used for interactions on the yz plane
  51493. */
  51494. xPlaneGizmo: PlaneDragGizmo;
  51495. /**
  51496. * Internal gizmo used for interactions on the xz plane
  51497. */
  51498. yPlaneGizmo: PlaneDragGizmo;
  51499. /**
  51500. * Internal gizmo used for interactions on the xy plane
  51501. */
  51502. zPlaneGizmo: PlaneDragGizmo;
  51503. /**
  51504. * private variables
  51505. */
  51506. private _meshAttached;
  51507. private _updateGizmoRotationToMatchAttachedMesh;
  51508. private _snapDistance;
  51509. private _scaleRatio;
  51510. /** Fires an event when any of it's sub gizmos are dragged */
  51511. onDragStartObservable: Observable<unknown>;
  51512. /** Fires an event when any of it's sub gizmos are released from dragging */
  51513. onDragEndObservable: Observable<unknown>;
  51514. /**
  51515. * If set to true, planar drag is enabled
  51516. */
  51517. private _planarGizmoEnabled;
  51518. get attachedMesh(): Nullable<AbstractMesh>;
  51519. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51520. /**
  51521. * Creates a PositionGizmo
  51522. * @param gizmoLayer The utility layer the gizmo will be added to
  51523. */
  51524. constructor(gizmoLayer?: UtilityLayerRenderer);
  51525. /**
  51526. * If the planar drag gizmo is enabled
  51527. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  51528. */
  51529. set planarGizmoEnabled(value: boolean);
  51530. get planarGizmoEnabled(): boolean;
  51531. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51532. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51533. /**
  51534. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51535. */
  51536. set snapDistance(value: number);
  51537. get snapDistance(): number;
  51538. /**
  51539. * Ratio for the scale of the gizmo (Default: 1)
  51540. */
  51541. set scaleRatio(value: number);
  51542. get scaleRatio(): number;
  51543. /**
  51544. * Disposes of the gizmo
  51545. */
  51546. dispose(): void;
  51547. /**
  51548. * CustomMeshes are not supported by this gizmo
  51549. * @param mesh The mesh to replace the default mesh of the gizmo
  51550. */
  51551. setCustomMesh(mesh: Mesh): void;
  51552. }
  51553. }
  51554. declare module "babylonjs/Gizmos/axisDragGizmo" {
  51555. import { Observable } from "babylonjs/Misc/observable";
  51556. import { Nullable } from "babylonjs/types";
  51557. import { Vector3 } from "babylonjs/Maths/math.vector";
  51558. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51560. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51561. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51562. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51563. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51564. import { Scene } from "babylonjs/scene";
  51565. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51566. import { Color3 } from "babylonjs/Maths/math.color";
  51567. /**
  51568. * Single axis drag gizmo
  51569. */
  51570. export class AxisDragGizmo extends Gizmo {
  51571. /**
  51572. * Drag behavior responsible for the gizmos dragging interactions
  51573. */
  51574. dragBehavior: PointerDragBehavior;
  51575. private _pointerObserver;
  51576. /**
  51577. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51578. */
  51579. snapDistance: number;
  51580. /**
  51581. * Event that fires each time the gizmo snaps to a new location.
  51582. * * snapDistance is the the change in distance
  51583. */
  51584. onSnapObservable: Observable<{
  51585. snapDistance: number;
  51586. }>;
  51587. private _isEnabled;
  51588. private _parent;
  51589. private _arrow;
  51590. private _coloredMaterial;
  51591. private _hoverMaterial;
  51592. /** @hidden */
  51593. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51594. /** @hidden */
  51595. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51596. /**
  51597. * Creates an AxisDragGizmo
  51598. * @param gizmoLayer The utility layer the gizmo will be added to
  51599. * @param dragAxis The axis which the gizmo will be able to drag on
  51600. * @param color The color of the gizmo
  51601. */
  51602. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51603. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51604. /**
  51605. * If the gizmo is enabled
  51606. */
  51607. set isEnabled(value: boolean);
  51608. get isEnabled(): boolean;
  51609. /**
  51610. * Disposes of the gizmo
  51611. */
  51612. dispose(): void;
  51613. }
  51614. }
  51615. declare module "babylonjs/Debug/axesViewer" {
  51616. import { Vector3 } from "babylonjs/Maths/math.vector";
  51617. import { Nullable } from "babylonjs/types";
  51618. import { Scene } from "babylonjs/scene";
  51619. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51620. /**
  51621. * The Axes viewer will show 3 axes in a specific point in space
  51622. */
  51623. export class AxesViewer {
  51624. private _xAxis;
  51625. private _yAxis;
  51626. private _zAxis;
  51627. private _scaleLinesFactor;
  51628. private _instanced;
  51629. /**
  51630. * Gets the hosting scene
  51631. */
  51632. scene: Scene;
  51633. /**
  51634. * Gets or sets a number used to scale line length
  51635. */
  51636. scaleLines: number;
  51637. /** Gets the node hierarchy used to render x-axis */
  51638. get xAxis(): TransformNode;
  51639. /** Gets the node hierarchy used to render y-axis */
  51640. get yAxis(): TransformNode;
  51641. /** Gets the node hierarchy used to render z-axis */
  51642. get zAxis(): TransformNode;
  51643. /**
  51644. * Creates a new AxesViewer
  51645. * @param scene defines the hosting scene
  51646. * @param scaleLines defines a number used to scale line length (1 by default)
  51647. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51648. * @param xAxis defines the node hierarchy used to render the x-axis
  51649. * @param yAxis defines the node hierarchy used to render the y-axis
  51650. * @param zAxis defines the node hierarchy used to render the z-axis
  51651. */
  51652. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51653. /**
  51654. * Force the viewer to update
  51655. * @param position defines the position of the viewer
  51656. * @param xaxis defines the x axis of the viewer
  51657. * @param yaxis defines the y axis of the viewer
  51658. * @param zaxis defines the z axis of the viewer
  51659. */
  51660. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51661. /**
  51662. * Creates an instance of this axes viewer.
  51663. * @returns a new axes viewer with instanced meshes
  51664. */
  51665. createInstance(): AxesViewer;
  51666. /** Releases resources */
  51667. dispose(): void;
  51668. private static _SetRenderingGroupId;
  51669. }
  51670. }
  51671. declare module "babylonjs/Debug/boneAxesViewer" {
  51672. import { Nullable } from "babylonjs/types";
  51673. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51674. import { Vector3 } from "babylonjs/Maths/math.vector";
  51675. import { Mesh } from "babylonjs/Meshes/mesh";
  51676. import { Bone } from "babylonjs/Bones/bone";
  51677. import { Scene } from "babylonjs/scene";
  51678. /**
  51679. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51680. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51681. */
  51682. export class BoneAxesViewer extends AxesViewer {
  51683. /**
  51684. * Gets or sets the target mesh where to display the axes viewer
  51685. */
  51686. mesh: Nullable<Mesh>;
  51687. /**
  51688. * Gets or sets the target bone where to display the axes viewer
  51689. */
  51690. bone: Nullable<Bone>;
  51691. /** Gets current position */
  51692. pos: Vector3;
  51693. /** Gets direction of X axis */
  51694. xaxis: Vector3;
  51695. /** Gets direction of Y axis */
  51696. yaxis: Vector3;
  51697. /** Gets direction of Z axis */
  51698. zaxis: Vector3;
  51699. /**
  51700. * Creates a new BoneAxesViewer
  51701. * @param scene defines the hosting scene
  51702. * @param bone defines the target bone
  51703. * @param mesh defines the target mesh
  51704. * @param scaleLines defines a scaling factor for line length (1 by default)
  51705. */
  51706. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51707. /**
  51708. * Force the viewer to update
  51709. */
  51710. update(): void;
  51711. /** Releases resources */
  51712. dispose(): void;
  51713. }
  51714. }
  51715. declare module "babylonjs/Debug/debugLayer" {
  51716. import { Scene } from "babylonjs/scene";
  51717. /**
  51718. * Interface used to define scene explorer extensibility option
  51719. */
  51720. export interface IExplorerExtensibilityOption {
  51721. /**
  51722. * Define the option label
  51723. */
  51724. label: string;
  51725. /**
  51726. * Defines the action to execute on click
  51727. */
  51728. action: (entity: any) => void;
  51729. }
  51730. /**
  51731. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51732. */
  51733. export interface IExplorerExtensibilityGroup {
  51734. /**
  51735. * Defines a predicate to test if a given type mut be extended
  51736. */
  51737. predicate: (entity: any) => boolean;
  51738. /**
  51739. * Gets the list of options added to a type
  51740. */
  51741. entries: IExplorerExtensibilityOption[];
  51742. }
  51743. /**
  51744. * Interface used to define the options to use to create the Inspector
  51745. */
  51746. export interface IInspectorOptions {
  51747. /**
  51748. * Display in overlay mode (default: false)
  51749. */
  51750. overlay?: boolean;
  51751. /**
  51752. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51753. */
  51754. globalRoot?: HTMLElement;
  51755. /**
  51756. * Display the Scene explorer
  51757. */
  51758. showExplorer?: boolean;
  51759. /**
  51760. * Display the property inspector
  51761. */
  51762. showInspector?: boolean;
  51763. /**
  51764. * Display in embed mode (both panes on the right)
  51765. */
  51766. embedMode?: boolean;
  51767. /**
  51768. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51769. */
  51770. handleResize?: boolean;
  51771. /**
  51772. * Allow the panes to popup (default: true)
  51773. */
  51774. enablePopup?: boolean;
  51775. /**
  51776. * Allow the panes to be closed by users (default: true)
  51777. */
  51778. enableClose?: boolean;
  51779. /**
  51780. * Optional list of extensibility entries
  51781. */
  51782. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51783. /**
  51784. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51785. */
  51786. inspectorURL?: string;
  51787. /**
  51788. * Optional initial tab (default to DebugLayerTab.Properties)
  51789. */
  51790. initialTab?: DebugLayerTab;
  51791. }
  51792. module "babylonjs/scene" {
  51793. interface Scene {
  51794. /**
  51795. * @hidden
  51796. * Backing field
  51797. */
  51798. _debugLayer: DebugLayer;
  51799. /**
  51800. * Gets the debug layer (aka Inspector) associated with the scene
  51801. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51802. */
  51803. debugLayer: DebugLayer;
  51804. }
  51805. }
  51806. /**
  51807. * Enum of inspector action tab
  51808. */
  51809. export enum DebugLayerTab {
  51810. /**
  51811. * Properties tag (default)
  51812. */
  51813. Properties = 0,
  51814. /**
  51815. * Debug tab
  51816. */
  51817. Debug = 1,
  51818. /**
  51819. * Statistics tab
  51820. */
  51821. Statistics = 2,
  51822. /**
  51823. * Tools tab
  51824. */
  51825. Tools = 3,
  51826. /**
  51827. * Settings tab
  51828. */
  51829. Settings = 4
  51830. }
  51831. /**
  51832. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51833. * what is happening in your scene
  51834. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51835. */
  51836. export class DebugLayer {
  51837. /**
  51838. * Define the url to get the inspector script from.
  51839. * By default it uses the babylonjs CDN.
  51840. * @ignoreNaming
  51841. */
  51842. static InspectorURL: string;
  51843. private _scene;
  51844. private BJSINSPECTOR;
  51845. private _onPropertyChangedObservable?;
  51846. /**
  51847. * Observable triggered when a property is changed through the inspector.
  51848. */
  51849. get onPropertyChangedObservable(): any;
  51850. /**
  51851. * Instantiates a new debug layer.
  51852. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51853. * what is happening in your scene
  51854. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51855. * @param scene Defines the scene to inspect
  51856. */
  51857. constructor(scene: Scene);
  51858. /** Creates the inspector window. */
  51859. private _createInspector;
  51860. /**
  51861. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51862. * @param entity defines the entity to select
  51863. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51864. */
  51865. select(entity: any, lineContainerTitles?: string | string[]): void;
  51866. /** Get the inspector from bundle or global */
  51867. private _getGlobalInspector;
  51868. /**
  51869. * Get if the inspector is visible or not.
  51870. * @returns true if visible otherwise, false
  51871. */
  51872. isVisible(): boolean;
  51873. /**
  51874. * Hide the inspector and close its window.
  51875. */
  51876. hide(): void;
  51877. /**
  51878. * Update the scene in the inspector
  51879. */
  51880. setAsActiveScene(): void;
  51881. /**
  51882. * Launch the debugLayer.
  51883. * @param config Define the configuration of the inspector
  51884. * @return a promise fulfilled when the debug layer is visible
  51885. */
  51886. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51887. }
  51888. }
  51889. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51890. import { Nullable } from "babylonjs/types";
  51891. import { Scene } from "babylonjs/scene";
  51892. import { Vector4 } from "babylonjs/Maths/math.vector";
  51893. import { Color4 } from "babylonjs/Maths/math.color";
  51894. import { Mesh } from "babylonjs/Meshes/mesh";
  51895. /**
  51896. * Class containing static functions to help procedurally build meshes
  51897. */
  51898. export class BoxBuilder {
  51899. /**
  51900. * Creates a box mesh
  51901. * * The parameter `size` sets the size (float) of each box side (default 1)
  51902. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51903. * * 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)
  51904. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51906. * * 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
  51907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51908. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51909. * @param name defines the name of the mesh
  51910. * @param options defines the options used to create the mesh
  51911. * @param scene defines the hosting scene
  51912. * @returns the box mesh
  51913. */
  51914. static CreateBox(name: string, options: {
  51915. size?: number;
  51916. width?: number;
  51917. height?: number;
  51918. depth?: number;
  51919. faceUV?: Vector4[];
  51920. faceColors?: Color4[];
  51921. sideOrientation?: number;
  51922. frontUVs?: Vector4;
  51923. backUVs?: Vector4;
  51924. wrap?: boolean;
  51925. topBaseAt?: number;
  51926. bottomBaseAt?: number;
  51927. updatable?: boolean;
  51928. }, scene?: Nullable<Scene>): Mesh;
  51929. }
  51930. }
  51931. declare module "babylonjs/Debug/physicsViewer" {
  51932. import { Nullable } from "babylonjs/types";
  51933. import { Scene } from "babylonjs/scene";
  51934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51935. import { Mesh } from "babylonjs/Meshes/mesh";
  51936. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51937. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51938. /**
  51939. * Used to show the physics impostor around the specific mesh
  51940. */
  51941. export class PhysicsViewer {
  51942. /** @hidden */
  51943. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51944. /** @hidden */
  51945. protected _meshes: Array<Nullable<AbstractMesh>>;
  51946. /** @hidden */
  51947. protected _scene: Nullable<Scene>;
  51948. /** @hidden */
  51949. protected _numMeshes: number;
  51950. /** @hidden */
  51951. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51952. private _renderFunction;
  51953. private _utilityLayer;
  51954. private _debugBoxMesh;
  51955. private _debugSphereMesh;
  51956. private _debugCylinderMesh;
  51957. private _debugMaterial;
  51958. private _debugMeshMeshes;
  51959. /**
  51960. * Creates a new PhysicsViewer
  51961. * @param scene defines the hosting scene
  51962. */
  51963. constructor(scene: Scene);
  51964. /** @hidden */
  51965. protected _updateDebugMeshes(): void;
  51966. /**
  51967. * Renders a specified physic impostor
  51968. * @param impostor defines the impostor to render
  51969. * @param targetMesh defines the mesh represented by the impostor
  51970. * @returns the new debug mesh used to render the impostor
  51971. */
  51972. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51973. /**
  51974. * Hides a specified physic impostor
  51975. * @param impostor defines the impostor to hide
  51976. */
  51977. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51978. private _getDebugMaterial;
  51979. private _getDebugBoxMesh;
  51980. private _getDebugSphereMesh;
  51981. private _getDebugCylinderMesh;
  51982. private _getDebugMeshMesh;
  51983. private _getDebugMesh;
  51984. /** Releases all resources */
  51985. dispose(): void;
  51986. }
  51987. }
  51988. declare module "babylonjs/Debug/rayHelper" {
  51989. import { Nullable } from "babylonjs/types";
  51990. import { Ray } from "babylonjs/Culling/ray";
  51991. import { Vector3 } from "babylonjs/Maths/math.vector";
  51992. import { Color3 } from "babylonjs/Maths/math.color";
  51993. import { Scene } from "babylonjs/scene";
  51994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51995. import "babylonjs/Meshes/Builders/linesBuilder";
  51996. /**
  51997. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51998. * in order to better appreciate the issue one might have.
  51999. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52000. */
  52001. export class RayHelper {
  52002. /**
  52003. * Defines the ray we are currently tryin to visualize.
  52004. */
  52005. ray: Nullable<Ray>;
  52006. private _renderPoints;
  52007. private _renderLine;
  52008. private _renderFunction;
  52009. private _scene;
  52010. private _updateToMeshFunction;
  52011. private _attachedToMesh;
  52012. private _meshSpaceDirection;
  52013. private _meshSpaceOrigin;
  52014. /**
  52015. * Helper function to create a colored helper in a scene in one line.
  52016. * @param ray Defines the ray we are currently tryin to visualize
  52017. * @param scene Defines the scene the ray is used in
  52018. * @param color Defines the color we want to see the ray in
  52019. * @returns The newly created ray helper.
  52020. */
  52021. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52022. /**
  52023. * Instantiate a new ray helper.
  52024. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52025. * in order to better appreciate the issue one might have.
  52026. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52027. * @param ray Defines the ray we are currently tryin to visualize
  52028. */
  52029. constructor(ray: Ray);
  52030. /**
  52031. * Shows the ray we are willing to debug.
  52032. * @param scene Defines the scene the ray needs to be rendered in
  52033. * @param color Defines the color the ray needs to be rendered in
  52034. */
  52035. show(scene: Scene, color?: Color3): void;
  52036. /**
  52037. * Hides the ray we are debugging.
  52038. */
  52039. hide(): void;
  52040. private _render;
  52041. /**
  52042. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52043. * @param mesh Defines the mesh we want the helper attached to
  52044. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52045. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52046. * @param length Defines the length of the ray
  52047. */
  52048. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52049. /**
  52050. * Detach the ray helper from the mesh it has previously been attached to.
  52051. */
  52052. detachFromMesh(): void;
  52053. private _updateToMesh;
  52054. /**
  52055. * Dispose the helper and release its associated resources.
  52056. */
  52057. dispose(): void;
  52058. }
  52059. }
  52060. declare module "babylonjs/Debug/skeletonViewer" {
  52061. import { Color3 } from "babylonjs/Maths/math.color";
  52062. import { Scene } from "babylonjs/scene";
  52063. import { Nullable } from "babylonjs/types";
  52064. import { Skeleton } from "babylonjs/Bones/skeleton";
  52065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52066. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52067. /**
  52068. * Class used to render a debug view of a given skeleton
  52069. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  52070. */
  52071. export class SkeletonViewer {
  52072. /** defines the skeleton to render */
  52073. skeleton: Skeleton;
  52074. /** defines the mesh attached to the skeleton */
  52075. mesh: AbstractMesh;
  52076. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52077. autoUpdateBonesMatrices: boolean;
  52078. /** defines the rendering group id to use with the viewer */
  52079. renderingGroupId: number;
  52080. /** Gets or sets the color used to render the skeleton */
  52081. color: Color3;
  52082. private _scene;
  52083. private _debugLines;
  52084. private _debugMesh;
  52085. private _isEnabled;
  52086. private _renderFunction;
  52087. private _utilityLayer;
  52088. /**
  52089. * Returns the mesh used to render the bones
  52090. */
  52091. get debugMesh(): Nullable<LinesMesh>;
  52092. /**
  52093. * Creates a new SkeletonViewer
  52094. * @param skeleton defines the skeleton to render
  52095. * @param mesh defines the mesh attached to the skeleton
  52096. * @param scene defines the hosting scene
  52097. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  52098. * @param renderingGroupId defines the rendering group id to use with the viewer
  52099. */
  52100. constructor(
  52101. /** defines the skeleton to render */
  52102. skeleton: Skeleton,
  52103. /** defines the mesh attached to the skeleton */
  52104. mesh: AbstractMesh, scene: Scene,
  52105. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52106. autoUpdateBonesMatrices?: boolean,
  52107. /** defines the rendering group id to use with the viewer */
  52108. renderingGroupId?: number);
  52109. /** Gets or sets a boolean indicating if the viewer is enabled */
  52110. set isEnabled(value: boolean);
  52111. get isEnabled(): boolean;
  52112. private _getBonePosition;
  52113. private _getLinesForBonesWithLength;
  52114. private _getLinesForBonesNoLength;
  52115. /** Update the viewer to sync with current skeleton state */
  52116. update(): void;
  52117. /** Release associated resources */
  52118. dispose(): void;
  52119. }
  52120. }
  52121. declare module "babylonjs/Debug/index" {
  52122. export * from "babylonjs/Debug/axesViewer";
  52123. export * from "babylonjs/Debug/boneAxesViewer";
  52124. export * from "babylonjs/Debug/debugLayer";
  52125. export * from "babylonjs/Debug/physicsViewer";
  52126. export * from "babylonjs/Debug/rayHelper";
  52127. export * from "babylonjs/Debug/skeletonViewer";
  52128. }
  52129. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  52130. /**
  52131. * Enum for Device Types
  52132. */
  52133. export enum DeviceType {
  52134. /** Generic */
  52135. Generic = 0,
  52136. /** Keyboard */
  52137. Keyboard = 1,
  52138. /** Mouse */
  52139. Mouse = 2,
  52140. /** Touch Pointers */
  52141. Touch = 3,
  52142. /** PS4 Dual Shock */
  52143. DualShock = 4,
  52144. /** Xbox */
  52145. Xbox = 5,
  52146. /** Switch Controller */
  52147. Switch = 6
  52148. }
  52149. /**
  52150. * Enum for All Pointers (Touch/Mouse)
  52151. */
  52152. export enum PointerInput {
  52153. /** Horizontal Axis */
  52154. Horizontal = 0,
  52155. /** Vertical Axis */
  52156. Vertical = 1,
  52157. /** Left Click or Touch */
  52158. LeftClick = 2,
  52159. /** Middle Click */
  52160. MiddleClick = 3,
  52161. /** Right Click */
  52162. RightClick = 4,
  52163. /** Browser Back */
  52164. BrowserBack = 5,
  52165. /** Browser Forward */
  52166. BrowserForward = 6
  52167. }
  52168. /**
  52169. * Enum for Dual Shock Gamepad
  52170. */
  52171. export enum DualShockInput {
  52172. /** Cross */
  52173. Cross = 0,
  52174. /** Circle */
  52175. Circle = 1,
  52176. /** Square */
  52177. Square = 2,
  52178. /** Triangle */
  52179. Triangle = 3,
  52180. /** L1 */
  52181. L1 = 4,
  52182. /** R1 */
  52183. R1 = 5,
  52184. /** L2 */
  52185. L2 = 6,
  52186. /** R2 */
  52187. R2 = 7,
  52188. /** Share */
  52189. Share = 8,
  52190. /** Options */
  52191. Options = 9,
  52192. /** L3 */
  52193. L3 = 10,
  52194. /** R3 */
  52195. R3 = 11,
  52196. /** DPadUp */
  52197. DPadUp = 12,
  52198. /** DPadDown */
  52199. DPadDown = 13,
  52200. /** DPadLeft */
  52201. DPadLeft = 14,
  52202. /** DRight */
  52203. DPadRight = 15,
  52204. /** Home */
  52205. Home = 16,
  52206. /** TouchPad */
  52207. TouchPad = 17,
  52208. /** LStickXAxis */
  52209. LStickXAxis = 18,
  52210. /** LStickYAxis */
  52211. LStickYAxis = 19,
  52212. /** RStickXAxis */
  52213. RStickXAxis = 20,
  52214. /** RStickYAxis */
  52215. RStickYAxis = 21
  52216. }
  52217. /**
  52218. * Enum for Xbox Gamepad
  52219. */
  52220. export enum XboxInput {
  52221. /** A */
  52222. A = 0,
  52223. /** B */
  52224. B = 1,
  52225. /** X */
  52226. X = 2,
  52227. /** Y */
  52228. Y = 3,
  52229. /** LB */
  52230. LB = 4,
  52231. /** RB */
  52232. RB = 5,
  52233. /** LT */
  52234. LT = 6,
  52235. /** RT */
  52236. RT = 7,
  52237. /** Back */
  52238. Back = 8,
  52239. /** Start */
  52240. Start = 9,
  52241. /** LS */
  52242. LS = 10,
  52243. /** RS */
  52244. RS = 11,
  52245. /** DPadUp */
  52246. DPadUp = 12,
  52247. /** DPadDown */
  52248. DPadDown = 13,
  52249. /** DPadLeft */
  52250. DPadLeft = 14,
  52251. /** DRight */
  52252. DPadRight = 15,
  52253. /** Home */
  52254. Home = 16,
  52255. /** LStickXAxis */
  52256. LStickXAxis = 17,
  52257. /** LStickYAxis */
  52258. LStickYAxis = 18,
  52259. /** RStickXAxis */
  52260. RStickXAxis = 19,
  52261. /** RStickYAxis */
  52262. RStickYAxis = 20
  52263. }
  52264. /**
  52265. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  52266. */
  52267. export enum SwitchInput {
  52268. /** B */
  52269. B = 0,
  52270. /** A */
  52271. A = 1,
  52272. /** Y */
  52273. Y = 2,
  52274. /** X */
  52275. X = 3,
  52276. /** L */
  52277. L = 4,
  52278. /** R */
  52279. R = 5,
  52280. /** ZL */
  52281. ZL = 6,
  52282. /** ZR */
  52283. ZR = 7,
  52284. /** Minus */
  52285. Minus = 8,
  52286. /** Plus */
  52287. Plus = 9,
  52288. /** LS */
  52289. LS = 10,
  52290. /** RS */
  52291. RS = 11,
  52292. /** DPadUp */
  52293. DPadUp = 12,
  52294. /** DPadDown */
  52295. DPadDown = 13,
  52296. /** DPadLeft */
  52297. DPadLeft = 14,
  52298. /** DRight */
  52299. DPadRight = 15,
  52300. /** Home */
  52301. Home = 16,
  52302. /** Capture */
  52303. Capture = 17,
  52304. /** LStickXAxis */
  52305. LStickXAxis = 18,
  52306. /** LStickYAxis */
  52307. LStickYAxis = 19,
  52308. /** RStickXAxis */
  52309. RStickXAxis = 20,
  52310. /** RStickYAxis */
  52311. RStickYAxis = 21
  52312. }
  52313. }
  52314. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  52315. import { Engine } from "babylonjs/Engines/engine";
  52316. import { IDisposable } from "babylonjs/scene";
  52317. import { Nullable } from "babylonjs/types";
  52318. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52319. /**
  52320. * This class will take all inputs from Keyboard, Pointer, and
  52321. * any Gamepads and provide a polling system that all devices
  52322. * will use. This class assumes that there will only be one
  52323. * pointer device and one keyboard.
  52324. */
  52325. export class DeviceInputSystem implements IDisposable {
  52326. /**
  52327. * Callback to be triggered when a device is connected
  52328. */
  52329. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52330. /**
  52331. * Callback to be triggered when a device is disconnected
  52332. */
  52333. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52334. /**
  52335. * Callback to be triggered when event driven input is updated
  52336. */
  52337. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  52338. private _inputs;
  52339. private _gamepads;
  52340. private _keyboardActive;
  52341. private _pointerActive;
  52342. private _elementToAttachTo;
  52343. private _keyboardDownEvent;
  52344. private _keyboardUpEvent;
  52345. private _pointerMoveEvent;
  52346. private _pointerDownEvent;
  52347. private _pointerUpEvent;
  52348. private _gamepadConnectedEvent;
  52349. private _gamepadDisconnectedEvent;
  52350. private static _MAX_KEYCODES;
  52351. private static _MAX_POINTER_INPUTS;
  52352. private constructor();
  52353. /**
  52354. * Creates a new DeviceInputSystem instance
  52355. * @param engine Engine to pull input element from
  52356. * @returns The new instance
  52357. */
  52358. static Create(engine: Engine): DeviceInputSystem;
  52359. /**
  52360. * Checks for current device input value, given an id and input index
  52361. * @param deviceName Id of connected device
  52362. * @param inputIndex Index of device input
  52363. * @returns Current value of input
  52364. */
  52365. /**
  52366. * Checks for current device input value, given an id and input index
  52367. * @param deviceType Enum specifiying device type
  52368. * @param deviceSlot "Slot" or index that device is referenced in
  52369. * @param inputIndex Id of input to be checked
  52370. * @returns Current value of input
  52371. */
  52372. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  52373. /**
  52374. * Dispose of all the eventlisteners
  52375. */
  52376. dispose(): void;
  52377. /**
  52378. * Add device and inputs to device array
  52379. * @param deviceType Enum specifiying device type
  52380. * @param deviceSlot "Slot" or index that device is referenced in
  52381. * @param numberOfInputs Number of input entries to create for given device
  52382. */
  52383. private _registerDevice;
  52384. /**
  52385. * Given a specific device name, remove that device from the device map
  52386. * @param deviceType Enum specifiying device type
  52387. * @param deviceSlot "Slot" or index that device is referenced in
  52388. */
  52389. private _unregisterDevice;
  52390. /**
  52391. * Handle all actions that come from keyboard interaction
  52392. */
  52393. private _handleKeyActions;
  52394. /**
  52395. * Handle all actions that come from pointer interaction
  52396. */
  52397. private _handlePointerActions;
  52398. /**
  52399. * Handle all actions that come from gamepad interaction
  52400. */
  52401. private _handleGamepadActions;
  52402. /**
  52403. * Update all non-event based devices with each frame
  52404. * @param deviceType Enum specifiying device type
  52405. * @param deviceSlot "Slot" or index that device is referenced in
  52406. * @param inputIndex Id of input to be checked
  52407. */
  52408. private _updateDevice;
  52409. /**
  52410. * Gets DeviceType from the device name
  52411. * @param deviceName Name of Device from DeviceInputSystem
  52412. * @returns DeviceType enum value
  52413. */
  52414. private _getGamepadDeviceType;
  52415. }
  52416. }
  52417. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  52418. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52419. /**
  52420. * Type to handle enforcement of inputs
  52421. */
  52422. 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;
  52423. }
  52424. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  52425. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  52426. import { Engine } from "babylonjs/Engines/engine";
  52427. import { IDisposable } from "babylonjs/scene";
  52428. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52429. import { Nullable } from "babylonjs/types";
  52430. import { Observable } from "babylonjs/Misc/observable";
  52431. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52432. /**
  52433. * Class that handles all input for a specific device
  52434. */
  52435. export class DeviceSource<T extends DeviceType> {
  52436. /** Type of device */
  52437. readonly deviceType: DeviceType;
  52438. /** "Slot" or index that device is referenced in */
  52439. readonly deviceSlot: number;
  52440. /**
  52441. * Observable to handle device input changes per device
  52442. */
  52443. readonly onInputChangedObservable: Observable<{
  52444. inputIndex: DeviceInput<T>;
  52445. previousState: Nullable<number>;
  52446. currentState: Nullable<number>;
  52447. }>;
  52448. private readonly _deviceInputSystem;
  52449. /**
  52450. * Default Constructor
  52451. * @param deviceInputSystem Reference to DeviceInputSystem
  52452. * @param deviceType Type of device
  52453. * @param deviceSlot "Slot" or index that device is referenced in
  52454. */
  52455. constructor(deviceInputSystem: DeviceInputSystem,
  52456. /** Type of device */
  52457. deviceType: DeviceType,
  52458. /** "Slot" or index that device is referenced in */
  52459. deviceSlot?: number);
  52460. /**
  52461. * Get input for specific input
  52462. * @param inputIndex index of specific input on device
  52463. * @returns Input value from DeviceInputSystem
  52464. */
  52465. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  52466. }
  52467. /**
  52468. * Class to keep track of devices
  52469. */
  52470. export class DeviceSourceManager implements IDisposable {
  52471. /**
  52472. * Observable to be triggered when before a device is connected
  52473. */
  52474. readonly onBeforeDeviceConnectedObservable: Observable<{
  52475. deviceType: DeviceType;
  52476. deviceSlot: number;
  52477. }>;
  52478. /**
  52479. * Observable to be triggered when before a device is disconnected
  52480. */
  52481. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  52482. deviceType: DeviceType;
  52483. deviceSlot: number;
  52484. }>;
  52485. /**
  52486. * Observable to be triggered when after a device is connected
  52487. */
  52488. readonly onAfterDeviceConnectedObservable: Observable<{
  52489. deviceType: DeviceType;
  52490. deviceSlot: number;
  52491. }>;
  52492. /**
  52493. * Observable to be triggered when after a device is disconnected
  52494. */
  52495. readonly onAfterDeviceDisconnectedObservable: Observable<{
  52496. deviceType: DeviceType;
  52497. deviceSlot: number;
  52498. }>;
  52499. private readonly _devices;
  52500. private readonly _firstDevice;
  52501. private readonly _deviceInputSystem;
  52502. /**
  52503. * Default Constructor
  52504. * @param engine engine to pull input element from
  52505. */
  52506. constructor(engine: Engine);
  52507. /**
  52508. * Gets a DeviceSource, given a type and slot
  52509. * @param deviceType Enum specifying device type
  52510. * @param deviceSlot "Slot" or index that device is referenced in
  52511. * @returns DeviceSource object
  52512. */
  52513. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  52514. /**
  52515. * Gets an array of DeviceSource objects for a given device type
  52516. * @param deviceType Enum specifying device type
  52517. * @returns Array of DeviceSource objects
  52518. */
  52519. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  52520. /**
  52521. * Dispose of DeviceInputSystem and other parts
  52522. */
  52523. dispose(): void;
  52524. /**
  52525. * Function to add device name to device list
  52526. * @param deviceType Enum specifying device type
  52527. * @param deviceSlot "Slot" or index that device is referenced in
  52528. */
  52529. private _addDevice;
  52530. /**
  52531. * Function to remove device name to device list
  52532. * @param deviceType Enum specifying device type
  52533. * @param deviceSlot "Slot" or index that device is referenced in
  52534. */
  52535. private _removeDevice;
  52536. /**
  52537. * Updates array storing first connected device of each type
  52538. * @param type Type of Device
  52539. */
  52540. private _updateFirstDevices;
  52541. }
  52542. }
  52543. declare module "babylonjs/DeviceInput/index" {
  52544. export * from "babylonjs/DeviceInput/deviceInputSystem";
  52545. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52546. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52547. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52548. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52549. }
  52550. declare module "babylonjs/Engines/nullEngine" {
  52551. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  52552. import { Engine } from "babylonjs/Engines/engine";
  52553. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  52554. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  52555. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52556. import { Effect } from "babylonjs/Materials/effect";
  52557. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  52558. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52559. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  52560. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  52561. /**
  52562. * Options to create the null engine
  52563. */
  52564. export class NullEngineOptions {
  52565. /**
  52566. * Render width (Default: 512)
  52567. */
  52568. renderWidth: number;
  52569. /**
  52570. * Render height (Default: 256)
  52571. */
  52572. renderHeight: number;
  52573. /**
  52574. * Texture size (Default: 512)
  52575. */
  52576. textureSize: number;
  52577. /**
  52578. * If delta time between frames should be constant
  52579. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52580. */
  52581. deterministicLockstep: boolean;
  52582. /**
  52583. * Maximum about of steps between frames (Default: 4)
  52584. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52585. */
  52586. lockstepMaxSteps: number;
  52587. }
  52588. /**
  52589. * The null engine class provides support for headless version of babylon.js.
  52590. * This can be used in server side scenario or for testing purposes
  52591. */
  52592. export class NullEngine extends Engine {
  52593. private _options;
  52594. /**
  52595. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52596. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52597. * @returns true if engine is in deterministic lock step mode
  52598. */
  52599. isDeterministicLockStep(): boolean;
  52600. /**
  52601. * Gets the max steps when engine is running in deterministic lock step
  52602. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52603. * @returns the max steps
  52604. */
  52605. getLockstepMaxSteps(): number;
  52606. /**
  52607. * Gets the current hardware scaling level.
  52608. * By default the hardware scaling level is computed from the window device ratio.
  52609. * 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.
  52610. * @returns a number indicating the current hardware scaling level
  52611. */
  52612. getHardwareScalingLevel(): number;
  52613. constructor(options?: NullEngineOptions);
  52614. /**
  52615. * Creates a vertex buffer
  52616. * @param vertices the data for the vertex buffer
  52617. * @returns the new WebGL static buffer
  52618. */
  52619. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52620. /**
  52621. * Creates a new index buffer
  52622. * @param indices defines the content of the index buffer
  52623. * @param updatable defines if the index buffer must be updatable
  52624. * @returns a new webGL buffer
  52625. */
  52626. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52627. /**
  52628. * Clear the current render buffer or the current render target (if any is set up)
  52629. * @param color defines the color to use
  52630. * @param backBuffer defines if the back buffer must be cleared
  52631. * @param depth defines if the depth buffer must be cleared
  52632. * @param stencil defines if the stencil buffer must be cleared
  52633. */
  52634. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52635. /**
  52636. * Gets the current render width
  52637. * @param useScreen defines if screen size must be used (or the current render target if any)
  52638. * @returns a number defining the current render width
  52639. */
  52640. getRenderWidth(useScreen?: boolean): number;
  52641. /**
  52642. * Gets the current render height
  52643. * @param useScreen defines if screen size must be used (or the current render target if any)
  52644. * @returns a number defining the current render height
  52645. */
  52646. getRenderHeight(useScreen?: boolean): number;
  52647. /**
  52648. * Set the WebGL's viewport
  52649. * @param viewport defines the viewport element to be used
  52650. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52651. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52652. */
  52653. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52654. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52655. /**
  52656. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52657. * @param pipelineContext defines the pipeline context to use
  52658. * @param uniformsNames defines the list of uniform names
  52659. * @returns an array of webGL uniform locations
  52660. */
  52661. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52662. /**
  52663. * Gets the lsit of active attributes for a given webGL program
  52664. * @param pipelineContext defines the pipeline context to use
  52665. * @param attributesNames defines the list of attribute names to get
  52666. * @returns an array of indices indicating the offset of each attribute
  52667. */
  52668. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52669. /**
  52670. * Binds an effect to the webGL context
  52671. * @param effect defines the effect to bind
  52672. */
  52673. bindSamplers(effect: Effect): void;
  52674. /**
  52675. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52676. * @param effect defines the effect to activate
  52677. */
  52678. enableEffect(effect: Effect): void;
  52679. /**
  52680. * Set various states to the webGL context
  52681. * @param culling defines backface culling state
  52682. * @param zOffset defines the value to apply to zOffset (0 by default)
  52683. * @param force defines if states must be applied even if cache is up to date
  52684. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52685. */
  52686. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52687. /**
  52688. * Set the value of an uniform to an array of int32
  52689. * @param uniform defines the webGL uniform location where to store the value
  52690. * @param array defines the array of int32 to store
  52691. */
  52692. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52693. /**
  52694. * Set the value of an uniform to an array of int32 (stored as vec2)
  52695. * @param uniform defines the webGL uniform location where to store the value
  52696. * @param array defines the array of int32 to store
  52697. */
  52698. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52699. /**
  52700. * Set the value of an uniform to an array of int32 (stored as vec3)
  52701. * @param uniform defines the webGL uniform location where to store the value
  52702. * @param array defines the array of int32 to store
  52703. */
  52704. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52705. /**
  52706. * Set the value of an uniform to an array of int32 (stored as vec4)
  52707. * @param uniform defines the webGL uniform location where to store the value
  52708. * @param array defines the array of int32 to store
  52709. */
  52710. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52711. /**
  52712. * Set the value of an uniform to an array of float32
  52713. * @param uniform defines the webGL uniform location where to store the value
  52714. * @param array defines the array of float32 to store
  52715. */
  52716. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52717. /**
  52718. * Set the value of an uniform to an array of float32 (stored as vec2)
  52719. * @param uniform defines the webGL uniform location where to store the value
  52720. * @param array defines the array of float32 to store
  52721. */
  52722. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52723. /**
  52724. * Set the value of an uniform to an array of float32 (stored as vec3)
  52725. * @param uniform defines the webGL uniform location where to store the value
  52726. * @param array defines the array of float32 to store
  52727. */
  52728. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52729. /**
  52730. * Set the value of an uniform to an array of float32 (stored as vec4)
  52731. * @param uniform defines the webGL uniform location where to store the value
  52732. * @param array defines the array of float32 to store
  52733. */
  52734. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52735. /**
  52736. * Set the value of an uniform to an array of number
  52737. * @param uniform defines the webGL uniform location where to store the value
  52738. * @param array defines the array of number to store
  52739. */
  52740. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52741. /**
  52742. * Set the value of an uniform to an array of number (stored as vec2)
  52743. * @param uniform defines the webGL uniform location where to store the value
  52744. * @param array defines the array of number to store
  52745. */
  52746. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52747. /**
  52748. * Set the value of an uniform to an array of number (stored as vec3)
  52749. * @param uniform defines the webGL uniform location where to store the value
  52750. * @param array defines the array of number to store
  52751. */
  52752. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52753. /**
  52754. * Set the value of an uniform to an array of number (stored as vec4)
  52755. * @param uniform defines the webGL uniform location where to store the value
  52756. * @param array defines the array of number to store
  52757. */
  52758. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52759. /**
  52760. * Set the value of an uniform to an array of float32 (stored as matrices)
  52761. * @param uniform defines the webGL uniform location where to store the value
  52762. * @param matrices defines the array of float32 to store
  52763. */
  52764. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52765. /**
  52766. * Set the value of an uniform to a matrix (3x3)
  52767. * @param uniform defines the webGL uniform location where to store the value
  52768. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52769. */
  52770. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52771. /**
  52772. * Set the value of an uniform to a matrix (2x2)
  52773. * @param uniform defines the webGL uniform location where to store the value
  52774. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52775. */
  52776. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52777. /**
  52778. * Set the value of an uniform to a number (float)
  52779. * @param uniform defines the webGL uniform location where to store the value
  52780. * @param value defines the float number to store
  52781. */
  52782. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52783. /**
  52784. * Set the value of an uniform to a vec2
  52785. * @param uniform defines the webGL uniform location where to store the value
  52786. * @param x defines the 1st component of the value
  52787. * @param y defines the 2nd component of the value
  52788. */
  52789. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52790. /**
  52791. * Set the value of an uniform to a vec3
  52792. * @param uniform defines the webGL uniform location where to store the value
  52793. * @param x defines the 1st component of the value
  52794. * @param y defines the 2nd component of the value
  52795. * @param z defines the 3rd component of the value
  52796. */
  52797. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52798. /**
  52799. * Set the value of an uniform to a boolean
  52800. * @param uniform defines the webGL uniform location where to store the value
  52801. * @param bool defines the boolean to store
  52802. */
  52803. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52804. /**
  52805. * Set the value of an uniform to a vec4
  52806. * @param uniform defines the webGL uniform location where to store the value
  52807. * @param x defines the 1st component of the value
  52808. * @param y defines the 2nd component of the value
  52809. * @param z defines the 3rd component of the value
  52810. * @param w defines the 4th component of the value
  52811. */
  52812. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52813. /**
  52814. * Sets the current alpha mode
  52815. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52816. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52817. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52818. */
  52819. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52820. /**
  52821. * Bind webGl buffers directly to the webGL context
  52822. * @param vertexBuffers defines the vertex buffer to bind
  52823. * @param indexBuffer defines the index buffer to bind
  52824. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52825. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52826. * @param effect defines the effect associated with the vertex buffer
  52827. */
  52828. bindBuffers(vertexBuffers: {
  52829. [key: string]: VertexBuffer;
  52830. }, indexBuffer: DataBuffer, effect: Effect): void;
  52831. /**
  52832. * Force the entire cache to be cleared
  52833. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52834. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52835. */
  52836. wipeCaches(bruteForce?: boolean): void;
  52837. /**
  52838. * Send a draw order
  52839. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52840. * @param indexStart defines the starting index
  52841. * @param indexCount defines the number of index to draw
  52842. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52843. */
  52844. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52845. /**
  52846. * Draw a list of indexed primitives
  52847. * @param fillMode defines the primitive to use
  52848. * @param indexStart defines the starting index
  52849. * @param indexCount defines the number of index to draw
  52850. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52851. */
  52852. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52853. /**
  52854. * Draw a list of unindexed primitives
  52855. * @param fillMode defines the primitive to use
  52856. * @param verticesStart defines the index of first vertex to draw
  52857. * @param verticesCount defines the count of vertices to draw
  52858. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52859. */
  52860. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52861. /** @hidden */
  52862. _createTexture(): WebGLTexture;
  52863. /** @hidden */
  52864. _releaseTexture(texture: InternalTexture): void;
  52865. /**
  52866. * Usually called from Texture.ts.
  52867. * Passed information to create a WebGLTexture
  52868. * @param urlArg defines a value which contains one of the following:
  52869. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52870. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52871. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52872. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52873. * @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)
  52874. * @param scene needed for loading to the correct scene
  52875. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52876. * @param onLoad optional callback to be called upon successful completion
  52877. * @param onError optional callback to be called upon failure
  52878. * @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
  52879. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52880. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52881. * @param forcedExtension defines the extension to use to pick the right loader
  52882. * @param mimeType defines an optional mime type
  52883. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52884. */
  52885. 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;
  52886. /**
  52887. * Creates a new render target texture
  52888. * @param size defines the size of the texture
  52889. * @param options defines the options used to create the texture
  52890. * @returns a new render target texture stored in an InternalTexture
  52891. */
  52892. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52893. /**
  52894. * Update the sampling mode of a given texture
  52895. * @param samplingMode defines the required sampling mode
  52896. * @param texture defines the texture to update
  52897. */
  52898. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52899. /**
  52900. * Binds the frame buffer to the specified texture.
  52901. * @param texture The texture to render to or null for the default canvas
  52902. * @param faceIndex The face of the texture to render to in case of cube texture
  52903. * @param requiredWidth The width of the target to render to
  52904. * @param requiredHeight The height of the target to render to
  52905. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52906. * @param lodLevel defines le lod level to bind to the frame buffer
  52907. */
  52908. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52909. /**
  52910. * Unbind the current render target texture from the webGL context
  52911. * @param texture defines the render target texture to unbind
  52912. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52913. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52914. */
  52915. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52916. /**
  52917. * Creates a dynamic vertex buffer
  52918. * @param vertices the data for the dynamic vertex buffer
  52919. * @returns the new WebGL dynamic buffer
  52920. */
  52921. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52922. /**
  52923. * Update the content of a dynamic texture
  52924. * @param texture defines the texture to update
  52925. * @param canvas defines the canvas containing the source
  52926. * @param invertY defines if data must be stored with Y axis inverted
  52927. * @param premulAlpha defines if alpha is stored as premultiplied
  52928. * @param format defines the format of the data
  52929. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52930. */
  52931. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52932. /**
  52933. * Gets a boolean indicating if all created effects are ready
  52934. * @returns true if all effects are ready
  52935. */
  52936. areAllEffectsReady(): boolean;
  52937. /**
  52938. * @hidden
  52939. * Get the current error code of the webGL context
  52940. * @returns the error code
  52941. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52942. */
  52943. getError(): number;
  52944. /** @hidden */
  52945. _getUnpackAlignement(): number;
  52946. /** @hidden */
  52947. _unpackFlipY(value: boolean): void;
  52948. /**
  52949. * Update a dynamic index buffer
  52950. * @param indexBuffer defines the target index buffer
  52951. * @param indices defines the data to update
  52952. * @param offset defines the offset in the target index buffer where update should start
  52953. */
  52954. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52955. /**
  52956. * Updates a dynamic vertex buffer.
  52957. * @param vertexBuffer the vertex buffer to update
  52958. * @param vertices the data used to update the vertex buffer
  52959. * @param byteOffset the byte offset of the data (optional)
  52960. * @param byteLength the byte length of the data (optional)
  52961. */
  52962. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52963. /** @hidden */
  52964. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52965. /** @hidden */
  52966. _bindTexture(channel: number, texture: InternalTexture): void;
  52967. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52968. /**
  52969. * 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
  52970. */
  52971. releaseEffects(): void;
  52972. displayLoadingUI(): void;
  52973. hideLoadingUI(): void;
  52974. /** @hidden */
  52975. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52976. /** @hidden */
  52977. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52978. /** @hidden */
  52979. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52980. /** @hidden */
  52981. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52982. }
  52983. }
  52984. declare module "babylonjs/Instrumentation/timeToken" {
  52985. import { Nullable } from "babylonjs/types";
  52986. /**
  52987. * @hidden
  52988. **/
  52989. export class _TimeToken {
  52990. _startTimeQuery: Nullable<WebGLQuery>;
  52991. _endTimeQuery: Nullable<WebGLQuery>;
  52992. _timeElapsedQuery: Nullable<WebGLQuery>;
  52993. _timeElapsedQueryEnded: boolean;
  52994. }
  52995. }
  52996. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52997. import { Nullable, int } from "babylonjs/types";
  52998. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52999. /** @hidden */
  53000. export class _OcclusionDataStorage {
  53001. /** @hidden */
  53002. occlusionInternalRetryCounter: number;
  53003. /** @hidden */
  53004. isOcclusionQueryInProgress: boolean;
  53005. /** @hidden */
  53006. isOccluded: boolean;
  53007. /** @hidden */
  53008. occlusionRetryCount: number;
  53009. /** @hidden */
  53010. occlusionType: number;
  53011. /** @hidden */
  53012. occlusionQueryAlgorithmType: number;
  53013. }
  53014. module "babylonjs/Engines/engine" {
  53015. interface Engine {
  53016. /**
  53017. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  53018. * @return the new query
  53019. */
  53020. createQuery(): WebGLQuery;
  53021. /**
  53022. * Delete and release a webGL query
  53023. * @param query defines the query to delete
  53024. * @return the current engine
  53025. */
  53026. deleteQuery(query: WebGLQuery): Engine;
  53027. /**
  53028. * Check if a given query has resolved and got its value
  53029. * @param query defines the query to check
  53030. * @returns true if the query got its value
  53031. */
  53032. isQueryResultAvailable(query: WebGLQuery): boolean;
  53033. /**
  53034. * Gets the value of a given query
  53035. * @param query defines the query to check
  53036. * @returns the value of the query
  53037. */
  53038. getQueryResult(query: WebGLQuery): number;
  53039. /**
  53040. * Initiates an occlusion query
  53041. * @param algorithmType defines the algorithm to use
  53042. * @param query defines the query to use
  53043. * @returns the current engine
  53044. * @see https://doc.babylonjs.com/features/occlusionquery
  53045. */
  53046. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  53047. /**
  53048. * Ends an occlusion query
  53049. * @see https://doc.babylonjs.com/features/occlusionquery
  53050. * @param algorithmType defines the algorithm to use
  53051. * @returns the current engine
  53052. */
  53053. endOcclusionQuery(algorithmType: number): Engine;
  53054. /**
  53055. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  53056. * Please note that only one query can be issued at a time
  53057. * @returns a time token used to track the time span
  53058. */
  53059. startTimeQuery(): Nullable<_TimeToken>;
  53060. /**
  53061. * Ends a time query
  53062. * @param token defines the token used to measure the time span
  53063. * @returns the time spent (in ns)
  53064. */
  53065. endTimeQuery(token: _TimeToken): int;
  53066. /** @hidden */
  53067. _currentNonTimestampToken: Nullable<_TimeToken>;
  53068. /** @hidden */
  53069. _createTimeQuery(): WebGLQuery;
  53070. /** @hidden */
  53071. _deleteTimeQuery(query: WebGLQuery): void;
  53072. /** @hidden */
  53073. _getGlAlgorithmType(algorithmType: number): number;
  53074. /** @hidden */
  53075. _getTimeQueryResult(query: WebGLQuery): any;
  53076. /** @hidden */
  53077. _getTimeQueryAvailability(query: WebGLQuery): any;
  53078. }
  53079. }
  53080. module "babylonjs/Meshes/abstractMesh" {
  53081. interface AbstractMesh {
  53082. /**
  53083. * Backing filed
  53084. * @hidden
  53085. */
  53086. __occlusionDataStorage: _OcclusionDataStorage;
  53087. /**
  53088. * Access property
  53089. * @hidden
  53090. */
  53091. _occlusionDataStorage: _OcclusionDataStorage;
  53092. /**
  53093. * 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.
  53094. * The default value is -1 which means don't break the query and wait till the result
  53095. * @see https://doc.babylonjs.com/features/occlusionquery
  53096. */
  53097. occlusionRetryCount: number;
  53098. /**
  53099. * 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:
  53100. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  53101. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  53102. * * 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.
  53103. * @see https://doc.babylonjs.com/features/occlusionquery
  53104. */
  53105. occlusionType: number;
  53106. /**
  53107. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  53108. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  53109. * * 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.
  53110. * @see https://doc.babylonjs.com/features/occlusionquery
  53111. */
  53112. occlusionQueryAlgorithmType: number;
  53113. /**
  53114. * 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
  53115. * @see https://doc.babylonjs.com/features/occlusionquery
  53116. */
  53117. isOccluded: boolean;
  53118. /**
  53119. * Flag to check the progress status of the query
  53120. * @see https://doc.babylonjs.com/features/occlusionquery
  53121. */
  53122. isOcclusionQueryInProgress: boolean;
  53123. }
  53124. }
  53125. }
  53126. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  53127. import { Nullable } from "babylonjs/types";
  53128. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53129. /** @hidden */
  53130. export var _forceTransformFeedbackToBundle: boolean;
  53131. module "babylonjs/Engines/engine" {
  53132. interface Engine {
  53133. /**
  53134. * Creates a webGL transform feedback object
  53135. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  53136. * @returns the webGL transform feedback object
  53137. */
  53138. createTransformFeedback(): WebGLTransformFeedback;
  53139. /**
  53140. * Delete a webGL transform feedback object
  53141. * @param value defines the webGL transform feedback object to delete
  53142. */
  53143. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  53144. /**
  53145. * Bind a webGL transform feedback object to the webgl context
  53146. * @param value defines the webGL transform feedback object to bind
  53147. */
  53148. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  53149. /**
  53150. * Begins a transform feedback operation
  53151. * @param usePoints defines if points or triangles must be used
  53152. */
  53153. beginTransformFeedback(usePoints: boolean): void;
  53154. /**
  53155. * Ends a transform feedback operation
  53156. */
  53157. endTransformFeedback(): void;
  53158. /**
  53159. * Specify the varyings to use with transform feedback
  53160. * @param program defines the associated webGL program
  53161. * @param value defines the list of strings representing the varying names
  53162. */
  53163. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  53164. /**
  53165. * Bind a webGL buffer for a transform feedback operation
  53166. * @param value defines the webGL buffer to bind
  53167. */
  53168. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  53169. }
  53170. }
  53171. }
  53172. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  53173. import { Scene } from "babylonjs/scene";
  53174. import { Engine } from "babylonjs/Engines/engine";
  53175. import { Texture } from "babylonjs/Materials/Textures/texture";
  53176. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53177. import "babylonjs/Engines/Extensions/engine.multiRender";
  53178. /**
  53179. * Creation options of the multi render target texture.
  53180. */
  53181. export interface IMultiRenderTargetOptions {
  53182. /**
  53183. * Define if the texture needs to create mip maps after render.
  53184. */
  53185. generateMipMaps?: boolean;
  53186. /**
  53187. * Define the types of all the draw buffers we want to create
  53188. */
  53189. types?: number[];
  53190. /**
  53191. * Define the sampling modes of all the draw buffers we want to create
  53192. */
  53193. samplingModes?: number[];
  53194. /**
  53195. * Define if a depth buffer is required
  53196. */
  53197. generateDepthBuffer?: boolean;
  53198. /**
  53199. * Define if a stencil buffer is required
  53200. */
  53201. generateStencilBuffer?: boolean;
  53202. /**
  53203. * Define if a depth texture is required instead of a depth buffer
  53204. */
  53205. generateDepthTexture?: boolean;
  53206. /**
  53207. * Define the number of desired draw buffers
  53208. */
  53209. textureCount?: number;
  53210. /**
  53211. * Define if aspect ratio should be adapted to the texture or stay the scene one
  53212. */
  53213. doNotChangeAspectRatio?: boolean;
  53214. /**
  53215. * Define the default type of the buffers we are creating
  53216. */
  53217. defaultType?: number;
  53218. }
  53219. /**
  53220. * A multi render target, like a render target provides the ability to render to a texture.
  53221. * Unlike the render target, it can render to several draw buffers in one draw.
  53222. * This is specially interesting in deferred rendering or for any effects requiring more than
  53223. * just one color from a single pass.
  53224. */
  53225. export class MultiRenderTarget extends RenderTargetTexture {
  53226. private _internalTextures;
  53227. private _textures;
  53228. private _multiRenderTargetOptions;
  53229. private _count;
  53230. /**
  53231. * Get if draw buffers are currently supported by the used hardware and browser.
  53232. */
  53233. get isSupported(): boolean;
  53234. /**
  53235. * Get the list of textures generated by the multi render target.
  53236. */
  53237. get textures(): Texture[];
  53238. /**
  53239. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  53240. */
  53241. get count(): number;
  53242. /**
  53243. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  53244. */
  53245. get depthTexture(): Texture;
  53246. /**
  53247. * Set the wrapping mode on U of all the textures we are rendering to.
  53248. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53249. */
  53250. set wrapU(wrap: number);
  53251. /**
  53252. * Set the wrapping mode on V of all the textures we are rendering to.
  53253. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53254. */
  53255. set wrapV(wrap: number);
  53256. /**
  53257. * Instantiate a new multi render target texture.
  53258. * A multi render target, like a render target provides the ability to render to a texture.
  53259. * Unlike the render target, it can render to several draw buffers in one draw.
  53260. * This is specially interesting in deferred rendering or for any effects requiring more than
  53261. * just one color from a single pass.
  53262. * @param name Define the name of the texture
  53263. * @param size Define the size of the buffers to render to
  53264. * @param count Define the number of target we are rendering into
  53265. * @param scene Define the scene the texture belongs to
  53266. * @param options Define the options used to create the multi render target
  53267. */
  53268. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  53269. /** @hidden */
  53270. _rebuild(): void;
  53271. private _createInternalTextures;
  53272. private _createTextures;
  53273. /**
  53274. * Define the number of samples used if MSAA is enabled.
  53275. */
  53276. get samples(): number;
  53277. set samples(value: number);
  53278. /**
  53279. * Resize all the textures in the multi render target.
  53280. * Be carrefull as it will recreate all the data in the new texture.
  53281. * @param size Define the new size
  53282. */
  53283. resize(size: any): void;
  53284. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  53285. /**
  53286. * Dispose the render targets and their associated resources
  53287. */
  53288. dispose(): void;
  53289. /**
  53290. * Release all the underlying texture used as draw buffers.
  53291. */
  53292. releaseInternalTextures(): void;
  53293. }
  53294. }
  53295. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  53296. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53297. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  53298. import { Nullable } from "babylonjs/types";
  53299. module "babylonjs/Engines/thinEngine" {
  53300. interface ThinEngine {
  53301. /**
  53302. * Unbind a list of render target textures from the webGL context
  53303. * This is used only when drawBuffer extension or webGL2 are active
  53304. * @param textures defines the render target textures to unbind
  53305. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53306. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53307. */
  53308. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  53309. /**
  53310. * Create a multi render target texture
  53311. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  53312. * @param size defines the size of the texture
  53313. * @param options defines the creation options
  53314. * @returns the cube texture as an InternalTexture
  53315. */
  53316. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  53317. /**
  53318. * Update the sample count for a given multiple render target texture
  53319. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  53320. * @param textures defines the textures to update
  53321. * @param samples defines the sample count to set
  53322. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  53323. */
  53324. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  53325. /**
  53326. * Select a subsets of attachments to draw to.
  53327. * @param attachments gl attachments
  53328. */
  53329. bindAttachments(attachments: number[]): void;
  53330. }
  53331. }
  53332. }
  53333. declare module "babylonjs/Engines/Extensions/engine.views" {
  53334. import { Camera } from "babylonjs/Cameras/camera";
  53335. import { Nullable } from "babylonjs/types";
  53336. /**
  53337. * Class used to define an additional view for the engine
  53338. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53339. */
  53340. export class EngineView {
  53341. /** Defines the canvas where to render the view */
  53342. target: HTMLCanvasElement;
  53343. /** Defines an optional camera used to render the view (will use active camera else) */
  53344. camera?: Camera;
  53345. }
  53346. module "babylonjs/Engines/engine" {
  53347. interface Engine {
  53348. /**
  53349. * Gets or sets the HTML element to use for attaching events
  53350. */
  53351. inputElement: Nullable<HTMLElement>;
  53352. /**
  53353. * Gets the current engine view
  53354. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53355. */
  53356. activeView: Nullable<EngineView>;
  53357. /** Gets or sets the list of views */
  53358. views: EngineView[];
  53359. /**
  53360. * Register a new child canvas
  53361. * @param canvas defines the canvas to register
  53362. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53363. * @returns the associated view
  53364. */
  53365. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53366. /**
  53367. * Remove a registered child canvas
  53368. * @param canvas defines the canvas to remove
  53369. * @returns the current engine
  53370. */
  53371. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53372. }
  53373. }
  53374. }
  53375. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53376. import { Nullable } from "babylonjs/types";
  53377. module "babylonjs/Engines/engine" {
  53378. interface Engine {
  53379. /** @hidden */
  53380. _excludedCompressedTextures: string[];
  53381. /** @hidden */
  53382. _textureFormatInUse: string;
  53383. /**
  53384. * Gets the list of texture formats supported
  53385. */
  53386. readonly texturesSupported: Array<string>;
  53387. /**
  53388. * Gets the texture format in use
  53389. */
  53390. readonly textureFormatInUse: Nullable<string>;
  53391. /**
  53392. * Set the compressed texture extensions or file names to skip.
  53393. *
  53394. * @param skippedFiles defines the list of those texture files you want to skip
  53395. * Example: [".dds", ".env", "myfile.png"]
  53396. */
  53397. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53398. /**
  53399. * Set the compressed texture format to use, based on the formats you have, and the formats
  53400. * supported by the hardware / browser.
  53401. *
  53402. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53403. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53404. * to API arguments needed to compressed textures. This puts the burden on the container
  53405. * generator to house the arcane code for determining these for current & future formats.
  53406. *
  53407. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53408. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53409. *
  53410. * Note: The result of this call is not taken into account when a texture is base64.
  53411. *
  53412. * @param formatsAvailable defines the list of those format families you have created
  53413. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53414. *
  53415. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53416. * @returns The extension selected.
  53417. */
  53418. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53419. }
  53420. }
  53421. }
  53422. declare module "babylonjs/Engines/Extensions/index" {
  53423. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53424. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53425. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53426. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53427. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53428. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53429. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53430. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53431. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53432. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53433. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53434. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53435. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53436. export * from "babylonjs/Engines/Extensions/engine.views";
  53437. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53438. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53439. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53440. }
  53441. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53442. import { Nullable } from "babylonjs/types";
  53443. /**
  53444. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53445. */
  53446. export interface CubeMapInfo {
  53447. /**
  53448. * The pixel array for the front face.
  53449. * This is stored in format, left to right, up to down format.
  53450. */
  53451. front: Nullable<ArrayBufferView>;
  53452. /**
  53453. * The pixel array for the back face.
  53454. * This is stored in format, left to right, up to down format.
  53455. */
  53456. back: Nullable<ArrayBufferView>;
  53457. /**
  53458. * The pixel array for the left face.
  53459. * This is stored in format, left to right, up to down format.
  53460. */
  53461. left: Nullable<ArrayBufferView>;
  53462. /**
  53463. * The pixel array for the right face.
  53464. * This is stored in format, left to right, up to down format.
  53465. */
  53466. right: Nullable<ArrayBufferView>;
  53467. /**
  53468. * The pixel array for the up face.
  53469. * This is stored in format, left to right, up to down format.
  53470. */
  53471. up: Nullable<ArrayBufferView>;
  53472. /**
  53473. * The pixel array for the down face.
  53474. * This is stored in format, left to right, up to down format.
  53475. */
  53476. down: Nullable<ArrayBufferView>;
  53477. /**
  53478. * The size of the cubemap stored.
  53479. *
  53480. * Each faces will be size * size pixels.
  53481. */
  53482. size: number;
  53483. /**
  53484. * The format of the texture.
  53485. *
  53486. * RGBA, RGB.
  53487. */
  53488. format: number;
  53489. /**
  53490. * The type of the texture data.
  53491. *
  53492. * UNSIGNED_INT, FLOAT.
  53493. */
  53494. type: number;
  53495. /**
  53496. * Specifies whether the texture is in gamma space.
  53497. */
  53498. gammaSpace: boolean;
  53499. }
  53500. /**
  53501. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  53502. */
  53503. export class PanoramaToCubeMapTools {
  53504. private static FACE_LEFT;
  53505. private static FACE_RIGHT;
  53506. private static FACE_FRONT;
  53507. private static FACE_BACK;
  53508. private static FACE_DOWN;
  53509. private static FACE_UP;
  53510. /**
  53511. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  53512. *
  53513. * @param float32Array The source data.
  53514. * @param inputWidth The width of the input panorama.
  53515. * @param inputHeight The height of the input panorama.
  53516. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  53517. * @return The cubemap data
  53518. */
  53519. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  53520. private static CreateCubemapTexture;
  53521. private static CalcProjectionSpherical;
  53522. }
  53523. }
  53524. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  53525. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53526. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53527. import { Nullable } from "babylonjs/types";
  53528. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53529. /**
  53530. * Helper class dealing with the extraction of spherical polynomial dataArray
  53531. * from a cube map.
  53532. */
  53533. export class CubeMapToSphericalPolynomialTools {
  53534. private static FileFaces;
  53535. /**
  53536. * Converts a texture to the according Spherical Polynomial data.
  53537. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53538. *
  53539. * @param texture The texture to extract the information from.
  53540. * @return The Spherical Polynomial data.
  53541. */
  53542. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  53543. /**
  53544. * Converts a cubemap to the according Spherical Polynomial data.
  53545. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53546. *
  53547. * @param cubeInfo The Cube map to extract the information from.
  53548. * @return The Spherical Polynomial data.
  53549. */
  53550. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  53551. }
  53552. }
  53553. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  53554. import { Nullable } from "babylonjs/types";
  53555. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53556. module "babylonjs/Materials/Textures/baseTexture" {
  53557. interface BaseTexture {
  53558. /**
  53559. * Get the polynomial representation of the texture data.
  53560. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  53561. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  53562. */
  53563. sphericalPolynomial: Nullable<SphericalPolynomial>;
  53564. }
  53565. }
  53566. }
  53567. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  53568. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53569. /** @hidden */
  53570. export var rgbdEncodePixelShader: {
  53571. name: string;
  53572. shader: string;
  53573. };
  53574. }
  53575. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  53576. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53577. /** @hidden */
  53578. export var rgbdDecodePixelShader: {
  53579. name: string;
  53580. shader: string;
  53581. };
  53582. }
  53583. declare module "babylonjs/Misc/environmentTextureTools" {
  53584. import { Nullable } from "babylonjs/types";
  53585. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53586. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53587. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53588. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53589. import "babylonjs/Engines/Extensions/engine.readTexture";
  53590. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53591. import "babylonjs/Shaders/rgbdEncode.fragment";
  53592. import "babylonjs/Shaders/rgbdDecode.fragment";
  53593. /**
  53594. * Raw texture data and descriptor sufficient for WebGL texture upload
  53595. */
  53596. export interface EnvironmentTextureInfo {
  53597. /**
  53598. * Version of the environment map
  53599. */
  53600. version: number;
  53601. /**
  53602. * Width of image
  53603. */
  53604. width: number;
  53605. /**
  53606. * Irradiance information stored in the file.
  53607. */
  53608. irradiance: any;
  53609. /**
  53610. * Specular information stored in the file.
  53611. */
  53612. specular: any;
  53613. }
  53614. /**
  53615. * Defines One Image in the file. It requires only the position in the file
  53616. * as well as the length.
  53617. */
  53618. interface BufferImageData {
  53619. /**
  53620. * Length of the image data.
  53621. */
  53622. length: number;
  53623. /**
  53624. * Position of the data from the null terminator delimiting the end of the JSON.
  53625. */
  53626. position: number;
  53627. }
  53628. /**
  53629. * Defines the specular data enclosed in the file.
  53630. * This corresponds to the version 1 of the data.
  53631. */
  53632. export interface EnvironmentTextureSpecularInfoV1 {
  53633. /**
  53634. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53635. */
  53636. specularDataPosition?: number;
  53637. /**
  53638. * This contains all the images data needed to reconstruct the cubemap.
  53639. */
  53640. mipmaps: Array<BufferImageData>;
  53641. /**
  53642. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53643. */
  53644. lodGenerationScale: number;
  53645. }
  53646. /**
  53647. * Sets of helpers addressing the serialization and deserialization of environment texture
  53648. * stored in a BabylonJS env file.
  53649. * Those files are usually stored as .env files.
  53650. */
  53651. export class EnvironmentTextureTools {
  53652. /**
  53653. * Magic number identifying the env file.
  53654. */
  53655. private static _MagicBytes;
  53656. /**
  53657. * Gets the environment info from an env file.
  53658. * @param data The array buffer containing the .env bytes.
  53659. * @returns the environment file info (the json header) if successfully parsed.
  53660. */
  53661. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53662. /**
  53663. * Creates an environment texture from a loaded cube texture.
  53664. * @param texture defines the cube texture to convert in env file
  53665. * @return a promise containing the environment data if succesfull.
  53666. */
  53667. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53668. /**
  53669. * Creates a JSON representation of the spherical data.
  53670. * @param texture defines the texture containing the polynomials
  53671. * @return the JSON representation of the spherical info
  53672. */
  53673. private static _CreateEnvTextureIrradiance;
  53674. /**
  53675. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53676. * @param data the image data
  53677. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53678. * @return the views described by info providing access to the underlying buffer
  53679. */
  53680. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53681. /**
  53682. * Uploads the texture info contained in the env file to the GPU.
  53683. * @param texture defines the internal texture to upload to
  53684. * @param data defines the data to load
  53685. * @param info defines the texture info retrieved through the GetEnvInfo method
  53686. * @returns a promise
  53687. */
  53688. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53689. private static _OnImageReadyAsync;
  53690. /**
  53691. * Uploads the levels of image data to the GPU.
  53692. * @param texture defines the internal texture to upload to
  53693. * @param imageData defines the array buffer views of image data [mipmap][face]
  53694. * @returns a promise
  53695. */
  53696. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53697. /**
  53698. * Uploads spherical polynomials information to the texture.
  53699. * @param texture defines the texture we are trying to upload the information to
  53700. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53701. */
  53702. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53703. /** @hidden */
  53704. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53705. }
  53706. }
  53707. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53708. /**
  53709. * Class used to inline functions in shader code
  53710. */
  53711. export class ShaderCodeInliner {
  53712. private static readonly _RegexpFindFunctionNameAndType;
  53713. private _sourceCode;
  53714. private _functionDescr;
  53715. private _numMaxIterations;
  53716. /** Gets or sets the token used to mark the functions to inline */
  53717. inlineToken: string;
  53718. /** Gets or sets the debug mode */
  53719. debug: boolean;
  53720. /** Gets the code after the inlining process */
  53721. get code(): string;
  53722. /**
  53723. * Initializes the inliner
  53724. * @param sourceCode shader code source to inline
  53725. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53726. */
  53727. constructor(sourceCode: string, numMaxIterations?: number);
  53728. /**
  53729. * Start the processing of the shader code
  53730. */
  53731. processCode(): void;
  53732. private _collectFunctions;
  53733. private _processInlining;
  53734. private _extractBetweenMarkers;
  53735. private _skipWhitespaces;
  53736. private _removeComments;
  53737. private _replaceFunctionCallsByCode;
  53738. private _findBackward;
  53739. private _escapeRegExp;
  53740. private _replaceNames;
  53741. }
  53742. }
  53743. declare module "babylonjs/Engines/nativeEngine" {
  53744. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53745. import { Engine } from "babylonjs/Engines/engine";
  53746. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53747. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53749. import { Effect } from "babylonjs/Materials/effect";
  53750. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53751. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53752. import { IColor4Like } from "babylonjs/Maths/math.like";
  53753. import { Scene } from "babylonjs/scene";
  53754. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53755. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53756. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53757. /**
  53758. * Container for accessors for natively-stored mesh data buffers.
  53759. */
  53760. class NativeDataBuffer extends DataBuffer {
  53761. /**
  53762. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53763. */
  53764. nativeIndexBuffer?: any;
  53765. /**
  53766. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53767. */
  53768. nativeVertexBuffer?: any;
  53769. }
  53770. /** @hidden */
  53771. class NativeTexture extends InternalTexture {
  53772. getInternalTexture(): InternalTexture;
  53773. getViewCount(): number;
  53774. }
  53775. /** @hidden */
  53776. export class NativeEngine extends Engine {
  53777. private readonly _native;
  53778. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53779. private readonly INVALID_HANDLE;
  53780. getHardwareScalingLevel(): number;
  53781. constructor();
  53782. dispose(): void;
  53783. /**
  53784. * Can be used to override the current requestAnimationFrame requester.
  53785. * @hidden
  53786. */
  53787. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53788. /**
  53789. * Override default engine behavior.
  53790. * @param color
  53791. * @param backBuffer
  53792. * @param depth
  53793. * @param stencil
  53794. */
  53795. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53796. /**
  53797. * Gets host document
  53798. * @returns the host document object
  53799. */
  53800. getHostDocument(): Nullable<Document>;
  53801. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53802. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53803. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53804. recordVertexArrayObject(vertexBuffers: {
  53805. [key: string]: VertexBuffer;
  53806. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53807. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53808. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53809. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53810. /**
  53811. * Draw a list of indexed primitives
  53812. * @param fillMode defines the primitive to use
  53813. * @param indexStart defines the starting index
  53814. * @param indexCount defines the number of index to draw
  53815. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53816. */
  53817. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53818. /**
  53819. * Draw a list of unindexed primitives
  53820. * @param fillMode defines the primitive to use
  53821. * @param verticesStart defines the index of first vertex to draw
  53822. * @param verticesCount defines the count of vertices to draw
  53823. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53824. */
  53825. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53826. createPipelineContext(): IPipelineContext;
  53827. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53828. /** @hidden */
  53829. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53830. /** @hidden */
  53831. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53832. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53833. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53834. protected _setProgram(program: WebGLProgram): void;
  53835. _releaseEffect(effect: Effect): void;
  53836. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53837. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53838. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53839. bindSamplers(effect: Effect): void;
  53840. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53841. getRenderWidth(useScreen?: boolean): number;
  53842. getRenderHeight(useScreen?: boolean): number;
  53843. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53844. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53845. /**
  53846. * Set the z offset to apply to current rendering
  53847. * @param value defines the offset to apply
  53848. */
  53849. setZOffset(value: number): void;
  53850. /**
  53851. * Gets the current value of the zOffset
  53852. * @returns the current zOffset state
  53853. */
  53854. getZOffset(): number;
  53855. /**
  53856. * Enable or disable depth buffering
  53857. * @param enable defines the state to set
  53858. */
  53859. setDepthBuffer(enable: boolean): void;
  53860. /**
  53861. * Gets a boolean indicating if depth writing is enabled
  53862. * @returns the current depth writing state
  53863. */
  53864. getDepthWrite(): boolean;
  53865. /**
  53866. * Enable or disable depth writing
  53867. * @param enable defines the state to set
  53868. */
  53869. setDepthWrite(enable: boolean): void;
  53870. /**
  53871. * Enable or disable color writing
  53872. * @param enable defines the state to set
  53873. */
  53874. setColorWrite(enable: boolean): void;
  53875. /**
  53876. * Gets a boolean indicating if color writing is enabled
  53877. * @returns the current color writing state
  53878. */
  53879. getColorWrite(): boolean;
  53880. /**
  53881. * Sets alpha constants used by some alpha blending modes
  53882. * @param r defines the red component
  53883. * @param g defines the green component
  53884. * @param b defines the blue component
  53885. * @param a defines the alpha component
  53886. */
  53887. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53888. /**
  53889. * Sets the current alpha mode
  53890. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53891. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53892. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53893. */
  53894. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53895. /**
  53896. * Gets the current alpha mode
  53897. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53898. * @returns the current alpha mode
  53899. */
  53900. getAlphaMode(): number;
  53901. setInt(uniform: WebGLUniformLocation, int: number): void;
  53902. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53903. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53904. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53905. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53906. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53907. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53908. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53909. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53910. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53911. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53912. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53913. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53914. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53915. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53916. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53917. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53918. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53919. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53920. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53921. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53922. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53923. wipeCaches(bruteForce?: boolean): void;
  53924. _createTexture(): WebGLTexture;
  53925. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53926. /**
  53927. * Usually called from Texture.ts.
  53928. * Passed information to create a WebGLTexture
  53929. * @param url defines a value which contains one of the following:
  53930. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53931. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53932. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53933. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53934. * @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)
  53935. * @param scene needed for loading to the correct scene
  53936. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53937. * @param onLoad optional callback to be called upon successful completion
  53938. * @param onError optional callback to be called upon failure
  53939. * @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
  53940. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53941. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53942. * @param forcedExtension defines the extension to use to pick the right loader
  53943. * @param mimeType defines an optional mime type
  53944. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53945. */
  53946. 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;
  53947. /**
  53948. * Creates a cube texture
  53949. * @param rootUrl defines the url where the files to load is located
  53950. * @param scene defines the current scene
  53951. * @param files defines the list of files to load (1 per face)
  53952. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53953. * @param onLoad defines an optional callback raised when the texture is loaded
  53954. * @param onError defines an optional callback raised if there is an issue to load the texture
  53955. * @param format defines the format of the data
  53956. * @param forcedExtension defines the extension to use to pick the right loader
  53957. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53958. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53959. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53960. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53961. * @returns the cube texture as an InternalTexture
  53962. */
  53963. 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;
  53964. private _getSamplingFilter;
  53965. private static _GetNativeTextureFormat;
  53966. createRenderTargetTexture(size: number | {
  53967. width: number;
  53968. height: number;
  53969. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53970. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53971. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53972. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53973. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53974. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53975. /**
  53976. * Updates a dynamic vertex buffer.
  53977. * @param vertexBuffer the vertex buffer to update
  53978. * @param data the data used to update the vertex buffer
  53979. * @param byteOffset the byte offset of the data (optional)
  53980. * @param byteLength the byte length of the data (optional)
  53981. */
  53982. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53983. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53984. private _updateAnisotropicLevel;
  53985. private _getAddressMode;
  53986. /** @hidden */
  53987. _bindTexture(channel: number, texture: InternalTexture): void;
  53988. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53989. releaseEffects(): void;
  53990. /** @hidden */
  53991. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53992. /** @hidden */
  53993. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53994. /** @hidden */
  53995. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53996. /** @hidden */
  53997. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53998. }
  53999. }
  54000. declare module "babylonjs/Engines/index" {
  54001. export * from "babylonjs/Engines/constants";
  54002. export * from "babylonjs/Engines/engineCapabilities";
  54003. export * from "babylonjs/Engines/instancingAttributeInfo";
  54004. export * from "babylonjs/Engines/thinEngine";
  54005. export * from "babylonjs/Engines/engine";
  54006. export * from "babylonjs/Engines/engineStore";
  54007. export * from "babylonjs/Engines/nullEngine";
  54008. export * from "babylonjs/Engines/Extensions/index";
  54009. export * from "babylonjs/Engines/IPipelineContext";
  54010. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54011. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54012. export * from "babylonjs/Engines/nativeEngine";
  54013. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54014. }
  54015. declare module "babylonjs/Events/clipboardEvents" {
  54016. /**
  54017. * Gather the list of clipboard event types as constants.
  54018. */
  54019. export class ClipboardEventTypes {
  54020. /**
  54021. * The clipboard event is fired when a copy command is active (pressed).
  54022. */
  54023. static readonly COPY: number;
  54024. /**
  54025. * The clipboard event is fired when a cut command is active (pressed).
  54026. */
  54027. static readonly CUT: number;
  54028. /**
  54029. * The clipboard event is fired when a paste command is active (pressed).
  54030. */
  54031. static readonly PASTE: number;
  54032. }
  54033. /**
  54034. * This class is used to store clipboard related info for the onClipboardObservable event.
  54035. */
  54036. export class ClipboardInfo {
  54037. /**
  54038. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54039. */
  54040. type: number;
  54041. /**
  54042. * Defines the related dom event
  54043. */
  54044. event: ClipboardEvent;
  54045. /**
  54046. *Creates an instance of ClipboardInfo.
  54047. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54048. * @param event Defines the related dom event
  54049. */
  54050. constructor(
  54051. /**
  54052. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54053. */
  54054. type: number,
  54055. /**
  54056. * Defines the related dom event
  54057. */
  54058. event: ClipboardEvent);
  54059. /**
  54060. * Get the clipboard event's type from the keycode.
  54061. * @param keyCode Defines the keyCode for the current keyboard event.
  54062. * @return {number}
  54063. */
  54064. static GetTypeFromCharacter(keyCode: number): number;
  54065. }
  54066. }
  54067. declare module "babylonjs/Events/index" {
  54068. export * from "babylonjs/Events/keyboardEvents";
  54069. export * from "babylonjs/Events/pointerEvents";
  54070. export * from "babylonjs/Events/clipboardEvents";
  54071. }
  54072. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54073. import { Scene } from "babylonjs/scene";
  54074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54075. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54076. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54077. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54078. /**
  54079. * Google Daydream controller
  54080. */
  54081. export class DaydreamController extends WebVRController {
  54082. /**
  54083. * Base Url for the controller model.
  54084. */
  54085. static MODEL_BASE_URL: string;
  54086. /**
  54087. * File name for the controller model.
  54088. */
  54089. static MODEL_FILENAME: string;
  54090. /**
  54091. * Gamepad Id prefix used to identify Daydream Controller.
  54092. */
  54093. static readonly GAMEPAD_ID_PREFIX: string;
  54094. /**
  54095. * Creates a new DaydreamController from a gamepad
  54096. * @param vrGamepad the gamepad that the controller should be created from
  54097. */
  54098. constructor(vrGamepad: any);
  54099. /**
  54100. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54101. * @param scene scene in which to add meshes
  54102. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54103. */
  54104. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54105. /**
  54106. * Called once for each button that changed state since the last frame
  54107. * @param buttonIdx Which button index changed
  54108. * @param state New state of the button
  54109. * @param changes Which properties on the state changed since last frame
  54110. */
  54111. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54112. }
  54113. }
  54114. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54115. import { Scene } from "babylonjs/scene";
  54116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54117. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54118. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54119. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54120. /**
  54121. * Gear VR Controller
  54122. */
  54123. export class GearVRController extends WebVRController {
  54124. /**
  54125. * Base Url for the controller model.
  54126. */
  54127. static MODEL_BASE_URL: string;
  54128. /**
  54129. * File name for the controller model.
  54130. */
  54131. static MODEL_FILENAME: string;
  54132. /**
  54133. * Gamepad Id prefix used to identify this controller.
  54134. */
  54135. static readonly GAMEPAD_ID_PREFIX: string;
  54136. private readonly _buttonIndexToObservableNameMap;
  54137. /**
  54138. * Creates a new GearVRController from a gamepad
  54139. * @param vrGamepad the gamepad that the controller should be created from
  54140. */
  54141. constructor(vrGamepad: any);
  54142. /**
  54143. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54144. * @param scene scene in which to add meshes
  54145. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54146. */
  54147. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54148. /**
  54149. * Called once for each button that changed state since the last frame
  54150. * @param buttonIdx Which button index changed
  54151. * @param state New state of the button
  54152. * @param changes Which properties on the state changed since last frame
  54153. */
  54154. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54155. }
  54156. }
  54157. declare module "babylonjs/Gamepads/Controllers/genericController" {
  54158. import { Scene } from "babylonjs/scene";
  54159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54160. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54161. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54162. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54163. /**
  54164. * Generic Controller
  54165. */
  54166. export class GenericController extends WebVRController {
  54167. /**
  54168. * Base Url for the controller model.
  54169. */
  54170. static readonly MODEL_BASE_URL: string;
  54171. /**
  54172. * File name for the controller model.
  54173. */
  54174. static readonly MODEL_FILENAME: string;
  54175. /**
  54176. * Creates a new GenericController from a gamepad
  54177. * @param vrGamepad the gamepad that the controller should be created from
  54178. */
  54179. constructor(vrGamepad: any);
  54180. /**
  54181. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54182. * @param scene scene in which to add meshes
  54183. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54184. */
  54185. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54186. /**
  54187. * Called once for each button that changed state since the last frame
  54188. * @param buttonIdx Which button index changed
  54189. * @param state New state of the button
  54190. * @param changes Which properties on the state changed since last frame
  54191. */
  54192. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54193. }
  54194. }
  54195. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54196. import { Observable } from "babylonjs/Misc/observable";
  54197. import { Scene } from "babylonjs/scene";
  54198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54199. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54200. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54201. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54202. /**
  54203. * Oculus Touch Controller
  54204. */
  54205. export class OculusTouchController extends WebVRController {
  54206. /**
  54207. * Base Url for the controller model.
  54208. */
  54209. static MODEL_BASE_URL: string;
  54210. /**
  54211. * File name for the left controller model.
  54212. */
  54213. static MODEL_LEFT_FILENAME: string;
  54214. /**
  54215. * File name for the right controller model.
  54216. */
  54217. static MODEL_RIGHT_FILENAME: string;
  54218. /**
  54219. * Base Url for the Quest controller model.
  54220. */
  54221. static QUEST_MODEL_BASE_URL: string;
  54222. /**
  54223. * @hidden
  54224. * If the controllers are running on a device that needs the updated Quest controller models
  54225. */
  54226. static _IsQuest: boolean;
  54227. /**
  54228. * Fired when the secondary trigger on this controller is modified
  54229. */
  54230. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54231. /**
  54232. * Fired when the thumb rest on this controller is modified
  54233. */
  54234. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54235. /**
  54236. * Creates a new OculusTouchController from a gamepad
  54237. * @param vrGamepad the gamepad that the controller should be created from
  54238. */
  54239. constructor(vrGamepad: any);
  54240. /**
  54241. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54242. * @param scene scene in which to add meshes
  54243. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54244. */
  54245. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54246. /**
  54247. * Fired when the A button on this controller is modified
  54248. */
  54249. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54250. /**
  54251. * Fired when the B button on this controller is modified
  54252. */
  54253. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54254. /**
  54255. * Fired when the X button on this controller is modified
  54256. */
  54257. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54258. /**
  54259. * Fired when the Y button on this controller is modified
  54260. */
  54261. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54262. /**
  54263. * Called once for each button that changed state since the last frame
  54264. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  54265. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  54266. * 2) secondary trigger (same)
  54267. * 3) A (right) X (left), touch, pressed = value
  54268. * 4) B / Y
  54269. * 5) thumb rest
  54270. * @param buttonIdx Which button index changed
  54271. * @param state New state of the button
  54272. * @param changes Which properties on the state changed since last frame
  54273. */
  54274. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54275. }
  54276. }
  54277. declare module "babylonjs/Gamepads/Controllers/viveController" {
  54278. import { Scene } from "babylonjs/scene";
  54279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54280. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54281. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54282. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54283. import { Observable } from "babylonjs/Misc/observable";
  54284. /**
  54285. * Vive Controller
  54286. */
  54287. export class ViveController extends WebVRController {
  54288. /**
  54289. * Base Url for the controller model.
  54290. */
  54291. static MODEL_BASE_URL: string;
  54292. /**
  54293. * File name for the controller model.
  54294. */
  54295. static MODEL_FILENAME: string;
  54296. /**
  54297. * Creates a new ViveController from a gamepad
  54298. * @param vrGamepad the gamepad that the controller should be created from
  54299. */
  54300. constructor(vrGamepad: any);
  54301. /**
  54302. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54303. * @param scene scene in which to add meshes
  54304. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54305. */
  54306. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54307. /**
  54308. * Fired when the left button on this controller is modified
  54309. */
  54310. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54311. /**
  54312. * Fired when the right button on this controller is modified
  54313. */
  54314. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54315. /**
  54316. * Fired when the menu button on this controller is modified
  54317. */
  54318. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54319. /**
  54320. * Called once for each button that changed state since the last frame
  54321. * Vive mapping:
  54322. * 0: touchpad
  54323. * 1: trigger
  54324. * 2: left AND right buttons
  54325. * 3: menu button
  54326. * @param buttonIdx Which button index changed
  54327. * @param state New state of the button
  54328. * @param changes Which properties on the state changed since last frame
  54329. */
  54330. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54331. }
  54332. }
  54333. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  54334. import { Observable } from "babylonjs/Misc/observable";
  54335. import { Scene } from "babylonjs/scene";
  54336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54337. import { Ray } from "babylonjs/Culling/ray";
  54338. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54339. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54340. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54341. /**
  54342. * Defines the WindowsMotionController object that the state of the windows motion controller
  54343. */
  54344. export class WindowsMotionController extends WebVRController {
  54345. /**
  54346. * The base url used to load the left and right controller models
  54347. */
  54348. static MODEL_BASE_URL: string;
  54349. /**
  54350. * The name of the left controller model file
  54351. */
  54352. static MODEL_LEFT_FILENAME: string;
  54353. /**
  54354. * The name of the right controller model file
  54355. */
  54356. static MODEL_RIGHT_FILENAME: string;
  54357. /**
  54358. * The controller name prefix for this controller type
  54359. */
  54360. static readonly GAMEPAD_ID_PREFIX: string;
  54361. /**
  54362. * The controller id pattern for this controller type
  54363. */
  54364. private static readonly GAMEPAD_ID_PATTERN;
  54365. private _loadedMeshInfo;
  54366. protected readonly _mapping: {
  54367. buttons: string[];
  54368. buttonMeshNames: {
  54369. trigger: string;
  54370. menu: string;
  54371. grip: string;
  54372. thumbstick: string;
  54373. trackpad: string;
  54374. };
  54375. buttonObservableNames: {
  54376. trigger: string;
  54377. menu: string;
  54378. grip: string;
  54379. thumbstick: string;
  54380. trackpad: string;
  54381. };
  54382. axisMeshNames: string[];
  54383. pointingPoseMeshName: string;
  54384. };
  54385. /**
  54386. * Fired when the trackpad on this controller is clicked
  54387. */
  54388. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54389. /**
  54390. * Fired when the trackpad on this controller is modified
  54391. */
  54392. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54393. /**
  54394. * The current x and y values of this controller's trackpad
  54395. */
  54396. trackpad: StickValues;
  54397. /**
  54398. * Creates a new WindowsMotionController from a gamepad
  54399. * @param vrGamepad the gamepad that the controller should be created from
  54400. */
  54401. constructor(vrGamepad: any);
  54402. /**
  54403. * Fired when the trigger on this controller is modified
  54404. */
  54405. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54406. /**
  54407. * Fired when the menu button on this controller is modified
  54408. */
  54409. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54410. /**
  54411. * Fired when the grip button on this controller is modified
  54412. */
  54413. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54414. /**
  54415. * Fired when the thumbstick button on this controller is modified
  54416. */
  54417. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54418. /**
  54419. * Fired when the touchpad button on this controller is modified
  54420. */
  54421. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54422. /**
  54423. * Fired when the touchpad values on this controller are modified
  54424. */
  54425. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54426. protected _updateTrackpad(): void;
  54427. /**
  54428. * Called once per frame by the engine.
  54429. */
  54430. update(): void;
  54431. /**
  54432. * Called once for each button that changed state since the last frame
  54433. * @param buttonIdx Which button index changed
  54434. * @param state New state of the button
  54435. * @param changes Which properties on the state changed since last frame
  54436. */
  54437. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54438. /**
  54439. * Moves the buttons on the controller mesh based on their current state
  54440. * @param buttonName the name of the button to move
  54441. * @param buttonValue the value of the button which determines the buttons new position
  54442. */
  54443. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54444. /**
  54445. * Moves the axis on the controller mesh based on its current state
  54446. * @param axis the index of the axis
  54447. * @param axisValue the value of the axis which determines the meshes new position
  54448. * @hidden
  54449. */
  54450. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54451. /**
  54452. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54453. * @param scene scene in which to add meshes
  54454. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54455. */
  54456. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54457. /**
  54458. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  54459. * can be transformed by button presses and axes values, based on this._mapping.
  54460. *
  54461. * @param scene scene in which the meshes exist
  54462. * @param meshes list of meshes that make up the controller model to process
  54463. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  54464. */
  54465. private processModel;
  54466. private createMeshInfo;
  54467. /**
  54468. * Gets the ray of the controller in the direction the controller is pointing
  54469. * @param length the length the resulting ray should be
  54470. * @returns a ray in the direction the controller is pointing
  54471. */
  54472. getForwardRay(length?: number): Ray;
  54473. /**
  54474. * Disposes of the controller
  54475. */
  54476. dispose(): void;
  54477. }
  54478. /**
  54479. * This class represents a new windows motion controller in XR.
  54480. */
  54481. export class XRWindowsMotionController extends WindowsMotionController {
  54482. /**
  54483. * Changing the original WIndowsMotionController mapping to fir the new mapping
  54484. */
  54485. protected readonly _mapping: {
  54486. buttons: string[];
  54487. buttonMeshNames: {
  54488. trigger: string;
  54489. menu: string;
  54490. grip: string;
  54491. thumbstick: string;
  54492. trackpad: string;
  54493. };
  54494. buttonObservableNames: {
  54495. trigger: string;
  54496. menu: string;
  54497. grip: string;
  54498. thumbstick: string;
  54499. trackpad: string;
  54500. };
  54501. axisMeshNames: string[];
  54502. pointingPoseMeshName: string;
  54503. };
  54504. /**
  54505. * Construct a new XR-Based windows motion controller
  54506. *
  54507. * @param gamepadInfo the gamepad object from the browser
  54508. */
  54509. constructor(gamepadInfo: any);
  54510. /**
  54511. * holds the thumbstick values (X,Y)
  54512. */
  54513. thumbstickValues: StickValues;
  54514. /**
  54515. * Fired when the thumbstick on this controller is clicked
  54516. */
  54517. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  54518. /**
  54519. * Fired when the thumbstick on this controller is modified
  54520. */
  54521. onThumbstickValuesChangedObservable: Observable<StickValues>;
  54522. /**
  54523. * Fired when the touchpad button on this controller is modified
  54524. */
  54525. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54526. /**
  54527. * Fired when the touchpad values on this controller are modified
  54528. */
  54529. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54530. /**
  54531. * Fired when the thumbstick button on this controller is modified
  54532. * here to prevent breaking changes
  54533. */
  54534. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54535. /**
  54536. * updating the thumbstick(!) and not the trackpad.
  54537. * This is named this way due to the difference between WebVR and XR and to avoid
  54538. * changing the parent class.
  54539. */
  54540. protected _updateTrackpad(): void;
  54541. /**
  54542. * Disposes the class with joy
  54543. */
  54544. dispose(): void;
  54545. }
  54546. }
  54547. declare module "babylonjs/Gamepads/Controllers/index" {
  54548. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  54549. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  54550. export * from "babylonjs/Gamepads/Controllers/genericController";
  54551. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  54552. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54553. export * from "babylonjs/Gamepads/Controllers/viveController";
  54554. export * from "babylonjs/Gamepads/Controllers/webVRController";
  54555. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  54556. }
  54557. declare module "babylonjs/Gamepads/index" {
  54558. export * from "babylonjs/Gamepads/Controllers/index";
  54559. export * from "babylonjs/Gamepads/gamepad";
  54560. export * from "babylonjs/Gamepads/gamepadManager";
  54561. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  54562. export * from "babylonjs/Gamepads/xboxGamepad";
  54563. export * from "babylonjs/Gamepads/dualShockGamepad";
  54564. }
  54565. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  54566. import { Scene } from "babylonjs/scene";
  54567. import { Vector4 } from "babylonjs/Maths/math.vector";
  54568. import { Color4 } from "babylonjs/Maths/math.color";
  54569. import { Mesh } from "babylonjs/Meshes/mesh";
  54570. import { Nullable } from "babylonjs/types";
  54571. /**
  54572. * Class containing static functions to help procedurally build meshes
  54573. */
  54574. export class PolyhedronBuilder {
  54575. /**
  54576. * Creates a polyhedron mesh
  54577. * * 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
  54578. * * The parameter `size` (positive float, default 1) sets the polygon size
  54579. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54580. * * 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`
  54581. * * 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
  54582. * * 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)`)
  54583. * * 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
  54584. * * 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
  54585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54586. * * 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
  54587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54588. * @param name defines the name of the mesh
  54589. * @param options defines the options used to create the mesh
  54590. * @param scene defines the hosting scene
  54591. * @returns the polyhedron mesh
  54592. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54593. */
  54594. static CreatePolyhedron(name: string, options: {
  54595. type?: number;
  54596. size?: number;
  54597. sizeX?: number;
  54598. sizeY?: number;
  54599. sizeZ?: number;
  54600. custom?: any;
  54601. faceUV?: Vector4[];
  54602. faceColors?: Color4[];
  54603. flat?: boolean;
  54604. updatable?: boolean;
  54605. sideOrientation?: number;
  54606. frontUVs?: Vector4;
  54607. backUVs?: Vector4;
  54608. }, scene?: Nullable<Scene>): Mesh;
  54609. }
  54610. }
  54611. declare module "babylonjs/Gizmos/scaleGizmo" {
  54612. import { Observable } from "babylonjs/Misc/observable";
  54613. import { Nullable } from "babylonjs/types";
  54614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54615. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54616. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54617. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54618. /**
  54619. * Gizmo that enables scaling a mesh along 3 axis
  54620. */
  54621. export class ScaleGizmo extends Gizmo {
  54622. /**
  54623. * Internal gizmo used for interactions on the x axis
  54624. */
  54625. xGizmo: AxisScaleGizmo;
  54626. /**
  54627. * Internal gizmo used for interactions on the y axis
  54628. */
  54629. yGizmo: AxisScaleGizmo;
  54630. /**
  54631. * Internal gizmo used for interactions on the z axis
  54632. */
  54633. zGizmo: AxisScaleGizmo;
  54634. /**
  54635. * Internal gizmo used to scale all axis equally
  54636. */
  54637. uniformScaleGizmo: AxisScaleGizmo;
  54638. private _meshAttached;
  54639. private _updateGizmoRotationToMatchAttachedMesh;
  54640. private _snapDistance;
  54641. private _scaleRatio;
  54642. private _uniformScalingMesh;
  54643. private _octahedron;
  54644. private _sensitivity;
  54645. /** Fires an event when any of it's sub gizmos are dragged */
  54646. onDragStartObservable: Observable<unknown>;
  54647. /** Fires an event when any of it's sub gizmos are released from dragging */
  54648. onDragEndObservable: Observable<unknown>;
  54649. get attachedMesh(): Nullable<AbstractMesh>;
  54650. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54651. /**
  54652. * Creates a ScaleGizmo
  54653. * @param gizmoLayer The utility layer the gizmo will be added to
  54654. */
  54655. constructor(gizmoLayer?: UtilityLayerRenderer);
  54656. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54657. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54658. /**
  54659. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54660. */
  54661. set snapDistance(value: number);
  54662. get snapDistance(): number;
  54663. /**
  54664. * Ratio for the scale of the gizmo (Default: 1)
  54665. */
  54666. set scaleRatio(value: number);
  54667. get scaleRatio(): number;
  54668. /**
  54669. * Sensitivity factor for dragging (Default: 1)
  54670. */
  54671. set sensitivity(value: number);
  54672. get sensitivity(): number;
  54673. /**
  54674. * Disposes of the gizmo
  54675. */
  54676. dispose(): void;
  54677. }
  54678. }
  54679. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54680. import { Observable } from "babylonjs/Misc/observable";
  54681. import { Nullable } from "babylonjs/types";
  54682. import { Vector3 } from "babylonjs/Maths/math.vector";
  54683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54684. import { Mesh } from "babylonjs/Meshes/mesh";
  54685. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54686. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54687. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54688. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54689. import { Color3 } from "babylonjs/Maths/math.color";
  54690. /**
  54691. * Single axis scale gizmo
  54692. */
  54693. export class AxisScaleGizmo extends Gizmo {
  54694. /**
  54695. * Drag behavior responsible for the gizmos dragging interactions
  54696. */
  54697. dragBehavior: PointerDragBehavior;
  54698. private _pointerObserver;
  54699. /**
  54700. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54701. */
  54702. snapDistance: number;
  54703. /**
  54704. * Event that fires each time the gizmo snaps to a new location.
  54705. * * snapDistance is the the change in distance
  54706. */
  54707. onSnapObservable: Observable<{
  54708. snapDistance: number;
  54709. }>;
  54710. /**
  54711. * If the scaling operation should be done on all axis (default: false)
  54712. */
  54713. uniformScaling: boolean;
  54714. /**
  54715. * Custom sensitivity value for the drag strength
  54716. */
  54717. sensitivity: number;
  54718. private _isEnabled;
  54719. private _parent;
  54720. private _arrow;
  54721. private _coloredMaterial;
  54722. private _hoverMaterial;
  54723. /**
  54724. * Creates an AxisScaleGizmo
  54725. * @param gizmoLayer The utility layer the gizmo will be added to
  54726. * @param dragAxis The axis which the gizmo will be able to scale on
  54727. * @param color The color of the gizmo
  54728. */
  54729. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54730. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54731. /**
  54732. * If the gizmo is enabled
  54733. */
  54734. set isEnabled(value: boolean);
  54735. get isEnabled(): boolean;
  54736. /**
  54737. * Disposes of the gizmo
  54738. */
  54739. dispose(): void;
  54740. /**
  54741. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54742. * @param mesh The mesh to replace the default mesh of the gizmo
  54743. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54744. */
  54745. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54746. }
  54747. }
  54748. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54749. import { Observable } from "babylonjs/Misc/observable";
  54750. import { Nullable } from "babylonjs/types";
  54751. import { Vector3 } from "babylonjs/Maths/math.vector";
  54752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54753. import { Mesh } from "babylonjs/Meshes/mesh";
  54754. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54755. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54756. import { Color3 } from "babylonjs/Maths/math.color";
  54757. import "babylonjs/Meshes/Builders/boxBuilder";
  54758. /**
  54759. * Bounding box gizmo
  54760. */
  54761. export class BoundingBoxGizmo extends Gizmo {
  54762. private _lineBoundingBox;
  54763. private _rotateSpheresParent;
  54764. private _scaleBoxesParent;
  54765. private _boundingDimensions;
  54766. private _renderObserver;
  54767. private _pointerObserver;
  54768. private _scaleDragSpeed;
  54769. private _tmpQuaternion;
  54770. private _tmpVector;
  54771. private _tmpRotationMatrix;
  54772. /**
  54773. * 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)
  54774. */
  54775. ignoreChildren: boolean;
  54776. /**
  54777. * 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)
  54778. */
  54779. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54780. /**
  54781. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54782. */
  54783. rotationSphereSize: number;
  54784. /**
  54785. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54786. */
  54787. scaleBoxSize: number;
  54788. /**
  54789. * 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)
  54790. */
  54791. fixedDragMeshScreenSize: boolean;
  54792. /**
  54793. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54794. */
  54795. fixedDragMeshScreenSizeDistanceFactor: number;
  54796. /**
  54797. * Fired when a rotation sphere or scale box is dragged
  54798. */
  54799. onDragStartObservable: Observable<{}>;
  54800. /**
  54801. * Fired when a scale box is dragged
  54802. */
  54803. onScaleBoxDragObservable: Observable<{}>;
  54804. /**
  54805. * Fired when a scale box drag is ended
  54806. */
  54807. onScaleBoxDragEndObservable: Observable<{}>;
  54808. /**
  54809. * Fired when a rotation sphere is dragged
  54810. */
  54811. onRotationSphereDragObservable: Observable<{}>;
  54812. /**
  54813. * Fired when a rotation sphere drag is ended
  54814. */
  54815. onRotationSphereDragEndObservable: Observable<{}>;
  54816. /**
  54817. * 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)
  54818. */
  54819. scalePivot: Nullable<Vector3>;
  54820. /**
  54821. * Mesh used as a pivot to rotate the attached mesh
  54822. */
  54823. private _anchorMesh;
  54824. private _existingMeshScale;
  54825. private _dragMesh;
  54826. private pointerDragBehavior;
  54827. private coloredMaterial;
  54828. private hoverColoredMaterial;
  54829. /**
  54830. * Sets the color of the bounding box gizmo
  54831. * @param color the color to set
  54832. */
  54833. setColor(color: Color3): void;
  54834. /**
  54835. * Creates an BoundingBoxGizmo
  54836. * @param gizmoLayer The utility layer the gizmo will be added to
  54837. * @param color The color of the gizmo
  54838. */
  54839. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54840. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54841. private _selectNode;
  54842. /**
  54843. * Updates the bounding box information for the Gizmo
  54844. */
  54845. updateBoundingBox(): void;
  54846. private _updateRotationSpheres;
  54847. private _updateScaleBoxes;
  54848. /**
  54849. * Enables rotation on the specified axis and disables rotation on the others
  54850. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54851. */
  54852. setEnabledRotationAxis(axis: string): void;
  54853. /**
  54854. * Enables/disables scaling
  54855. * @param enable if scaling should be enabled
  54856. * @param homogeneousScaling defines if scaling should only be homogeneous
  54857. */
  54858. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54859. private _updateDummy;
  54860. /**
  54861. * Enables a pointer drag behavior on the bounding box of the gizmo
  54862. */
  54863. enableDragBehavior(): void;
  54864. /**
  54865. * Disposes of the gizmo
  54866. */
  54867. dispose(): void;
  54868. /**
  54869. * 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)
  54870. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54871. * @returns the bounding box mesh with the passed in mesh as a child
  54872. */
  54873. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54874. /**
  54875. * CustomMeshes are not supported by this gizmo
  54876. * @param mesh The mesh to replace the default mesh of the gizmo
  54877. */
  54878. setCustomMesh(mesh: Mesh): void;
  54879. }
  54880. }
  54881. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54882. import { Observable } from "babylonjs/Misc/observable";
  54883. import { Nullable } from "babylonjs/types";
  54884. import { Vector3 } from "babylonjs/Maths/math.vector";
  54885. import { Color3 } from "babylonjs/Maths/math.color";
  54886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54887. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54888. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54889. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54890. import "babylonjs/Meshes/Builders/linesBuilder";
  54891. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54892. /**
  54893. * Single plane rotation gizmo
  54894. */
  54895. export class PlaneRotationGizmo extends Gizmo {
  54896. /**
  54897. * Drag behavior responsible for the gizmos dragging interactions
  54898. */
  54899. dragBehavior: PointerDragBehavior;
  54900. private _pointerObserver;
  54901. /**
  54902. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54903. */
  54904. snapDistance: number;
  54905. /**
  54906. * Event that fires each time the gizmo snaps to a new location.
  54907. * * snapDistance is the the change in distance
  54908. */
  54909. onSnapObservable: Observable<{
  54910. snapDistance: number;
  54911. }>;
  54912. private _isEnabled;
  54913. private _parent;
  54914. /**
  54915. * Creates a PlaneRotationGizmo
  54916. * @param gizmoLayer The utility layer the gizmo will be added to
  54917. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54918. * @param color The color of the gizmo
  54919. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54920. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54921. */
  54922. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54923. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54924. /**
  54925. * If the gizmo is enabled
  54926. */
  54927. set isEnabled(value: boolean);
  54928. get isEnabled(): boolean;
  54929. /**
  54930. * Disposes of the gizmo
  54931. */
  54932. dispose(): void;
  54933. }
  54934. }
  54935. declare module "babylonjs/Gizmos/rotationGizmo" {
  54936. import { Observable } from "babylonjs/Misc/observable";
  54937. import { Nullable } from "babylonjs/types";
  54938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54939. import { Mesh } from "babylonjs/Meshes/mesh";
  54940. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54941. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54942. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54943. /**
  54944. * Gizmo that enables rotating a mesh along 3 axis
  54945. */
  54946. export class RotationGizmo extends Gizmo {
  54947. /**
  54948. * Internal gizmo used for interactions on the x axis
  54949. */
  54950. xGizmo: PlaneRotationGizmo;
  54951. /**
  54952. * Internal gizmo used for interactions on the y axis
  54953. */
  54954. yGizmo: PlaneRotationGizmo;
  54955. /**
  54956. * Internal gizmo used for interactions on the z axis
  54957. */
  54958. zGizmo: PlaneRotationGizmo;
  54959. /** Fires an event when any of it's sub gizmos are dragged */
  54960. onDragStartObservable: Observable<unknown>;
  54961. /** Fires an event when any of it's sub gizmos are released from dragging */
  54962. onDragEndObservable: Observable<unknown>;
  54963. private _meshAttached;
  54964. get attachedMesh(): Nullable<AbstractMesh>;
  54965. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54966. /**
  54967. * Creates a RotationGizmo
  54968. * @param gizmoLayer The utility layer the gizmo will be added to
  54969. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54970. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54971. */
  54972. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54973. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54974. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54975. /**
  54976. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54977. */
  54978. set snapDistance(value: number);
  54979. get snapDistance(): number;
  54980. /**
  54981. * Ratio for the scale of the gizmo (Default: 1)
  54982. */
  54983. set scaleRatio(value: number);
  54984. get scaleRatio(): number;
  54985. /**
  54986. * Disposes of the gizmo
  54987. */
  54988. dispose(): void;
  54989. /**
  54990. * CustomMeshes are not supported by this gizmo
  54991. * @param mesh The mesh to replace the default mesh of the gizmo
  54992. */
  54993. setCustomMesh(mesh: Mesh): void;
  54994. }
  54995. }
  54996. declare module "babylonjs/Gizmos/gizmoManager" {
  54997. import { Observable } from "babylonjs/Misc/observable";
  54998. import { Nullable } from "babylonjs/types";
  54999. import { Scene, IDisposable } from "babylonjs/scene";
  55000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55001. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55002. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  55003. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55004. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55005. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55006. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55007. /**
  55008. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  55009. */
  55010. export class GizmoManager implements IDisposable {
  55011. private scene;
  55012. /**
  55013. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55014. */
  55015. gizmos: {
  55016. positionGizmo: Nullable<PositionGizmo>;
  55017. rotationGizmo: Nullable<RotationGizmo>;
  55018. scaleGizmo: Nullable<ScaleGizmo>;
  55019. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55020. };
  55021. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55022. clearGizmoOnEmptyPointerEvent: boolean;
  55023. /** Fires an event when the manager is attached to a mesh */
  55024. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55025. private _gizmosEnabled;
  55026. private _pointerObserver;
  55027. private _attachedMesh;
  55028. private _boundingBoxColor;
  55029. private _defaultUtilityLayer;
  55030. private _defaultKeepDepthUtilityLayer;
  55031. /**
  55032. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55033. */
  55034. boundingBoxDragBehavior: SixDofDragBehavior;
  55035. /**
  55036. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55037. */
  55038. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55039. /**
  55040. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  55041. */
  55042. usePointerToAttachGizmos: boolean;
  55043. /**
  55044. * Utility layer that the bounding box gizmo belongs to
  55045. */
  55046. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55047. /**
  55048. * Utility layer that all gizmos besides bounding box belong to
  55049. */
  55050. get utilityLayer(): UtilityLayerRenderer;
  55051. /**
  55052. * Instatiates a gizmo manager
  55053. * @param scene the scene to overlay the gizmos on top of
  55054. */
  55055. constructor(scene: Scene);
  55056. /**
  55057. * Attaches a set of gizmos to the specified mesh
  55058. * @param mesh The mesh the gizmo's should be attached to
  55059. */
  55060. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55061. /**
  55062. * If the position gizmo is enabled
  55063. */
  55064. set positionGizmoEnabled(value: boolean);
  55065. get positionGizmoEnabled(): boolean;
  55066. /**
  55067. * If the rotation gizmo is enabled
  55068. */
  55069. set rotationGizmoEnabled(value: boolean);
  55070. get rotationGizmoEnabled(): boolean;
  55071. /**
  55072. * If the scale gizmo is enabled
  55073. */
  55074. set scaleGizmoEnabled(value: boolean);
  55075. get scaleGizmoEnabled(): boolean;
  55076. /**
  55077. * If the boundingBox gizmo is enabled
  55078. */
  55079. set boundingBoxGizmoEnabled(value: boolean);
  55080. get boundingBoxGizmoEnabled(): boolean;
  55081. /**
  55082. * Disposes of the gizmo manager
  55083. */
  55084. dispose(): void;
  55085. }
  55086. }
  55087. declare module "babylonjs/Lights/directionalLight" {
  55088. import { Camera } from "babylonjs/Cameras/camera";
  55089. import { Scene } from "babylonjs/scene";
  55090. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55092. import { Light } from "babylonjs/Lights/light";
  55093. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55094. import { Effect } from "babylonjs/Materials/effect";
  55095. /**
  55096. * A directional light is defined by a direction (what a surprise!).
  55097. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55098. * 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.
  55099. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55100. */
  55101. export class DirectionalLight extends ShadowLight {
  55102. private _shadowFrustumSize;
  55103. /**
  55104. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  55105. */
  55106. get shadowFrustumSize(): number;
  55107. /**
  55108. * Specifies a fix frustum size for the shadow generation.
  55109. */
  55110. set shadowFrustumSize(value: number);
  55111. private _shadowOrthoScale;
  55112. /**
  55113. * Gets the shadow projection scale against the optimal computed one.
  55114. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55115. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55116. */
  55117. get shadowOrthoScale(): number;
  55118. /**
  55119. * Sets the shadow projection scale against the optimal computed one.
  55120. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55121. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55122. */
  55123. set shadowOrthoScale(value: number);
  55124. /**
  55125. * Automatically compute the projection matrix to best fit (including all the casters)
  55126. * on each frame.
  55127. */
  55128. autoUpdateExtends: boolean;
  55129. /**
  55130. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  55131. * on each frame. autoUpdateExtends must be set to true for this to work
  55132. */
  55133. autoCalcShadowZBounds: boolean;
  55134. private _orthoLeft;
  55135. private _orthoRight;
  55136. private _orthoTop;
  55137. private _orthoBottom;
  55138. /**
  55139. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  55140. * The directional light is emitted from everywhere in the given direction.
  55141. * It can cast shadows.
  55142. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55143. * @param name The friendly name of the light
  55144. * @param direction The direction of the light
  55145. * @param scene The scene the light belongs to
  55146. */
  55147. constructor(name: string, direction: Vector3, scene: Scene);
  55148. /**
  55149. * Returns the string "DirectionalLight".
  55150. * @return The class name
  55151. */
  55152. getClassName(): string;
  55153. /**
  55154. * Returns the integer 1.
  55155. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55156. */
  55157. getTypeID(): number;
  55158. /**
  55159. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  55160. * Returns the DirectionalLight Shadow projection matrix.
  55161. */
  55162. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55163. /**
  55164. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  55165. * Returns the DirectionalLight Shadow projection matrix.
  55166. */
  55167. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55168. /**
  55169. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55170. * Returns the DirectionalLight Shadow projection matrix.
  55171. */
  55172. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55173. protected _buildUniformLayout(): void;
  55174. /**
  55175. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55176. * @param effect The effect to update
  55177. * @param lightIndex The index of the light in the effect to update
  55178. * @returns The directional light
  55179. */
  55180. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55181. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55182. /**
  55183. * Gets the minZ used for shadow according to both the scene and the light.
  55184. *
  55185. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55186. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55187. * @param activeCamera The camera we are returning the min for
  55188. * @returns the depth min z
  55189. */
  55190. getDepthMinZ(activeCamera: Camera): number;
  55191. /**
  55192. * Gets the maxZ used for shadow according to both the scene and the light.
  55193. *
  55194. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55195. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55196. * @param activeCamera The camera we are returning the max for
  55197. * @returns the depth max z
  55198. */
  55199. getDepthMaxZ(activeCamera: Camera): number;
  55200. /**
  55201. * Prepares the list of defines specific to the light type.
  55202. * @param defines the list of defines
  55203. * @param lightIndex defines the index of the light for the effect
  55204. */
  55205. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55206. }
  55207. }
  55208. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55209. import { Mesh } from "babylonjs/Meshes/mesh";
  55210. /**
  55211. * Class containing static functions to help procedurally build meshes
  55212. */
  55213. export class HemisphereBuilder {
  55214. /**
  55215. * Creates a hemisphere mesh
  55216. * @param name defines the name of the mesh
  55217. * @param options defines the options used to create the mesh
  55218. * @param scene defines the hosting scene
  55219. * @returns the hemisphere mesh
  55220. */
  55221. static CreateHemisphere(name: string, options: {
  55222. segments?: number;
  55223. diameter?: number;
  55224. sideOrientation?: number;
  55225. }, scene: any): Mesh;
  55226. }
  55227. }
  55228. declare module "babylonjs/Lights/spotLight" {
  55229. import { Nullable } from "babylonjs/types";
  55230. import { Scene } from "babylonjs/scene";
  55231. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55233. import { Effect } from "babylonjs/Materials/effect";
  55234. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55235. import { Light } from "babylonjs/Lights/light";
  55236. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55237. /**
  55238. * A spot light is defined by a position, a direction, an angle, and an exponent.
  55239. * These values define a cone of light starting from the position, emitting toward the direction.
  55240. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  55241. * and the exponent defines the speed of the decay of the light with distance (reach).
  55242. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55243. */
  55244. export class SpotLight extends ShadowLight {
  55245. private _angle;
  55246. private _innerAngle;
  55247. private _cosHalfAngle;
  55248. private _lightAngleScale;
  55249. private _lightAngleOffset;
  55250. /**
  55251. * Gets the cone angle of the spot light in Radians.
  55252. */
  55253. get angle(): number;
  55254. /**
  55255. * Sets the cone angle of the spot light in Radians.
  55256. */
  55257. set angle(value: number);
  55258. /**
  55259. * Only used in gltf falloff mode, this defines the angle where
  55260. * the directional falloff will start before cutting at angle which could be seen
  55261. * as outer angle.
  55262. */
  55263. get innerAngle(): number;
  55264. /**
  55265. * Only used in gltf falloff mode, this defines the angle where
  55266. * the directional falloff will start before cutting at angle which could be seen
  55267. * as outer angle.
  55268. */
  55269. set innerAngle(value: number);
  55270. private _shadowAngleScale;
  55271. /**
  55272. * Allows scaling the angle of the light for shadow generation only.
  55273. */
  55274. get shadowAngleScale(): number;
  55275. /**
  55276. * Allows scaling the angle of the light for shadow generation only.
  55277. */
  55278. set shadowAngleScale(value: number);
  55279. /**
  55280. * The light decay speed with the distance from the emission spot.
  55281. */
  55282. exponent: number;
  55283. private _projectionTextureMatrix;
  55284. /**
  55285. * Allows reading the projecton texture
  55286. */
  55287. get projectionTextureMatrix(): Matrix;
  55288. protected _projectionTextureLightNear: number;
  55289. /**
  55290. * Gets the near clip of the Spotlight for texture projection.
  55291. */
  55292. get projectionTextureLightNear(): number;
  55293. /**
  55294. * Sets the near clip of the Spotlight for texture projection.
  55295. */
  55296. set projectionTextureLightNear(value: number);
  55297. protected _projectionTextureLightFar: number;
  55298. /**
  55299. * Gets the far clip of the Spotlight for texture projection.
  55300. */
  55301. get projectionTextureLightFar(): number;
  55302. /**
  55303. * Sets the far clip of the Spotlight for texture projection.
  55304. */
  55305. set projectionTextureLightFar(value: number);
  55306. protected _projectionTextureUpDirection: Vector3;
  55307. /**
  55308. * Gets the Up vector of the Spotlight for texture projection.
  55309. */
  55310. get projectionTextureUpDirection(): Vector3;
  55311. /**
  55312. * Sets the Up vector of the Spotlight for texture projection.
  55313. */
  55314. set projectionTextureUpDirection(value: Vector3);
  55315. private _projectionTexture;
  55316. /**
  55317. * Gets the projection texture of the light.
  55318. */
  55319. get projectionTexture(): Nullable<BaseTexture>;
  55320. /**
  55321. * Sets the projection texture of the light.
  55322. */
  55323. set projectionTexture(value: Nullable<BaseTexture>);
  55324. private _projectionTextureViewLightDirty;
  55325. private _projectionTextureProjectionLightDirty;
  55326. private _projectionTextureDirty;
  55327. private _projectionTextureViewTargetVector;
  55328. private _projectionTextureViewLightMatrix;
  55329. private _projectionTextureProjectionLightMatrix;
  55330. private _projectionTextureScalingMatrix;
  55331. /**
  55332. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  55333. * It can cast shadows.
  55334. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55335. * @param name The light friendly name
  55336. * @param position The position of the spot light in the scene
  55337. * @param direction The direction of the light in the scene
  55338. * @param angle The cone angle of the light in Radians
  55339. * @param exponent The light decay speed with the distance from the emission spot
  55340. * @param scene The scene the lights belongs to
  55341. */
  55342. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55343. /**
  55344. * Returns the string "SpotLight".
  55345. * @returns the class name
  55346. */
  55347. getClassName(): string;
  55348. /**
  55349. * Returns the integer 2.
  55350. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55351. */
  55352. getTypeID(): number;
  55353. /**
  55354. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55355. */
  55356. protected _setDirection(value: Vector3): void;
  55357. /**
  55358. * Overrides the position setter to recompute the projection texture view light Matrix.
  55359. */
  55360. protected _setPosition(value: Vector3): void;
  55361. /**
  55362. * 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.
  55363. * Returns the SpotLight.
  55364. */
  55365. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55366. protected _computeProjectionTextureViewLightMatrix(): void;
  55367. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55368. /**
  55369. * Main function for light texture projection matrix computing.
  55370. */
  55371. protected _computeProjectionTextureMatrix(): void;
  55372. protected _buildUniformLayout(): void;
  55373. private _computeAngleValues;
  55374. /**
  55375. * Sets the passed Effect "effect" with the Light textures.
  55376. * @param effect The effect to update
  55377. * @param lightIndex The index of the light in the effect to update
  55378. * @returns The light
  55379. */
  55380. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55381. /**
  55382. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55383. * @param effect The effect to update
  55384. * @param lightIndex The index of the light in the effect to update
  55385. * @returns The spot light
  55386. */
  55387. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55388. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55389. /**
  55390. * Disposes the light and the associated resources.
  55391. */
  55392. dispose(): void;
  55393. /**
  55394. * Prepares the list of defines specific to the light type.
  55395. * @param defines the list of defines
  55396. * @param lightIndex defines the index of the light for the effect
  55397. */
  55398. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55399. }
  55400. }
  55401. declare module "babylonjs/Gizmos/lightGizmo" {
  55402. import { Nullable } from "babylonjs/types";
  55403. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55404. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55405. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55406. import { Light } from "babylonjs/Lights/light";
  55407. /**
  55408. * Gizmo that enables viewing a light
  55409. */
  55410. export class LightGizmo extends Gizmo {
  55411. private _lightMesh;
  55412. private _material;
  55413. private _cachedPosition;
  55414. private _cachedForward;
  55415. private _attachedMeshParent;
  55416. /**
  55417. * Creates a LightGizmo
  55418. * @param gizmoLayer The utility layer the gizmo will be added to
  55419. */
  55420. constructor(gizmoLayer?: UtilityLayerRenderer);
  55421. private _light;
  55422. /**
  55423. * The light that the gizmo is attached to
  55424. */
  55425. set light(light: Nullable<Light>);
  55426. get light(): Nullable<Light>;
  55427. /**
  55428. * Gets the material used to render the light gizmo
  55429. */
  55430. get material(): StandardMaterial;
  55431. /**
  55432. * @hidden
  55433. * Updates the gizmo to match the attached mesh's position/rotation
  55434. */
  55435. protected _update(): void;
  55436. private static _Scale;
  55437. /**
  55438. * Creates the lines for a light mesh
  55439. */
  55440. private static _CreateLightLines;
  55441. /**
  55442. * Disposes of the light gizmo
  55443. */
  55444. dispose(): void;
  55445. private static _CreateHemisphericLightMesh;
  55446. private static _CreatePointLightMesh;
  55447. private static _CreateSpotLightMesh;
  55448. private static _CreateDirectionalLightMesh;
  55449. }
  55450. }
  55451. declare module "babylonjs/Gizmos/index" {
  55452. export * from "babylonjs/Gizmos/axisDragGizmo";
  55453. export * from "babylonjs/Gizmos/axisScaleGizmo";
  55454. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  55455. export * from "babylonjs/Gizmos/gizmo";
  55456. export * from "babylonjs/Gizmos/gizmoManager";
  55457. export * from "babylonjs/Gizmos/planeRotationGizmo";
  55458. export * from "babylonjs/Gizmos/positionGizmo";
  55459. export * from "babylonjs/Gizmos/rotationGizmo";
  55460. export * from "babylonjs/Gizmos/scaleGizmo";
  55461. export * from "babylonjs/Gizmos/lightGizmo";
  55462. export * from "babylonjs/Gizmos/planeDragGizmo";
  55463. }
  55464. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  55465. /** @hidden */
  55466. export var backgroundFragmentDeclaration: {
  55467. name: string;
  55468. shader: string;
  55469. };
  55470. }
  55471. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  55472. /** @hidden */
  55473. export var backgroundUboDeclaration: {
  55474. name: string;
  55475. shader: string;
  55476. };
  55477. }
  55478. declare module "babylonjs/Shaders/background.fragment" {
  55479. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  55480. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55481. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55482. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55483. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55484. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55485. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55486. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  55487. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  55488. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55489. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  55490. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  55491. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55492. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  55493. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  55494. /** @hidden */
  55495. export var backgroundPixelShader: {
  55496. name: string;
  55497. shader: string;
  55498. };
  55499. }
  55500. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  55501. /** @hidden */
  55502. export var backgroundVertexDeclaration: {
  55503. name: string;
  55504. shader: string;
  55505. };
  55506. }
  55507. declare module "babylonjs/Shaders/background.vertex" {
  55508. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  55509. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55510. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55511. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55512. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55513. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  55514. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  55515. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55516. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55517. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55518. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55519. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55520. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  55521. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  55522. /** @hidden */
  55523. export var backgroundVertexShader: {
  55524. name: string;
  55525. shader: string;
  55526. };
  55527. }
  55528. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  55529. import { Nullable, int, float } from "babylonjs/types";
  55530. import { Scene } from "babylonjs/scene";
  55531. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55532. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55534. import { Mesh } from "babylonjs/Meshes/mesh";
  55535. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55536. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  55537. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  55538. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55539. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  55540. import { Color3 } from "babylonjs/Maths/math.color";
  55541. import "babylonjs/Shaders/background.fragment";
  55542. import "babylonjs/Shaders/background.vertex";
  55543. /**
  55544. * Background material used to create an efficient environement around your scene.
  55545. */
  55546. export class BackgroundMaterial extends PushMaterial {
  55547. /**
  55548. * Standard reflectance value at parallel view angle.
  55549. */
  55550. static StandardReflectance0: number;
  55551. /**
  55552. * Standard reflectance value at grazing angle.
  55553. */
  55554. static StandardReflectance90: number;
  55555. protected _primaryColor: Color3;
  55556. /**
  55557. * Key light Color (multiply against the environement texture)
  55558. */
  55559. primaryColor: Color3;
  55560. protected __perceptualColor: Nullable<Color3>;
  55561. /**
  55562. * Experimental Internal Use Only.
  55563. *
  55564. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  55565. * This acts as a helper to set the primary color to a more "human friendly" value.
  55566. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  55567. * output color as close as possible from the chosen value.
  55568. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55569. * part of lighting setup.)
  55570. */
  55571. get _perceptualColor(): Nullable<Color3>;
  55572. set _perceptualColor(value: Nullable<Color3>);
  55573. protected _primaryColorShadowLevel: float;
  55574. /**
  55575. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55576. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55577. */
  55578. get primaryColorShadowLevel(): float;
  55579. set primaryColorShadowLevel(value: float);
  55580. protected _primaryColorHighlightLevel: float;
  55581. /**
  55582. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55583. * The primary color is used at the level chosen to define what the white area would look.
  55584. */
  55585. get primaryColorHighlightLevel(): float;
  55586. set primaryColorHighlightLevel(value: float);
  55587. protected _reflectionTexture: Nullable<BaseTexture>;
  55588. /**
  55589. * Reflection Texture used in the material.
  55590. * Should be author in a specific way for the best result (refer to the documentation).
  55591. */
  55592. reflectionTexture: Nullable<BaseTexture>;
  55593. protected _reflectionBlur: float;
  55594. /**
  55595. * Reflection Texture level of blur.
  55596. *
  55597. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55598. * texture twice.
  55599. */
  55600. reflectionBlur: float;
  55601. protected _diffuseTexture: Nullable<BaseTexture>;
  55602. /**
  55603. * Diffuse Texture used in the material.
  55604. * Should be author in a specific way for the best result (refer to the documentation).
  55605. */
  55606. diffuseTexture: Nullable<BaseTexture>;
  55607. protected _shadowLights: Nullable<IShadowLight[]>;
  55608. /**
  55609. * Specify the list of lights casting shadow on the material.
  55610. * All scene shadow lights will be included if null.
  55611. */
  55612. shadowLights: Nullable<IShadowLight[]>;
  55613. protected _shadowLevel: float;
  55614. /**
  55615. * Helps adjusting the shadow to a softer level if required.
  55616. * 0 means black shadows and 1 means no shadows.
  55617. */
  55618. shadowLevel: float;
  55619. protected _sceneCenter: Vector3;
  55620. /**
  55621. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55622. * It is usually zero but might be interesting to modify according to your setup.
  55623. */
  55624. sceneCenter: Vector3;
  55625. protected _opacityFresnel: boolean;
  55626. /**
  55627. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55628. * This helps ensuring a nice transition when the camera goes under the ground.
  55629. */
  55630. opacityFresnel: boolean;
  55631. protected _reflectionFresnel: boolean;
  55632. /**
  55633. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55634. * This helps adding a mirror texture on the ground.
  55635. */
  55636. reflectionFresnel: boolean;
  55637. protected _reflectionFalloffDistance: number;
  55638. /**
  55639. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55640. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55641. */
  55642. reflectionFalloffDistance: number;
  55643. protected _reflectionAmount: number;
  55644. /**
  55645. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55646. */
  55647. reflectionAmount: number;
  55648. protected _reflectionReflectance0: number;
  55649. /**
  55650. * This specifies the weight of the reflection at grazing angle.
  55651. */
  55652. reflectionReflectance0: number;
  55653. protected _reflectionReflectance90: number;
  55654. /**
  55655. * This specifies the weight of the reflection at a perpendicular point of view.
  55656. */
  55657. reflectionReflectance90: number;
  55658. /**
  55659. * Sets the reflection reflectance fresnel values according to the default standard
  55660. * empirically know to work well :-)
  55661. */
  55662. set reflectionStandardFresnelWeight(value: number);
  55663. protected _useRGBColor: boolean;
  55664. /**
  55665. * Helps to directly use the maps channels instead of their level.
  55666. */
  55667. useRGBColor: boolean;
  55668. protected _enableNoise: boolean;
  55669. /**
  55670. * This helps reducing the banding effect that could occur on the background.
  55671. */
  55672. enableNoise: boolean;
  55673. /**
  55674. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55675. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55676. * Recommended to be keep at 1.0 except for special cases.
  55677. */
  55678. get fovMultiplier(): number;
  55679. set fovMultiplier(value: number);
  55680. private _fovMultiplier;
  55681. /**
  55682. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55683. */
  55684. useEquirectangularFOV: boolean;
  55685. private _maxSimultaneousLights;
  55686. /**
  55687. * Number of Simultaneous lights allowed on the material.
  55688. */
  55689. maxSimultaneousLights: int;
  55690. private _shadowOnly;
  55691. /**
  55692. * Make the material only render shadows
  55693. */
  55694. shadowOnly: boolean;
  55695. /**
  55696. * Default configuration related to image processing available in the Background Material.
  55697. */
  55698. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55699. /**
  55700. * Keep track of the image processing observer to allow dispose and replace.
  55701. */
  55702. private _imageProcessingObserver;
  55703. /**
  55704. * Attaches a new image processing configuration to the PBR Material.
  55705. * @param configuration (if null the scene configuration will be use)
  55706. */
  55707. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55708. /**
  55709. * Gets the image processing configuration used either in this material.
  55710. */
  55711. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55712. /**
  55713. * Sets the Default image processing configuration used either in the this material.
  55714. *
  55715. * If sets to null, the scene one is in use.
  55716. */
  55717. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55718. /**
  55719. * Gets wether the color curves effect is enabled.
  55720. */
  55721. get cameraColorCurvesEnabled(): boolean;
  55722. /**
  55723. * Sets wether the color curves effect is enabled.
  55724. */
  55725. set cameraColorCurvesEnabled(value: boolean);
  55726. /**
  55727. * Gets wether the color grading effect is enabled.
  55728. */
  55729. get cameraColorGradingEnabled(): boolean;
  55730. /**
  55731. * Gets wether the color grading effect is enabled.
  55732. */
  55733. set cameraColorGradingEnabled(value: boolean);
  55734. /**
  55735. * Gets wether tonemapping is enabled or not.
  55736. */
  55737. get cameraToneMappingEnabled(): boolean;
  55738. /**
  55739. * Sets wether tonemapping is enabled or not
  55740. */
  55741. set cameraToneMappingEnabled(value: boolean);
  55742. /**
  55743. * The camera exposure used on this material.
  55744. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55745. * This corresponds to a photographic exposure.
  55746. */
  55747. get cameraExposure(): float;
  55748. /**
  55749. * The camera exposure used on this material.
  55750. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55751. * This corresponds to a photographic exposure.
  55752. */
  55753. set cameraExposure(value: float);
  55754. /**
  55755. * Gets The camera contrast used on this material.
  55756. */
  55757. get cameraContrast(): float;
  55758. /**
  55759. * Sets The camera contrast used on this material.
  55760. */
  55761. set cameraContrast(value: float);
  55762. /**
  55763. * Gets the Color Grading 2D Lookup Texture.
  55764. */
  55765. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55766. /**
  55767. * Sets the Color Grading 2D Lookup Texture.
  55768. */
  55769. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55770. /**
  55771. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55772. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55773. * 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;
  55774. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55775. */
  55776. get cameraColorCurves(): Nullable<ColorCurves>;
  55777. /**
  55778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55780. * 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;
  55781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55782. */
  55783. set cameraColorCurves(value: Nullable<ColorCurves>);
  55784. /**
  55785. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55786. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55787. */
  55788. switchToBGR: boolean;
  55789. private _renderTargets;
  55790. private _reflectionControls;
  55791. private _white;
  55792. private _primaryShadowColor;
  55793. private _primaryHighlightColor;
  55794. /**
  55795. * Instantiates a Background Material in the given scene
  55796. * @param name The friendly name of the material
  55797. * @param scene The scene to add the material to
  55798. */
  55799. constructor(name: string, scene: Scene);
  55800. /**
  55801. * Gets a boolean indicating that current material needs to register RTT
  55802. */
  55803. get hasRenderTargetTextures(): boolean;
  55804. /**
  55805. * The entire material has been created in order to prevent overdraw.
  55806. * @returns false
  55807. */
  55808. needAlphaTesting(): boolean;
  55809. /**
  55810. * The entire material has been created in order to prevent overdraw.
  55811. * @returns true if blending is enable
  55812. */
  55813. needAlphaBlending(): boolean;
  55814. /**
  55815. * Checks wether the material is ready to be rendered for a given mesh.
  55816. * @param mesh The mesh to render
  55817. * @param subMesh The submesh to check against
  55818. * @param useInstances Specify wether or not the material is used with instances
  55819. * @returns true if all the dependencies are ready (Textures, Effects...)
  55820. */
  55821. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55822. /**
  55823. * Compute the primary color according to the chosen perceptual color.
  55824. */
  55825. private _computePrimaryColorFromPerceptualColor;
  55826. /**
  55827. * Compute the highlights and shadow colors according to their chosen levels.
  55828. */
  55829. private _computePrimaryColors;
  55830. /**
  55831. * Build the uniform buffer used in the material.
  55832. */
  55833. buildUniformLayout(): void;
  55834. /**
  55835. * Unbind the material.
  55836. */
  55837. unbind(): void;
  55838. /**
  55839. * Bind only the world matrix to the material.
  55840. * @param world The world matrix to bind.
  55841. */
  55842. bindOnlyWorldMatrix(world: Matrix): void;
  55843. /**
  55844. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55845. * @param world The world matrix to bind.
  55846. * @param subMesh The submesh to bind for.
  55847. */
  55848. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55849. /**
  55850. * Checks to see if a texture is used in the material.
  55851. * @param texture - Base texture to use.
  55852. * @returns - Boolean specifying if a texture is used in the material.
  55853. */
  55854. hasTexture(texture: BaseTexture): boolean;
  55855. /**
  55856. * Dispose the material.
  55857. * @param forceDisposeEffect Force disposal of the associated effect.
  55858. * @param forceDisposeTextures Force disposal of the associated textures.
  55859. */
  55860. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55861. /**
  55862. * Clones the material.
  55863. * @param name The cloned name.
  55864. * @returns The cloned material.
  55865. */
  55866. clone(name: string): BackgroundMaterial;
  55867. /**
  55868. * Serializes the current material to its JSON representation.
  55869. * @returns The JSON representation.
  55870. */
  55871. serialize(): any;
  55872. /**
  55873. * Gets the class name of the material
  55874. * @returns "BackgroundMaterial"
  55875. */
  55876. getClassName(): string;
  55877. /**
  55878. * Parse a JSON input to create back a background material.
  55879. * @param source The JSON data to parse
  55880. * @param scene The scene to create the parsed material in
  55881. * @param rootUrl The root url of the assets the material depends upon
  55882. * @returns the instantiated BackgroundMaterial.
  55883. */
  55884. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55885. }
  55886. }
  55887. declare module "babylonjs/Helpers/environmentHelper" {
  55888. import { Observable } from "babylonjs/Misc/observable";
  55889. import { Nullable } from "babylonjs/types";
  55890. import { Scene } from "babylonjs/scene";
  55891. import { Vector3 } from "babylonjs/Maths/math.vector";
  55892. import { Color3 } from "babylonjs/Maths/math.color";
  55893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55894. import { Mesh } from "babylonjs/Meshes/mesh";
  55895. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55896. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55897. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55898. import "babylonjs/Meshes/Builders/planeBuilder";
  55899. import "babylonjs/Meshes/Builders/boxBuilder";
  55900. /**
  55901. * Represents the different options available during the creation of
  55902. * a Environment helper.
  55903. *
  55904. * This can control the default ground, skybox and image processing setup of your scene.
  55905. */
  55906. export interface IEnvironmentHelperOptions {
  55907. /**
  55908. * Specifies whether or not to create a ground.
  55909. * True by default.
  55910. */
  55911. createGround: boolean;
  55912. /**
  55913. * Specifies the ground size.
  55914. * 15 by default.
  55915. */
  55916. groundSize: number;
  55917. /**
  55918. * The texture used on the ground for the main color.
  55919. * Comes from the BabylonJS CDN by default.
  55920. *
  55921. * Remarks: Can be either a texture or a url.
  55922. */
  55923. groundTexture: string | BaseTexture;
  55924. /**
  55925. * The color mixed in the ground texture by default.
  55926. * BabylonJS clearColor by default.
  55927. */
  55928. groundColor: Color3;
  55929. /**
  55930. * Specifies the ground opacity.
  55931. * 1 by default.
  55932. */
  55933. groundOpacity: number;
  55934. /**
  55935. * Enables the ground to receive shadows.
  55936. * True by default.
  55937. */
  55938. enableGroundShadow: boolean;
  55939. /**
  55940. * Helps preventing the shadow to be fully black on the ground.
  55941. * 0.5 by default.
  55942. */
  55943. groundShadowLevel: number;
  55944. /**
  55945. * Creates a mirror texture attach to the ground.
  55946. * false by default.
  55947. */
  55948. enableGroundMirror: boolean;
  55949. /**
  55950. * Specifies the ground mirror size ratio.
  55951. * 0.3 by default as the default kernel is 64.
  55952. */
  55953. groundMirrorSizeRatio: number;
  55954. /**
  55955. * Specifies the ground mirror blur kernel size.
  55956. * 64 by default.
  55957. */
  55958. groundMirrorBlurKernel: number;
  55959. /**
  55960. * Specifies the ground mirror visibility amount.
  55961. * 1 by default
  55962. */
  55963. groundMirrorAmount: number;
  55964. /**
  55965. * Specifies the ground mirror reflectance weight.
  55966. * This uses the standard weight of the background material to setup the fresnel effect
  55967. * of the mirror.
  55968. * 1 by default.
  55969. */
  55970. groundMirrorFresnelWeight: number;
  55971. /**
  55972. * Specifies the ground mirror Falloff distance.
  55973. * This can helps reducing the size of the reflection.
  55974. * 0 by Default.
  55975. */
  55976. groundMirrorFallOffDistance: number;
  55977. /**
  55978. * Specifies the ground mirror texture type.
  55979. * Unsigned Int by Default.
  55980. */
  55981. groundMirrorTextureType: number;
  55982. /**
  55983. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55984. * the shown objects.
  55985. */
  55986. groundYBias: number;
  55987. /**
  55988. * Specifies whether or not to create a skybox.
  55989. * True by default.
  55990. */
  55991. createSkybox: boolean;
  55992. /**
  55993. * Specifies the skybox size.
  55994. * 20 by default.
  55995. */
  55996. skyboxSize: number;
  55997. /**
  55998. * The texture used on the skybox for the main color.
  55999. * Comes from the BabylonJS CDN by default.
  56000. *
  56001. * Remarks: Can be either a texture or a url.
  56002. */
  56003. skyboxTexture: string | BaseTexture;
  56004. /**
  56005. * The color mixed in the skybox texture by default.
  56006. * BabylonJS clearColor by default.
  56007. */
  56008. skyboxColor: Color3;
  56009. /**
  56010. * The background rotation around the Y axis of the scene.
  56011. * This helps aligning the key lights of your scene with the background.
  56012. * 0 by default.
  56013. */
  56014. backgroundYRotation: number;
  56015. /**
  56016. * Compute automatically the size of the elements to best fit with the scene.
  56017. */
  56018. sizeAuto: boolean;
  56019. /**
  56020. * Default position of the rootMesh if autoSize is not true.
  56021. */
  56022. rootPosition: Vector3;
  56023. /**
  56024. * Sets up the image processing in the scene.
  56025. * true by default.
  56026. */
  56027. setupImageProcessing: boolean;
  56028. /**
  56029. * The texture used as your environment texture in the scene.
  56030. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56031. *
  56032. * Remarks: Can be either a texture or a url.
  56033. */
  56034. environmentTexture: string | BaseTexture;
  56035. /**
  56036. * The value of the exposure to apply to the scene.
  56037. * 0.6 by default if setupImageProcessing is true.
  56038. */
  56039. cameraExposure: number;
  56040. /**
  56041. * The value of the contrast to apply to the scene.
  56042. * 1.6 by default if setupImageProcessing is true.
  56043. */
  56044. cameraContrast: number;
  56045. /**
  56046. * Specifies whether or not tonemapping should be enabled in the scene.
  56047. * true by default if setupImageProcessing is true.
  56048. */
  56049. toneMappingEnabled: boolean;
  56050. }
  56051. /**
  56052. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  56053. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  56054. * It also helps with the default setup of your imageProcessing configuration.
  56055. */
  56056. export class EnvironmentHelper {
  56057. /**
  56058. * Default ground texture URL.
  56059. */
  56060. private static _groundTextureCDNUrl;
  56061. /**
  56062. * Default skybox texture URL.
  56063. */
  56064. private static _skyboxTextureCDNUrl;
  56065. /**
  56066. * Default environment texture URL.
  56067. */
  56068. private static _environmentTextureCDNUrl;
  56069. /**
  56070. * Creates the default options for the helper.
  56071. */
  56072. private static _getDefaultOptions;
  56073. private _rootMesh;
  56074. /**
  56075. * Gets the root mesh created by the helper.
  56076. */
  56077. get rootMesh(): Mesh;
  56078. private _skybox;
  56079. /**
  56080. * Gets the skybox created by the helper.
  56081. */
  56082. get skybox(): Nullable<Mesh>;
  56083. private _skyboxTexture;
  56084. /**
  56085. * Gets the skybox texture created by the helper.
  56086. */
  56087. get skyboxTexture(): Nullable<BaseTexture>;
  56088. private _skyboxMaterial;
  56089. /**
  56090. * Gets the skybox material created by the helper.
  56091. */
  56092. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56093. private _ground;
  56094. /**
  56095. * Gets the ground mesh created by the helper.
  56096. */
  56097. get ground(): Nullable<Mesh>;
  56098. private _groundTexture;
  56099. /**
  56100. * Gets the ground texture created by the helper.
  56101. */
  56102. get groundTexture(): Nullable<BaseTexture>;
  56103. private _groundMirror;
  56104. /**
  56105. * Gets the ground mirror created by the helper.
  56106. */
  56107. get groundMirror(): Nullable<MirrorTexture>;
  56108. /**
  56109. * Gets the ground mirror render list to helps pushing the meshes
  56110. * you wish in the ground reflection.
  56111. */
  56112. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  56113. private _groundMaterial;
  56114. /**
  56115. * Gets the ground material created by the helper.
  56116. */
  56117. get groundMaterial(): Nullable<BackgroundMaterial>;
  56118. /**
  56119. * Stores the creation options.
  56120. */
  56121. private readonly _scene;
  56122. private _options;
  56123. /**
  56124. * This observable will be notified with any error during the creation of the environment,
  56125. * mainly texture creation errors.
  56126. */
  56127. onErrorObservable: Observable<{
  56128. message?: string;
  56129. exception?: any;
  56130. }>;
  56131. /**
  56132. * constructor
  56133. * @param options Defines the options we want to customize the helper
  56134. * @param scene The scene to add the material to
  56135. */
  56136. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  56137. /**
  56138. * Updates the background according to the new options
  56139. * @param options
  56140. */
  56141. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  56142. /**
  56143. * Sets the primary color of all the available elements.
  56144. * @param color the main color to affect to the ground and the background
  56145. */
  56146. setMainColor(color: Color3): void;
  56147. /**
  56148. * Setup the image processing according to the specified options.
  56149. */
  56150. private _setupImageProcessing;
  56151. /**
  56152. * Setup the environment texture according to the specified options.
  56153. */
  56154. private _setupEnvironmentTexture;
  56155. /**
  56156. * Setup the background according to the specified options.
  56157. */
  56158. private _setupBackground;
  56159. /**
  56160. * Get the scene sizes according to the setup.
  56161. */
  56162. private _getSceneSize;
  56163. /**
  56164. * Setup the ground according to the specified options.
  56165. */
  56166. private _setupGround;
  56167. /**
  56168. * Setup the ground material according to the specified options.
  56169. */
  56170. private _setupGroundMaterial;
  56171. /**
  56172. * Setup the ground diffuse texture according to the specified options.
  56173. */
  56174. private _setupGroundDiffuseTexture;
  56175. /**
  56176. * Setup the ground mirror texture according to the specified options.
  56177. */
  56178. private _setupGroundMirrorTexture;
  56179. /**
  56180. * Setup the ground to receive the mirror texture.
  56181. */
  56182. private _setupMirrorInGroundMaterial;
  56183. /**
  56184. * Setup the skybox according to the specified options.
  56185. */
  56186. private _setupSkybox;
  56187. /**
  56188. * Setup the skybox material according to the specified options.
  56189. */
  56190. private _setupSkyboxMaterial;
  56191. /**
  56192. * Setup the skybox reflection texture according to the specified options.
  56193. */
  56194. private _setupSkyboxReflectionTexture;
  56195. private _errorHandler;
  56196. /**
  56197. * Dispose all the elements created by the Helper.
  56198. */
  56199. dispose(): void;
  56200. }
  56201. }
  56202. declare module "babylonjs/Helpers/photoDome" {
  56203. import { Observable } from "babylonjs/Misc/observable";
  56204. import { Nullable } from "babylonjs/types";
  56205. import { Scene } from "babylonjs/scene";
  56206. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56207. import { Mesh } from "babylonjs/Meshes/mesh";
  56208. import { Texture } from "babylonjs/Materials/Textures/texture";
  56209. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56210. import "babylonjs/Meshes/Builders/sphereBuilder";
  56211. /**
  56212. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56213. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56214. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56215. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56216. */
  56217. export class PhotoDome extends TransformNode {
  56218. /**
  56219. * Define the image as a Monoscopic panoramic 360 image.
  56220. */
  56221. static readonly MODE_MONOSCOPIC: number;
  56222. /**
  56223. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56224. */
  56225. static readonly MODE_TOPBOTTOM: number;
  56226. /**
  56227. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56228. */
  56229. static readonly MODE_SIDEBYSIDE: number;
  56230. private _useDirectMapping;
  56231. /**
  56232. * The texture being displayed on the sphere
  56233. */
  56234. protected _photoTexture: Texture;
  56235. /**
  56236. * Gets or sets the texture being displayed on the sphere
  56237. */
  56238. get photoTexture(): Texture;
  56239. set photoTexture(value: Texture);
  56240. /**
  56241. * Observable raised when an error occured while loading the 360 image
  56242. */
  56243. onLoadErrorObservable: Observable<string>;
  56244. /**
  56245. * The skybox material
  56246. */
  56247. protected _material: BackgroundMaterial;
  56248. /**
  56249. * The surface used for the skybox
  56250. */
  56251. protected _mesh: Mesh;
  56252. /**
  56253. * Gets the mesh used for the skybox.
  56254. */
  56255. get mesh(): Mesh;
  56256. /**
  56257. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56258. * Also see the options.resolution property.
  56259. */
  56260. get fovMultiplier(): number;
  56261. set fovMultiplier(value: number);
  56262. private _imageMode;
  56263. /**
  56264. * Gets or set the current video mode for the video. It can be:
  56265. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  56266. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56267. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56268. */
  56269. get imageMode(): number;
  56270. set imageMode(value: number);
  56271. /**
  56272. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  56273. * @param name Element's name, child elements will append suffixes for their own names.
  56274. * @param urlsOfPhoto defines the url of the photo to display
  56275. * @param options defines an object containing optional or exposed sub element properties
  56276. * @param onError defines a callback called when an error occured while loading the texture
  56277. */
  56278. constructor(name: string, urlOfPhoto: string, options: {
  56279. resolution?: number;
  56280. size?: number;
  56281. useDirectMapping?: boolean;
  56282. faceForward?: boolean;
  56283. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  56284. private _onBeforeCameraRenderObserver;
  56285. private _changeImageMode;
  56286. /**
  56287. * Releases resources associated with this node.
  56288. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56289. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56290. */
  56291. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56292. }
  56293. }
  56294. declare module "babylonjs/Misc/rgbdTextureTools" {
  56295. import "babylonjs/Shaders/rgbdDecode.fragment";
  56296. import "babylonjs/Engines/Extensions/engine.renderTarget";
  56297. import { Texture } from "babylonjs/Materials/Textures/texture";
  56298. /**
  56299. * Class used to host RGBD texture specific utilities
  56300. */
  56301. export class RGBDTextureTools {
  56302. /**
  56303. * Expand the RGBD Texture from RGBD to Half Float if possible.
  56304. * @param texture the texture to expand.
  56305. */
  56306. static ExpandRGBDTexture(texture: Texture): void;
  56307. }
  56308. }
  56309. declare module "babylonjs/Misc/brdfTextureTools" {
  56310. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56311. import { Scene } from "babylonjs/scene";
  56312. /**
  56313. * Class used to host texture specific utilities
  56314. */
  56315. export class BRDFTextureTools {
  56316. /**
  56317. * Prevents texture cache collision
  56318. */
  56319. private static _instanceNumber;
  56320. /**
  56321. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  56322. * @param scene defines the hosting scene
  56323. * @returns the environment BRDF texture
  56324. */
  56325. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  56326. private static _environmentBRDFBase64Texture;
  56327. }
  56328. }
  56329. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  56330. import { Nullable } from "babylonjs/types";
  56331. import { Color3 } from "babylonjs/Maths/math.color";
  56332. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56333. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56334. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56335. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56336. import { Engine } from "babylonjs/Engines/engine";
  56337. import { Scene } from "babylonjs/scene";
  56338. /**
  56339. * @hidden
  56340. */
  56341. export interface IMaterialClearCoatDefines {
  56342. CLEARCOAT: boolean;
  56343. CLEARCOAT_DEFAULTIOR: boolean;
  56344. CLEARCOAT_TEXTURE: boolean;
  56345. CLEARCOAT_TEXTUREDIRECTUV: number;
  56346. CLEARCOAT_BUMP: boolean;
  56347. CLEARCOAT_BUMPDIRECTUV: number;
  56348. CLEARCOAT_TINT: boolean;
  56349. CLEARCOAT_TINT_TEXTURE: boolean;
  56350. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56351. /** @hidden */
  56352. _areTexturesDirty: boolean;
  56353. }
  56354. /**
  56355. * Define the code related to the clear coat parameters of the pbr material.
  56356. */
  56357. export class PBRClearCoatConfiguration {
  56358. /**
  56359. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56360. * The default fits with a polyurethane material.
  56361. */
  56362. private static readonly _DefaultIndexOfRefraction;
  56363. private _isEnabled;
  56364. /**
  56365. * Defines if the clear coat is enabled in the material.
  56366. */
  56367. isEnabled: boolean;
  56368. /**
  56369. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56370. */
  56371. intensity: number;
  56372. /**
  56373. * Defines the clear coat layer roughness.
  56374. */
  56375. roughness: number;
  56376. private _indexOfRefraction;
  56377. /**
  56378. * Defines the index of refraction of the clear coat.
  56379. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56380. * The default fits with a polyurethane material.
  56381. * Changing the default value is more performance intensive.
  56382. */
  56383. indexOfRefraction: number;
  56384. private _texture;
  56385. /**
  56386. * Stores the clear coat values in a texture.
  56387. */
  56388. texture: Nullable<BaseTexture>;
  56389. private _bumpTexture;
  56390. /**
  56391. * Define the clear coat specific bump texture.
  56392. */
  56393. bumpTexture: Nullable<BaseTexture>;
  56394. private _isTintEnabled;
  56395. /**
  56396. * Defines if the clear coat tint is enabled in the material.
  56397. */
  56398. isTintEnabled: boolean;
  56399. /**
  56400. * Defines the clear coat tint of the material.
  56401. * This is only use if tint is enabled
  56402. */
  56403. tintColor: Color3;
  56404. /**
  56405. * Defines the distance at which the tint color should be found in the
  56406. * clear coat media.
  56407. * This is only use if tint is enabled
  56408. */
  56409. tintColorAtDistance: number;
  56410. /**
  56411. * Defines the clear coat layer thickness.
  56412. * This is only use if tint is enabled
  56413. */
  56414. tintThickness: number;
  56415. private _tintTexture;
  56416. /**
  56417. * Stores the clear tint values in a texture.
  56418. * rgb is tint
  56419. * a is a thickness factor
  56420. */
  56421. tintTexture: Nullable<BaseTexture>;
  56422. /** @hidden */
  56423. private _internalMarkAllSubMeshesAsTexturesDirty;
  56424. /** @hidden */
  56425. _markAllSubMeshesAsTexturesDirty(): void;
  56426. /**
  56427. * Instantiate a new istance of clear coat configuration.
  56428. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56429. */
  56430. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56431. /**
  56432. * Gets wehter the submesh is ready to be used or not.
  56433. * @param defines the list of "defines" to update.
  56434. * @param scene defines the scene the material belongs to.
  56435. * @param engine defines the engine the material belongs to.
  56436. * @param disableBumpMap defines wether the material disables bump or not.
  56437. * @returns - boolean indicating that the submesh is ready or not.
  56438. */
  56439. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56440. /**
  56441. * Checks to see if a texture is used in the material.
  56442. * @param defines the list of "defines" to update.
  56443. * @param scene defines the scene to the material belongs to.
  56444. */
  56445. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  56446. /**
  56447. * Binds the material data.
  56448. * @param uniformBuffer defines the Uniform buffer to fill in.
  56449. * @param scene defines the scene the material belongs to.
  56450. * @param engine defines the engine the material belongs to.
  56451. * @param disableBumpMap defines wether the material disables bump or not.
  56452. * @param isFrozen defines wether the material is frozen or not.
  56453. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56454. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56455. */
  56456. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  56457. /**
  56458. * Checks to see if a texture is used in the material.
  56459. * @param texture - Base texture to use.
  56460. * @returns - Boolean specifying if a texture is used in the material.
  56461. */
  56462. hasTexture(texture: BaseTexture): boolean;
  56463. /**
  56464. * Returns an array of the actively used textures.
  56465. * @param activeTextures Array of BaseTextures
  56466. */
  56467. getActiveTextures(activeTextures: BaseTexture[]): void;
  56468. /**
  56469. * Returns the animatable textures.
  56470. * @param animatables Array of animatable textures.
  56471. */
  56472. getAnimatables(animatables: IAnimatable[]): void;
  56473. /**
  56474. * Disposes the resources of the material.
  56475. * @param forceDisposeTextures - Forces the disposal of all textures.
  56476. */
  56477. dispose(forceDisposeTextures?: boolean): void;
  56478. /**
  56479. * Get the current class name of the texture useful for serialization or dynamic coding.
  56480. * @returns "PBRClearCoatConfiguration"
  56481. */
  56482. getClassName(): string;
  56483. /**
  56484. * Add fallbacks to the effect fallbacks list.
  56485. * @param defines defines the Base texture to use.
  56486. * @param fallbacks defines the current fallback list.
  56487. * @param currentRank defines the current fallback rank.
  56488. * @returns the new fallback rank.
  56489. */
  56490. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56491. /**
  56492. * Add the required uniforms to the current list.
  56493. * @param uniforms defines the current uniform list.
  56494. */
  56495. static AddUniforms(uniforms: string[]): void;
  56496. /**
  56497. * Add the required samplers to the current list.
  56498. * @param samplers defines the current sampler list.
  56499. */
  56500. static AddSamplers(samplers: string[]): void;
  56501. /**
  56502. * Add the required uniforms to the current buffer.
  56503. * @param uniformBuffer defines the current uniform buffer.
  56504. */
  56505. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56506. /**
  56507. * Makes a duplicate of the current configuration into another one.
  56508. * @param clearCoatConfiguration define the config where to copy the info
  56509. */
  56510. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  56511. /**
  56512. * Serializes this clear coat configuration.
  56513. * @returns - An object with the serialized config.
  56514. */
  56515. serialize(): any;
  56516. /**
  56517. * Parses a anisotropy Configuration from a serialized object.
  56518. * @param source - Serialized object.
  56519. * @param scene Defines the scene we are parsing for
  56520. * @param rootUrl Defines the rootUrl to load from
  56521. */
  56522. parse(source: any, scene: Scene, rootUrl: string): void;
  56523. }
  56524. }
  56525. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  56526. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56528. import { Vector2 } from "babylonjs/Maths/math.vector";
  56529. import { Scene } from "babylonjs/scene";
  56530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56531. import { Nullable } from "babylonjs/types";
  56532. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56533. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56534. /**
  56535. * @hidden
  56536. */
  56537. export interface IMaterialAnisotropicDefines {
  56538. ANISOTROPIC: boolean;
  56539. ANISOTROPIC_TEXTURE: boolean;
  56540. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56541. MAINUV1: boolean;
  56542. _areTexturesDirty: boolean;
  56543. _needUVs: boolean;
  56544. }
  56545. /**
  56546. * Define the code related to the anisotropic parameters of the pbr material.
  56547. */
  56548. export class PBRAnisotropicConfiguration {
  56549. private _isEnabled;
  56550. /**
  56551. * Defines if the anisotropy is enabled in the material.
  56552. */
  56553. isEnabled: boolean;
  56554. /**
  56555. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  56556. */
  56557. intensity: number;
  56558. /**
  56559. * Defines if the effect is along the tangents, bitangents or in between.
  56560. * By default, the effect is "strectching" the highlights along the tangents.
  56561. */
  56562. direction: Vector2;
  56563. private _texture;
  56564. /**
  56565. * Stores the anisotropy values in a texture.
  56566. * rg is direction (like normal from -1 to 1)
  56567. * b is a intensity
  56568. */
  56569. texture: Nullable<BaseTexture>;
  56570. /** @hidden */
  56571. private _internalMarkAllSubMeshesAsTexturesDirty;
  56572. /** @hidden */
  56573. _markAllSubMeshesAsTexturesDirty(): void;
  56574. /**
  56575. * Instantiate a new istance of anisotropy configuration.
  56576. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56577. */
  56578. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56579. /**
  56580. * Specifies that the submesh is ready to be used.
  56581. * @param defines the list of "defines" to update.
  56582. * @param scene defines the scene the material belongs to.
  56583. * @returns - boolean indicating that the submesh is ready or not.
  56584. */
  56585. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56586. /**
  56587. * Checks to see if a texture is used in the material.
  56588. * @param defines the list of "defines" to update.
  56589. * @param mesh the mesh we are preparing the defines for.
  56590. * @param scene defines the scene the material belongs to.
  56591. */
  56592. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56593. /**
  56594. * Binds the material data.
  56595. * @param uniformBuffer defines the Uniform buffer to fill in.
  56596. * @param scene defines the scene the material belongs to.
  56597. * @param isFrozen defines wether the material is frozen or not.
  56598. */
  56599. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56600. /**
  56601. * Checks to see if a texture is used in the material.
  56602. * @param texture - Base texture to use.
  56603. * @returns - Boolean specifying if a texture is used in the material.
  56604. */
  56605. hasTexture(texture: BaseTexture): boolean;
  56606. /**
  56607. * Returns an array of the actively used textures.
  56608. * @param activeTextures Array of BaseTextures
  56609. */
  56610. getActiveTextures(activeTextures: BaseTexture[]): void;
  56611. /**
  56612. * Returns the animatable textures.
  56613. * @param animatables Array of animatable textures.
  56614. */
  56615. getAnimatables(animatables: IAnimatable[]): void;
  56616. /**
  56617. * Disposes the resources of the material.
  56618. * @param forceDisposeTextures - Forces the disposal of all textures.
  56619. */
  56620. dispose(forceDisposeTextures?: boolean): void;
  56621. /**
  56622. * Get the current class name of the texture useful for serialization or dynamic coding.
  56623. * @returns "PBRAnisotropicConfiguration"
  56624. */
  56625. getClassName(): string;
  56626. /**
  56627. * Add fallbacks to the effect fallbacks list.
  56628. * @param defines defines the Base texture to use.
  56629. * @param fallbacks defines the current fallback list.
  56630. * @param currentRank defines the current fallback rank.
  56631. * @returns the new fallback rank.
  56632. */
  56633. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56634. /**
  56635. * Add the required uniforms to the current list.
  56636. * @param uniforms defines the current uniform list.
  56637. */
  56638. static AddUniforms(uniforms: string[]): void;
  56639. /**
  56640. * Add the required uniforms to the current buffer.
  56641. * @param uniformBuffer defines the current uniform buffer.
  56642. */
  56643. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56644. /**
  56645. * Add the required samplers to the current list.
  56646. * @param samplers defines the current sampler list.
  56647. */
  56648. static AddSamplers(samplers: string[]): void;
  56649. /**
  56650. * Makes a duplicate of the current configuration into another one.
  56651. * @param anisotropicConfiguration define the config where to copy the info
  56652. */
  56653. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56654. /**
  56655. * Serializes this anisotropy configuration.
  56656. * @returns - An object with the serialized config.
  56657. */
  56658. serialize(): any;
  56659. /**
  56660. * Parses a anisotropy Configuration from a serialized object.
  56661. * @param source - Serialized object.
  56662. * @param scene Defines the scene we are parsing for
  56663. * @param rootUrl Defines the rootUrl to load from
  56664. */
  56665. parse(source: any, scene: Scene, rootUrl: string): void;
  56666. }
  56667. }
  56668. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56669. import { Scene } from "babylonjs/scene";
  56670. /**
  56671. * @hidden
  56672. */
  56673. export interface IMaterialBRDFDefines {
  56674. BRDF_V_HEIGHT_CORRELATED: boolean;
  56675. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56676. SPHERICAL_HARMONICS: boolean;
  56677. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56678. /** @hidden */
  56679. _areMiscDirty: boolean;
  56680. }
  56681. /**
  56682. * Define the code related to the BRDF parameters of the pbr material.
  56683. */
  56684. export class PBRBRDFConfiguration {
  56685. /**
  56686. * Default value used for the energy conservation.
  56687. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56688. */
  56689. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56690. /**
  56691. * Default value used for the Smith Visibility Height Correlated mode.
  56692. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56693. */
  56694. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56695. /**
  56696. * Default value used for the IBL diffuse part.
  56697. * This can help switching back to the polynomials mode globally which is a tiny bit
  56698. * less GPU intensive at the drawback of a lower quality.
  56699. */
  56700. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56701. /**
  56702. * Default value used for activating energy conservation for the specular workflow.
  56703. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56704. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56705. */
  56706. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56707. private _useEnergyConservation;
  56708. /**
  56709. * Defines if the material uses energy conservation.
  56710. */
  56711. useEnergyConservation: boolean;
  56712. private _useSmithVisibilityHeightCorrelated;
  56713. /**
  56714. * LEGACY Mode set to false
  56715. * Defines if the material uses height smith correlated visibility term.
  56716. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56717. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56718. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56719. * Not relying on height correlated will also disable energy conservation.
  56720. */
  56721. useSmithVisibilityHeightCorrelated: boolean;
  56722. private _useSphericalHarmonics;
  56723. /**
  56724. * LEGACY Mode set to false
  56725. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56726. * diffuse part of the IBL.
  56727. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56728. * to the ground truth.
  56729. */
  56730. useSphericalHarmonics: boolean;
  56731. private _useSpecularGlossinessInputEnergyConservation;
  56732. /**
  56733. * Defines if the material uses energy conservation, when the specular workflow is active.
  56734. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56735. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56736. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56737. */
  56738. useSpecularGlossinessInputEnergyConservation: boolean;
  56739. /** @hidden */
  56740. private _internalMarkAllSubMeshesAsMiscDirty;
  56741. /** @hidden */
  56742. _markAllSubMeshesAsMiscDirty(): void;
  56743. /**
  56744. * Instantiate a new istance of clear coat configuration.
  56745. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56746. */
  56747. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56748. /**
  56749. * Checks to see if a texture is used in the material.
  56750. * @param defines the list of "defines" to update.
  56751. */
  56752. prepareDefines(defines: IMaterialBRDFDefines): void;
  56753. /**
  56754. * Get the current class name of the texture useful for serialization or dynamic coding.
  56755. * @returns "PBRClearCoatConfiguration"
  56756. */
  56757. getClassName(): string;
  56758. /**
  56759. * Makes a duplicate of the current configuration into another one.
  56760. * @param brdfConfiguration define the config where to copy the info
  56761. */
  56762. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56763. /**
  56764. * Serializes this BRDF configuration.
  56765. * @returns - An object with the serialized config.
  56766. */
  56767. serialize(): any;
  56768. /**
  56769. * Parses a anisotropy Configuration from a serialized object.
  56770. * @param source - Serialized object.
  56771. * @param scene Defines the scene we are parsing for
  56772. * @param rootUrl Defines the rootUrl to load from
  56773. */
  56774. parse(source: any, scene: Scene, rootUrl: string): void;
  56775. }
  56776. }
  56777. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56778. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56779. import { Color3 } from "babylonjs/Maths/math.color";
  56780. import { Scene } from "babylonjs/scene";
  56781. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56782. import { Nullable } from "babylonjs/types";
  56783. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56784. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56785. /**
  56786. * @hidden
  56787. */
  56788. export interface IMaterialSheenDefines {
  56789. SHEEN: boolean;
  56790. SHEEN_TEXTURE: boolean;
  56791. SHEEN_TEXTUREDIRECTUV: number;
  56792. SHEEN_LINKWITHALBEDO: boolean;
  56793. SHEEN_ROUGHNESS: boolean;
  56794. SHEEN_ALBEDOSCALING: boolean;
  56795. /** @hidden */
  56796. _areTexturesDirty: boolean;
  56797. }
  56798. /**
  56799. * Define the code related to the Sheen parameters of the pbr material.
  56800. */
  56801. export class PBRSheenConfiguration {
  56802. private _isEnabled;
  56803. /**
  56804. * Defines if the material uses sheen.
  56805. */
  56806. isEnabled: boolean;
  56807. private _linkSheenWithAlbedo;
  56808. /**
  56809. * Defines if the sheen is linked to the sheen color.
  56810. */
  56811. linkSheenWithAlbedo: boolean;
  56812. /**
  56813. * Defines the sheen intensity.
  56814. */
  56815. intensity: number;
  56816. /**
  56817. * Defines the sheen color.
  56818. */
  56819. color: Color3;
  56820. private _texture;
  56821. /**
  56822. * Stores the sheen tint values in a texture.
  56823. * rgb is tint
  56824. * a is a intensity or roughness if roughness has been defined
  56825. */
  56826. texture: Nullable<BaseTexture>;
  56827. private _roughness;
  56828. /**
  56829. * Defines the sheen roughness.
  56830. * It is not taken into account if linkSheenWithAlbedo is true.
  56831. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56832. */
  56833. roughness: Nullable<number>;
  56834. private _albedoScaling;
  56835. /**
  56836. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56837. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56838. * making it easier to setup and tweak the effect
  56839. */
  56840. albedoScaling: boolean;
  56841. /** @hidden */
  56842. private _internalMarkAllSubMeshesAsTexturesDirty;
  56843. /** @hidden */
  56844. _markAllSubMeshesAsTexturesDirty(): void;
  56845. /**
  56846. * Instantiate a new istance of clear coat configuration.
  56847. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56848. */
  56849. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56850. /**
  56851. * Specifies that the submesh is ready to be used.
  56852. * @param defines the list of "defines" to update.
  56853. * @param scene defines the scene the material belongs to.
  56854. * @returns - boolean indicating that the submesh is ready or not.
  56855. */
  56856. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56857. /**
  56858. * Checks to see if a texture is used in the material.
  56859. * @param defines the list of "defines" to update.
  56860. * @param scene defines the scene the material belongs to.
  56861. */
  56862. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56863. /**
  56864. * Binds the material data.
  56865. * @param uniformBuffer defines the Uniform buffer to fill in.
  56866. * @param scene defines the scene the material belongs to.
  56867. * @param isFrozen defines wether the material is frozen or not.
  56868. */
  56869. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56870. /**
  56871. * Checks to see if a texture is used in the material.
  56872. * @param texture - Base texture to use.
  56873. * @returns - Boolean specifying if a texture is used in the material.
  56874. */
  56875. hasTexture(texture: BaseTexture): boolean;
  56876. /**
  56877. * Returns an array of the actively used textures.
  56878. * @param activeTextures Array of BaseTextures
  56879. */
  56880. getActiveTextures(activeTextures: BaseTexture[]): void;
  56881. /**
  56882. * Returns the animatable textures.
  56883. * @param animatables Array of animatable textures.
  56884. */
  56885. getAnimatables(animatables: IAnimatable[]): void;
  56886. /**
  56887. * Disposes the resources of the material.
  56888. * @param forceDisposeTextures - Forces the disposal of all textures.
  56889. */
  56890. dispose(forceDisposeTextures?: boolean): void;
  56891. /**
  56892. * Get the current class name of the texture useful for serialization or dynamic coding.
  56893. * @returns "PBRSheenConfiguration"
  56894. */
  56895. getClassName(): string;
  56896. /**
  56897. * Add fallbacks to the effect fallbacks list.
  56898. * @param defines defines the Base texture to use.
  56899. * @param fallbacks defines the current fallback list.
  56900. * @param currentRank defines the current fallback rank.
  56901. * @returns the new fallback rank.
  56902. */
  56903. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56904. /**
  56905. * Add the required uniforms to the current list.
  56906. * @param uniforms defines the current uniform list.
  56907. */
  56908. static AddUniforms(uniforms: string[]): void;
  56909. /**
  56910. * Add the required uniforms to the current buffer.
  56911. * @param uniformBuffer defines the current uniform buffer.
  56912. */
  56913. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56914. /**
  56915. * Add the required samplers to the current list.
  56916. * @param samplers defines the current sampler list.
  56917. */
  56918. static AddSamplers(samplers: string[]): void;
  56919. /**
  56920. * Makes a duplicate of the current configuration into another one.
  56921. * @param sheenConfiguration define the config where to copy the info
  56922. */
  56923. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56924. /**
  56925. * Serializes this BRDF configuration.
  56926. * @returns - An object with the serialized config.
  56927. */
  56928. serialize(): any;
  56929. /**
  56930. * Parses a anisotropy Configuration from a serialized object.
  56931. * @param source - Serialized object.
  56932. * @param scene Defines the scene we are parsing for
  56933. * @param rootUrl Defines the rootUrl to load from
  56934. */
  56935. parse(source: any, scene: Scene, rootUrl: string): void;
  56936. }
  56937. }
  56938. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56939. import { Nullable } from "babylonjs/types";
  56940. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56941. import { Color3 } from "babylonjs/Maths/math.color";
  56942. import { SmartArray } from "babylonjs/Misc/smartArray";
  56943. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56944. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56945. import { Effect } from "babylonjs/Materials/effect";
  56946. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56947. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56948. import { Engine } from "babylonjs/Engines/engine";
  56949. import { Scene } from "babylonjs/scene";
  56950. /**
  56951. * @hidden
  56952. */
  56953. export interface IMaterialSubSurfaceDefines {
  56954. SUBSURFACE: boolean;
  56955. SS_REFRACTION: boolean;
  56956. SS_TRANSLUCENCY: boolean;
  56957. SS_SCATTERING: boolean;
  56958. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56959. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56960. SS_REFRACTIONMAP_3D: boolean;
  56961. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56962. SS_LODINREFRACTIONALPHA: boolean;
  56963. SS_GAMMAREFRACTION: boolean;
  56964. SS_RGBDREFRACTION: boolean;
  56965. SS_LINEARSPECULARREFRACTION: boolean;
  56966. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56967. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56968. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56969. /** @hidden */
  56970. _areTexturesDirty: boolean;
  56971. }
  56972. /**
  56973. * Define the code related to the sub surface parameters of the pbr material.
  56974. */
  56975. export class PBRSubSurfaceConfiguration {
  56976. private _isRefractionEnabled;
  56977. /**
  56978. * Defines if the refraction is enabled in the material.
  56979. */
  56980. isRefractionEnabled: boolean;
  56981. private _isTranslucencyEnabled;
  56982. /**
  56983. * Defines if the translucency is enabled in the material.
  56984. */
  56985. isTranslucencyEnabled: boolean;
  56986. private _isScatteringEnabled;
  56987. /**
  56988. * Defines if the sub surface scattering is enabled in the material.
  56989. */
  56990. isScatteringEnabled: boolean;
  56991. private _scatteringDiffusionProfileIndex;
  56992. /**
  56993. * Diffusion profile for subsurface scattering.
  56994. * Useful for better scattering in the skins or foliages.
  56995. */
  56996. get scatteringDiffusionProfile(): Nullable<Color3>;
  56997. set scatteringDiffusionProfile(c: Nullable<Color3>);
  56998. /**
  56999. * Defines the refraction intensity of the material.
  57000. * The refraction when enabled replaces the Diffuse part of the material.
  57001. * The intensity helps transitionning between diffuse and refraction.
  57002. */
  57003. refractionIntensity: number;
  57004. /**
  57005. * Defines the translucency intensity of the material.
  57006. * When translucency has been enabled, this defines how much of the "translucency"
  57007. * is addded to the diffuse part of the material.
  57008. */
  57009. translucencyIntensity: number;
  57010. /**
  57011. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57012. */
  57013. useAlbedoToTintRefraction: boolean;
  57014. private _thicknessTexture;
  57015. /**
  57016. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57017. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57018. * 0 would mean minimumThickness
  57019. * 1 would mean maximumThickness
  57020. * The other channels might be use as a mask to vary the different effects intensity.
  57021. */
  57022. thicknessTexture: Nullable<BaseTexture>;
  57023. private _refractionTexture;
  57024. /**
  57025. * Defines the texture to use for refraction.
  57026. */
  57027. refractionTexture: Nullable<BaseTexture>;
  57028. private _indexOfRefraction;
  57029. /**
  57030. * Index of refraction of the material base layer.
  57031. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57032. *
  57033. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57034. *
  57035. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57036. */
  57037. indexOfRefraction: number;
  57038. private _volumeIndexOfRefraction;
  57039. /**
  57040. * Index of refraction of the material's volume.
  57041. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57042. *
  57043. * This ONLY impacts refraction. If not provided or given a non-valid value,
  57044. * the volume will use the same IOR as the surface.
  57045. */
  57046. get volumeIndexOfRefraction(): number;
  57047. set volumeIndexOfRefraction(value: number);
  57048. private _invertRefractionY;
  57049. /**
  57050. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57051. */
  57052. invertRefractionY: boolean;
  57053. private _linkRefractionWithTransparency;
  57054. /**
  57055. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57056. * Materials half opaque for instance using refraction could benefit from this control.
  57057. */
  57058. linkRefractionWithTransparency: boolean;
  57059. /**
  57060. * Defines the minimum thickness stored in the thickness map.
  57061. * If no thickness map is defined, this value will be used to simulate thickness.
  57062. */
  57063. minimumThickness: number;
  57064. /**
  57065. * Defines the maximum thickness stored in the thickness map.
  57066. */
  57067. maximumThickness: number;
  57068. /**
  57069. * Defines the volume tint of the material.
  57070. * This is used for both translucency and scattering.
  57071. */
  57072. tintColor: Color3;
  57073. /**
  57074. * Defines the distance at which the tint color should be found in the media.
  57075. * This is used for refraction only.
  57076. */
  57077. tintColorAtDistance: number;
  57078. /**
  57079. * Defines how far each channel transmit through the media.
  57080. * It is defined as a color to simplify it selection.
  57081. */
  57082. diffusionDistance: Color3;
  57083. private _useMaskFromThicknessTexture;
  57084. /**
  57085. * Stores the intensity of the different subsurface effects in the thickness texture.
  57086. * * the green channel is the translucency intensity.
  57087. * * the blue channel is the scattering intensity.
  57088. * * the alpha channel is the refraction intensity.
  57089. */
  57090. useMaskFromThicknessTexture: boolean;
  57091. private _scene;
  57092. /** @hidden */
  57093. private _internalMarkAllSubMeshesAsTexturesDirty;
  57094. private _internalMarkScenePrePassDirty;
  57095. /** @hidden */
  57096. _markAllSubMeshesAsTexturesDirty(): void;
  57097. /** @hidden */
  57098. _markScenePrePassDirty(): void;
  57099. /**
  57100. * Instantiate a new istance of sub surface configuration.
  57101. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57102. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  57103. * @param scene The scene
  57104. */
  57105. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  57106. /**
  57107. * Gets wehter the submesh is ready to be used or not.
  57108. * @param defines the list of "defines" to update.
  57109. * @param scene defines the scene the material belongs to.
  57110. * @returns - boolean indicating that the submesh is ready or not.
  57111. */
  57112. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  57113. /**
  57114. * Checks to see if a texture is used in the material.
  57115. * @param defines the list of "defines" to update.
  57116. * @param scene defines the scene to the material belongs to.
  57117. */
  57118. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  57119. /**
  57120. * Binds the material data.
  57121. * @param uniformBuffer defines the Uniform buffer to fill in.
  57122. * @param scene defines the scene the material belongs to.
  57123. * @param engine defines the engine the material belongs to.
  57124. * @param isFrozen defines whether the material is frozen or not.
  57125. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  57126. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  57127. */
  57128. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  57129. /**
  57130. * Unbinds the material from the mesh.
  57131. * @param activeEffect defines the effect that should be unbound from.
  57132. * @returns true if unbound, otherwise false
  57133. */
  57134. unbind(activeEffect: Effect): boolean;
  57135. /**
  57136. * Returns the texture used for refraction or null if none is used.
  57137. * @param scene defines the scene the material belongs to.
  57138. * @returns - Refraction texture if present. If no refraction texture and refraction
  57139. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57140. */
  57141. private _getRefractionTexture;
  57142. /**
  57143. * Returns true if alpha blending should be disabled.
  57144. */
  57145. get disableAlphaBlending(): boolean;
  57146. /**
  57147. * Fills the list of render target textures.
  57148. * @param renderTargets the list of render targets to update
  57149. */
  57150. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  57151. /**
  57152. * Checks to see if a texture is used in the material.
  57153. * @param texture - Base texture to use.
  57154. * @returns - Boolean specifying if a texture is used in the material.
  57155. */
  57156. hasTexture(texture: BaseTexture): boolean;
  57157. /**
  57158. * Gets a boolean indicating that current material needs to register RTT
  57159. * @returns true if this uses a render target otherwise false.
  57160. */
  57161. hasRenderTargetTextures(): boolean;
  57162. /**
  57163. * Returns an array of the actively used textures.
  57164. * @param activeTextures Array of BaseTextures
  57165. */
  57166. getActiveTextures(activeTextures: BaseTexture[]): void;
  57167. /**
  57168. * Returns the animatable textures.
  57169. * @param animatables Array of animatable textures.
  57170. */
  57171. getAnimatables(animatables: IAnimatable[]): void;
  57172. /**
  57173. * Disposes the resources of the material.
  57174. * @param forceDisposeTextures - Forces the disposal of all textures.
  57175. */
  57176. dispose(forceDisposeTextures?: boolean): void;
  57177. /**
  57178. * Get the current class name of the texture useful for serialization or dynamic coding.
  57179. * @returns "PBRSubSurfaceConfiguration"
  57180. */
  57181. getClassName(): string;
  57182. /**
  57183. * Add fallbacks to the effect fallbacks list.
  57184. * @param defines defines the Base texture to use.
  57185. * @param fallbacks defines the current fallback list.
  57186. * @param currentRank defines the current fallback rank.
  57187. * @returns the new fallback rank.
  57188. */
  57189. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57190. /**
  57191. * Add the required uniforms to the current list.
  57192. * @param uniforms defines the current uniform list.
  57193. */
  57194. static AddUniforms(uniforms: string[]): void;
  57195. /**
  57196. * Add the required samplers to the current list.
  57197. * @param samplers defines the current sampler list.
  57198. */
  57199. static AddSamplers(samplers: string[]): void;
  57200. /**
  57201. * Add the required uniforms to the current buffer.
  57202. * @param uniformBuffer defines the current uniform buffer.
  57203. */
  57204. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57205. /**
  57206. * Makes a duplicate of the current configuration into another one.
  57207. * @param configuration define the config where to copy the info
  57208. */
  57209. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57210. /**
  57211. * Serializes this Sub Surface configuration.
  57212. * @returns - An object with the serialized config.
  57213. */
  57214. serialize(): any;
  57215. /**
  57216. * Parses a anisotropy Configuration from a serialized object.
  57217. * @param source - Serialized object.
  57218. * @param scene Defines the scene we are parsing for
  57219. * @param rootUrl Defines the rootUrl to load from
  57220. */
  57221. parse(source: any, scene: Scene, rootUrl: string): void;
  57222. }
  57223. }
  57224. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  57225. /** @hidden */
  57226. export var prePassDeclaration: {
  57227. name: string;
  57228. shader: string;
  57229. };
  57230. }
  57231. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57232. /** @hidden */
  57233. export var pbrFragmentDeclaration: {
  57234. name: string;
  57235. shader: string;
  57236. };
  57237. }
  57238. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  57239. /** @hidden */
  57240. export var pbrUboDeclaration: {
  57241. name: string;
  57242. shader: string;
  57243. };
  57244. }
  57245. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  57246. /** @hidden */
  57247. export var pbrFragmentExtraDeclaration: {
  57248. name: string;
  57249. shader: string;
  57250. };
  57251. }
  57252. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  57253. /** @hidden */
  57254. export var pbrFragmentSamplersDeclaration: {
  57255. name: string;
  57256. shader: string;
  57257. };
  57258. }
  57259. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  57260. /** @hidden */
  57261. export var subSurfaceScatteringFunctions: {
  57262. name: string;
  57263. shader: string;
  57264. };
  57265. }
  57266. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  57267. /** @hidden */
  57268. export var importanceSampling: {
  57269. name: string;
  57270. shader: string;
  57271. };
  57272. }
  57273. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  57274. /** @hidden */
  57275. export var pbrHelperFunctions: {
  57276. name: string;
  57277. shader: string;
  57278. };
  57279. }
  57280. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  57281. /** @hidden */
  57282. export var harmonicsFunctions: {
  57283. name: string;
  57284. shader: string;
  57285. };
  57286. }
  57287. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  57288. /** @hidden */
  57289. export var pbrDirectLightingSetupFunctions: {
  57290. name: string;
  57291. shader: string;
  57292. };
  57293. }
  57294. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  57295. /** @hidden */
  57296. export var pbrDirectLightingFalloffFunctions: {
  57297. name: string;
  57298. shader: string;
  57299. };
  57300. }
  57301. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  57302. /** @hidden */
  57303. export var pbrBRDFFunctions: {
  57304. name: string;
  57305. shader: string;
  57306. };
  57307. }
  57308. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  57309. /** @hidden */
  57310. export var hdrFilteringFunctions: {
  57311. name: string;
  57312. shader: string;
  57313. };
  57314. }
  57315. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  57316. /** @hidden */
  57317. export var pbrDirectLightingFunctions: {
  57318. name: string;
  57319. shader: string;
  57320. };
  57321. }
  57322. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  57323. /** @hidden */
  57324. export var pbrIBLFunctions: {
  57325. name: string;
  57326. shader: string;
  57327. };
  57328. }
  57329. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  57330. /** @hidden */
  57331. export var pbrBlockAlbedoOpacity: {
  57332. name: string;
  57333. shader: string;
  57334. };
  57335. }
  57336. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  57337. /** @hidden */
  57338. export var pbrBlockReflectivity: {
  57339. name: string;
  57340. shader: string;
  57341. };
  57342. }
  57343. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  57344. /** @hidden */
  57345. export var pbrBlockAmbientOcclusion: {
  57346. name: string;
  57347. shader: string;
  57348. };
  57349. }
  57350. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  57351. /** @hidden */
  57352. export var pbrBlockAlphaFresnel: {
  57353. name: string;
  57354. shader: string;
  57355. };
  57356. }
  57357. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  57358. /** @hidden */
  57359. export var pbrBlockAnisotropic: {
  57360. name: string;
  57361. shader: string;
  57362. };
  57363. }
  57364. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  57365. /** @hidden */
  57366. export var pbrBlockReflection: {
  57367. name: string;
  57368. shader: string;
  57369. };
  57370. }
  57371. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57372. /** @hidden */
  57373. export var pbrBlockSheen: {
  57374. name: string;
  57375. shader: string;
  57376. };
  57377. }
  57378. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57379. /** @hidden */
  57380. export var pbrBlockClearcoat: {
  57381. name: string;
  57382. shader: string;
  57383. };
  57384. }
  57385. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57386. /** @hidden */
  57387. export var pbrBlockSubSurface: {
  57388. name: string;
  57389. shader: string;
  57390. };
  57391. }
  57392. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57393. /** @hidden */
  57394. export var pbrBlockNormalGeometric: {
  57395. name: string;
  57396. shader: string;
  57397. };
  57398. }
  57399. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57400. /** @hidden */
  57401. export var pbrBlockNormalFinal: {
  57402. name: string;
  57403. shader: string;
  57404. };
  57405. }
  57406. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57407. /** @hidden */
  57408. export var pbrBlockGeometryInfo: {
  57409. name: string;
  57410. shader: string;
  57411. };
  57412. }
  57413. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57414. /** @hidden */
  57415. export var pbrBlockReflectance0: {
  57416. name: string;
  57417. shader: string;
  57418. };
  57419. }
  57420. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57421. /** @hidden */
  57422. export var pbrBlockReflectance: {
  57423. name: string;
  57424. shader: string;
  57425. };
  57426. }
  57427. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57428. /** @hidden */
  57429. export var pbrBlockDirectLighting: {
  57430. name: string;
  57431. shader: string;
  57432. };
  57433. }
  57434. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57435. /** @hidden */
  57436. export var pbrBlockFinalLitComponents: {
  57437. name: string;
  57438. shader: string;
  57439. };
  57440. }
  57441. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57442. /** @hidden */
  57443. export var pbrBlockFinalUnlitComponents: {
  57444. name: string;
  57445. shader: string;
  57446. };
  57447. }
  57448. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57449. /** @hidden */
  57450. export var pbrBlockFinalColorComposition: {
  57451. name: string;
  57452. shader: string;
  57453. };
  57454. }
  57455. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  57456. /** @hidden */
  57457. export var pbrBlockImageProcessing: {
  57458. name: string;
  57459. shader: string;
  57460. };
  57461. }
  57462. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  57463. /** @hidden */
  57464. export var pbrDebug: {
  57465. name: string;
  57466. shader: string;
  57467. };
  57468. }
  57469. declare module "babylonjs/Shaders/pbr.fragment" {
  57470. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  57471. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  57472. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57473. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  57474. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57475. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57476. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  57477. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57478. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57479. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57480. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57481. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57482. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  57483. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  57484. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  57485. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57486. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57487. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57488. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  57489. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  57490. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  57491. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  57492. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  57493. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  57494. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  57495. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57496. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57497. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  57498. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  57499. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  57500. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  57501. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  57502. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  57503. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  57504. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  57505. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  57506. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57507. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  57508. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57509. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  57510. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  57511. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  57512. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  57513. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  57514. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  57515. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57516. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  57517. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  57518. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  57519. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57520. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57521. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  57522. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  57523. /** @hidden */
  57524. export var pbrPixelShader: {
  57525. name: string;
  57526. shader: string;
  57527. };
  57528. }
  57529. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  57530. /** @hidden */
  57531. export var pbrVertexDeclaration: {
  57532. name: string;
  57533. shader: string;
  57534. };
  57535. }
  57536. declare module "babylonjs/Shaders/pbr.vertex" {
  57537. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  57538. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57539. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57540. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57541. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57542. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57543. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  57544. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57545. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57546. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57547. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57548. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57549. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57550. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57551. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57552. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57553. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57554. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  57555. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57556. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57557. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57558. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57559. /** @hidden */
  57560. export var pbrVertexShader: {
  57561. name: string;
  57562. shader: string;
  57563. };
  57564. }
  57565. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  57566. import { Nullable } from "babylonjs/types";
  57567. import { Scene } from "babylonjs/scene";
  57568. import { Matrix } from "babylonjs/Maths/math.vector";
  57569. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57571. import { Mesh } from "babylonjs/Meshes/mesh";
  57572. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  57573. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  57574. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  57575. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  57576. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  57577. import { Color3 } from "babylonjs/Maths/math.color";
  57578. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57579. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  57580. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57581. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57582. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57583. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57584. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57585. import "babylonjs/Shaders/pbr.fragment";
  57586. import "babylonjs/Shaders/pbr.vertex";
  57587. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  57588. /**
  57589. * Manages the defines for the PBR Material.
  57590. * @hidden
  57591. */
  57592. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  57593. PBR: boolean;
  57594. NUM_SAMPLES: string;
  57595. REALTIME_FILTERING: boolean;
  57596. MAINUV1: boolean;
  57597. MAINUV2: boolean;
  57598. UV1: boolean;
  57599. UV2: boolean;
  57600. ALBEDO: boolean;
  57601. GAMMAALBEDO: boolean;
  57602. ALBEDODIRECTUV: number;
  57603. VERTEXCOLOR: boolean;
  57604. DETAIL: boolean;
  57605. DETAILDIRECTUV: number;
  57606. DETAIL_NORMALBLENDMETHOD: number;
  57607. AMBIENT: boolean;
  57608. AMBIENTDIRECTUV: number;
  57609. AMBIENTINGRAYSCALE: boolean;
  57610. OPACITY: boolean;
  57611. VERTEXALPHA: boolean;
  57612. OPACITYDIRECTUV: number;
  57613. OPACITYRGB: boolean;
  57614. ALPHATEST: boolean;
  57615. DEPTHPREPASS: boolean;
  57616. ALPHABLEND: boolean;
  57617. ALPHAFROMALBEDO: boolean;
  57618. ALPHATESTVALUE: string;
  57619. SPECULAROVERALPHA: boolean;
  57620. RADIANCEOVERALPHA: boolean;
  57621. ALPHAFRESNEL: boolean;
  57622. LINEARALPHAFRESNEL: boolean;
  57623. PREMULTIPLYALPHA: boolean;
  57624. EMISSIVE: boolean;
  57625. EMISSIVEDIRECTUV: number;
  57626. REFLECTIVITY: boolean;
  57627. REFLECTIVITYDIRECTUV: number;
  57628. SPECULARTERM: boolean;
  57629. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57630. MICROSURFACEAUTOMATIC: boolean;
  57631. LODBASEDMICROSFURACE: boolean;
  57632. MICROSURFACEMAP: boolean;
  57633. MICROSURFACEMAPDIRECTUV: number;
  57634. METALLICWORKFLOW: boolean;
  57635. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57636. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57637. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57638. AOSTOREINMETALMAPRED: boolean;
  57639. METALLIC_REFLECTANCE: boolean;
  57640. METALLIC_REFLECTANCEDIRECTUV: number;
  57641. ENVIRONMENTBRDF: boolean;
  57642. ENVIRONMENTBRDF_RGBD: boolean;
  57643. NORMAL: boolean;
  57644. TANGENT: boolean;
  57645. BUMP: boolean;
  57646. BUMPDIRECTUV: number;
  57647. OBJECTSPACE_NORMALMAP: boolean;
  57648. PARALLAX: boolean;
  57649. PARALLAXOCCLUSION: boolean;
  57650. NORMALXYSCALE: boolean;
  57651. LIGHTMAP: boolean;
  57652. LIGHTMAPDIRECTUV: number;
  57653. USELIGHTMAPASSHADOWMAP: boolean;
  57654. GAMMALIGHTMAP: boolean;
  57655. RGBDLIGHTMAP: boolean;
  57656. REFLECTION: boolean;
  57657. REFLECTIONMAP_3D: boolean;
  57658. REFLECTIONMAP_SPHERICAL: boolean;
  57659. REFLECTIONMAP_PLANAR: boolean;
  57660. REFLECTIONMAP_CUBIC: boolean;
  57661. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57662. REFLECTIONMAP_PROJECTION: boolean;
  57663. REFLECTIONMAP_SKYBOX: boolean;
  57664. REFLECTIONMAP_EXPLICIT: boolean;
  57665. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57666. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57667. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57668. INVERTCUBICMAP: boolean;
  57669. USESPHERICALFROMREFLECTIONMAP: boolean;
  57670. USEIRRADIANCEMAP: boolean;
  57671. SPHERICAL_HARMONICS: boolean;
  57672. USESPHERICALINVERTEX: boolean;
  57673. REFLECTIONMAP_OPPOSITEZ: boolean;
  57674. LODINREFLECTIONALPHA: boolean;
  57675. GAMMAREFLECTION: boolean;
  57676. RGBDREFLECTION: boolean;
  57677. LINEARSPECULARREFLECTION: boolean;
  57678. RADIANCEOCCLUSION: boolean;
  57679. HORIZONOCCLUSION: boolean;
  57680. INSTANCES: boolean;
  57681. THIN_INSTANCES: boolean;
  57682. PREPASS: boolean;
  57683. SCENE_MRT_COUNT: number;
  57684. NUM_BONE_INFLUENCERS: number;
  57685. BonesPerMesh: number;
  57686. BONETEXTURE: boolean;
  57687. NONUNIFORMSCALING: boolean;
  57688. MORPHTARGETS: boolean;
  57689. MORPHTARGETS_NORMAL: boolean;
  57690. MORPHTARGETS_TANGENT: boolean;
  57691. MORPHTARGETS_UV: boolean;
  57692. NUM_MORPH_INFLUENCERS: number;
  57693. IMAGEPROCESSING: boolean;
  57694. VIGNETTE: boolean;
  57695. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57696. VIGNETTEBLENDMODEOPAQUE: boolean;
  57697. TONEMAPPING: boolean;
  57698. TONEMAPPING_ACES: boolean;
  57699. CONTRAST: boolean;
  57700. COLORCURVES: boolean;
  57701. COLORGRADING: boolean;
  57702. COLORGRADING3D: boolean;
  57703. SAMPLER3DGREENDEPTH: boolean;
  57704. SAMPLER3DBGRMAP: boolean;
  57705. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57706. EXPOSURE: boolean;
  57707. MULTIVIEW: boolean;
  57708. USEPHYSICALLIGHTFALLOFF: boolean;
  57709. USEGLTFLIGHTFALLOFF: boolean;
  57710. TWOSIDEDLIGHTING: boolean;
  57711. SHADOWFLOAT: boolean;
  57712. CLIPPLANE: boolean;
  57713. CLIPPLANE2: boolean;
  57714. CLIPPLANE3: boolean;
  57715. CLIPPLANE4: boolean;
  57716. CLIPPLANE5: boolean;
  57717. CLIPPLANE6: boolean;
  57718. POINTSIZE: boolean;
  57719. FOG: boolean;
  57720. LOGARITHMICDEPTH: boolean;
  57721. FORCENORMALFORWARD: boolean;
  57722. SPECULARAA: boolean;
  57723. CLEARCOAT: boolean;
  57724. CLEARCOAT_DEFAULTIOR: boolean;
  57725. CLEARCOAT_TEXTURE: boolean;
  57726. CLEARCOAT_TEXTUREDIRECTUV: number;
  57727. CLEARCOAT_BUMP: boolean;
  57728. CLEARCOAT_BUMPDIRECTUV: number;
  57729. CLEARCOAT_TINT: boolean;
  57730. CLEARCOAT_TINT_TEXTURE: boolean;
  57731. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57732. ANISOTROPIC: boolean;
  57733. ANISOTROPIC_TEXTURE: boolean;
  57734. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57735. BRDF_V_HEIGHT_CORRELATED: boolean;
  57736. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57737. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57738. SHEEN: boolean;
  57739. SHEEN_TEXTURE: boolean;
  57740. SHEEN_TEXTUREDIRECTUV: number;
  57741. SHEEN_LINKWITHALBEDO: boolean;
  57742. SHEEN_ROUGHNESS: boolean;
  57743. SHEEN_ALBEDOSCALING: boolean;
  57744. SUBSURFACE: boolean;
  57745. SS_REFRACTION: boolean;
  57746. SS_TRANSLUCENCY: boolean;
  57747. SS_SCATTERING: boolean;
  57748. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57749. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57750. SS_REFRACTIONMAP_3D: boolean;
  57751. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57752. SS_LODINREFRACTIONALPHA: boolean;
  57753. SS_GAMMAREFRACTION: boolean;
  57754. SS_RGBDREFRACTION: boolean;
  57755. SS_LINEARSPECULARREFRACTION: boolean;
  57756. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57757. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57758. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57759. UNLIT: boolean;
  57760. DEBUGMODE: number;
  57761. /**
  57762. * Initializes the PBR Material defines.
  57763. */
  57764. constructor();
  57765. /**
  57766. * Resets the PBR Material defines.
  57767. */
  57768. reset(): void;
  57769. }
  57770. /**
  57771. * The Physically based material base class of BJS.
  57772. *
  57773. * This offers the main features of a standard PBR material.
  57774. * For more information, please refer to the documentation :
  57775. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57776. */
  57777. export abstract class PBRBaseMaterial extends PushMaterial {
  57778. /**
  57779. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57780. */
  57781. static readonly PBRMATERIAL_OPAQUE: number;
  57782. /**
  57783. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57784. */
  57785. static readonly PBRMATERIAL_ALPHATEST: number;
  57786. /**
  57787. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57788. */
  57789. static readonly PBRMATERIAL_ALPHABLEND: number;
  57790. /**
  57791. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57792. * They are also discarded below the alpha cutoff threshold to improve performances.
  57793. */
  57794. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57795. /**
  57796. * Defines the default value of how much AO map is occluding the analytical lights
  57797. * (point spot...).
  57798. */
  57799. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57800. /**
  57801. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57802. */
  57803. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57804. /**
  57805. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57806. * to enhance interoperability with other engines.
  57807. */
  57808. static readonly LIGHTFALLOFF_GLTF: number;
  57809. /**
  57810. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57811. * to enhance interoperability with other materials.
  57812. */
  57813. static readonly LIGHTFALLOFF_STANDARD: number;
  57814. /**
  57815. * Intensity of the direct lights e.g. the four lights available in your scene.
  57816. * This impacts both the direct diffuse and specular highlights.
  57817. */
  57818. protected _directIntensity: number;
  57819. /**
  57820. * Intensity of the emissive part of the material.
  57821. * This helps controlling the emissive effect without modifying the emissive color.
  57822. */
  57823. protected _emissiveIntensity: number;
  57824. /**
  57825. * Intensity of the environment e.g. how much the environment will light the object
  57826. * either through harmonics for rough material or through the refelction for shiny ones.
  57827. */
  57828. protected _environmentIntensity: number;
  57829. /**
  57830. * This is a special control allowing the reduction of the specular highlights coming from the
  57831. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57832. */
  57833. protected _specularIntensity: number;
  57834. /**
  57835. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57836. */
  57837. private _lightingInfos;
  57838. /**
  57839. * Debug Control allowing disabling the bump map on this material.
  57840. */
  57841. protected _disableBumpMap: boolean;
  57842. /**
  57843. * AKA Diffuse Texture in standard nomenclature.
  57844. */
  57845. protected _albedoTexture: Nullable<BaseTexture>;
  57846. /**
  57847. * AKA Occlusion Texture in other nomenclature.
  57848. */
  57849. protected _ambientTexture: Nullable<BaseTexture>;
  57850. /**
  57851. * AKA Occlusion Texture Intensity in other nomenclature.
  57852. */
  57853. protected _ambientTextureStrength: number;
  57854. /**
  57855. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57856. * 1 means it completely occludes it
  57857. * 0 mean it has no impact
  57858. */
  57859. protected _ambientTextureImpactOnAnalyticalLights: number;
  57860. /**
  57861. * Stores the alpha values in a texture.
  57862. */
  57863. protected _opacityTexture: Nullable<BaseTexture>;
  57864. /**
  57865. * Stores the reflection values in a texture.
  57866. */
  57867. protected _reflectionTexture: Nullable<BaseTexture>;
  57868. /**
  57869. * Stores the emissive values in a texture.
  57870. */
  57871. protected _emissiveTexture: Nullable<BaseTexture>;
  57872. /**
  57873. * AKA Specular texture in other nomenclature.
  57874. */
  57875. protected _reflectivityTexture: Nullable<BaseTexture>;
  57876. /**
  57877. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57878. */
  57879. protected _metallicTexture: Nullable<BaseTexture>;
  57880. /**
  57881. * Specifies the metallic scalar of the metallic/roughness workflow.
  57882. * Can also be used to scale the metalness values of the metallic texture.
  57883. */
  57884. protected _metallic: Nullable<number>;
  57885. /**
  57886. * Specifies the roughness scalar of the metallic/roughness workflow.
  57887. * Can also be used to scale the roughness values of the metallic texture.
  57888. */
  57889. protected _roughness: Nullable<number>;
  57890. /**
  57891. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57892. * By default the indexOfrefraction is used to compute F0;
  57893. *
  57894. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57895. *
  57896. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57897. * F90 = metallicReflectanceColor;
  57898. */
  57899. protected _metallicF0Factor: number;
  57900. /**
  57901. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57902. * By default the F90 is always 1;
  57903. *
  57904. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57905. *
  57906. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57907. * F90 = metallicReflectanceColor;
  57908. */
  57909. protected _metallicReflectanceColor: Color3;
  57910. /**
  57911. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57912. * This is multiply against the scalar values defined in the material.
  57913. */
  57914. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57915. /**
  57916. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57917. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57918. */
  57919. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57920. /**
  57921. * Stores surface normal data used to displace a mesh in a texture.
  57922. */
  57923. protected _bumpTexture: Nullable<BaseTexture>;
  57924. /**
  57925. * Stores the pre-calculated light information of a mesh in a texture.
  57926. */
  57927. protected _lightmapTexture: Nullable<BaseTexture>;
  57928. /**
  57929. * The color of a material in ambient lighting.
  57930. */
  57931. protected _ambientColor: Color3;
  57932. /**
  57933. * AKA Diffuse Color in other nomenclature.
  57934. */
  57935. protected _albedoColor: Color3;
  57936. /**
  57937. * AKA Specular Color in other nomenclature.
  57938. */
  57939. protected _reflectivityColor: Color3;
  57940. /**
  57941. * The color applied when light is reflected from a material.
  57942. */
  57943. protected _reflectionColor: Color3;
  57944. /**
  57945. * The color applied when light is emitted from a material.
  57946. */
  57947. protected _emissiveColor: Color3;
  57948. /**
  57949. * AKA Glossiness in other nomenclature.
  57950. */
  57951. protected _microSurface: number;
  57952. /**
  57953. * Specifies that the material will use the light map as a show map.
  57954. */
  57955. protected _useLightmapAsShadowmap: boolean;
  57956. /**
  57957. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57958. * makes the reflect vector face the model (under horizon).
  57959. */
  57960. protected _useHorizonOcclusion: boolean;
  57961. /**
  57962. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57963. * too much the area relying on ambient texture to define their ambient occlusion.
  57964. */
  57965. protected _useRadianceOcclusion: boolean;
  57966. /**
  57967. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57968. */
  57969. protected _useAlphaFromAlbedoTexture: boolean;
  57970. /**
  57971. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57972. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57973. */
  57974. protected _useSpecularOverAlpha: boolean;
  57975. /**
  57976. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57977. */
  57978. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57979. /**
  57980. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57981. */
  57982. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57983. /**
  57984. * Specifies if the metallic texture contains the roughness information in its green channel.
  57985. */
  57986. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57987. /**
  57988. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57989. */
  57990. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57991. /**
  57992. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57993. */
  57994. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57995. /**
  57996. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57997. */
  57998. protected _useAmbientInGrayScale: boolean;
  57999. /**
  58000. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58001. * The material will try to infer what glossiness each pixel should be.
  58002. */
  58003. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  58004. /**
  58005. * Defines the falloff type used in this material.
  58006. * It by default is Physical.
  58007. */
  58008. protected _lightFalloff: number;
  58009. /**
  58010. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58011. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58012. */
  58013. protected _useRadianceOverAlpha: boolean;
  58014. /**
  58015. * Allows using an object space normal map (instead of tangent space).
  58016. */
  58017. protected _useObjectSpaceNormalMap: boolean;
  58018. /**
  58019. * Allows using the bump map in parallax mode.
  58020. */
  58021. protected _useParallax: boolean;
  58022. /**
  58023. * Allows using the bump map in parallax occlusion mode.
  58024. */
  58025. protected _useParallaxOcclusion: boolean;
  58026. /**
  58027. * Controls the scale bias of the parallax mode.
  58028. */
  58029. protected _parallaxScaleBias: number;
  58030. /**
  58031. * If sets to true, disables all the lights affecting the material.
  58032. */
  58033. protected _disableLighting: boolean;
  58034. /**
  58035. * Number of Simultaneous lights allowed on the material.
  58036. */
  58037. protected _maxSimultaneousLights: number;
  58038. /**
  58039. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58040. */
  58041. protected _invertNormalMapX: boolean;
  58042. /**
  58043. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58044. */
  58045. protected _invertNormalMapY: boolean;
  58046. /**
  58047. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58048. */
  58049. protected _twoSidedLighting: boolean;
  58050. /**
  58051. * Defines the alpha limits in alpha test mode.
  58052. */
  58053. protected _alphaCutOff: number;
  58054. /**
  58055. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58056. */
  58057. protected _forceAlphaTest: boolean;
  58058. /**
  58059. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58060. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58061. */
  58062. protected _useAlphaFresnel: boolean;
  58063. /**
  58064. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58065. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58066. */
  58067. protected _useLinearAlphaFresnel: boolean;
  58068. /**
  58069. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  58070. * from cos thetav and roughness:
  58071. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  58072. */
  58073. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  58074. /**
  58075. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58076. */
  58077. protected _forceIrradianceInFragment: boolean;
  58078. private _realTimeFiltering;
  58079. /**
  58080. * Enables realtime filtering on the texture.
  58081. */
  58082. get realTimeFiltering(): boolean;
  58083. set realTimeFiltering(b: boolean);
  58084. private _realTimeFilteringQuality;
  58085. /**
  58086. * Quality switch for realtime filtering
  58087. */
  58088. get realTimeFilteringQuality(): number;
  58089. set realTimeFilteringQuality(n: number);
  58090. /**
  58091. * Should this material render to several textures at once
  58092. */
  58093. get shouldRenderToMRT(): boolean;
  58094. /**
  58095. * Force normal to face away from face.
  58096. */
  58097. protected _forceNormalForward: boolean;
  58098. /**
  58099. * Enables specular anti aliasing in the PBR shader.
  58100. * It will both interacts on the Geometry for analytical and IBL lighting.
  58101. * It also prefilter the roughness map based on the bump values.
  58102. */
  58103. protected _enableSpecularAntiAliasing: boolean;
  58104. /**
  58105. * Default configuration related to image processing available in the PBR Material.
  58106. */
  58107. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58108. /**
  58109. * Keep track of the image processing observer to allow dispose and replace.
  58110. */
  58111. private _imageProcessingObserver;
  58112. /**
  58113. * Attaches a new image processing configuration to the PBR Material.
  58114. * @param configuration
  58115. */
  58116. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58117. /**
  58118. * Stores the available render targets.
  58119. */
  58120. private _renderTargets;
  58121. /**
  58122. * Sets the global ambient color for the material used in lighting calculations.
  58123. */
  58124. private _globalAmbientColor;
  58125. /**
  58126. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  58127. */
  58128. private _useLogarithmicDepth;
  58129. /**
  58130. * If set to true, no lighting calculations will be applied.
  58131. */
  58132. private _unlit;
  58133. private _debugMode;
  58134. /**
  58135. * @hidden
  58136. * This is reserved for the inspector.
  58137. * Defines the material debug mode.
  58138. * It helps seeing only some components of the material while troubleshooting.
  58139. */
  58140. debugMode: number;
  58141. /**
  58142. * @hidden
  58143. * This is reserved for the inspector.
  58144. * Specify from where on screen the debug mode should start.
  58145. * The value goes from -1 (full screen) to 1 (not visible)
  58146. * It helps with side by side comparison against the final render
  58147. * This defaults to -1
  58148. */
  58149. private debugLimit;
  58150. /**
  58151. * @hidden
  58152. * This is reserved for the inspector.
  58153. * As the default viewing range might not be enough (if the ambient is really small for instance)
  58154. * You can use the factor to better multiply the final value.
  58155. */
  58156. private debugFactor;
  58157. /**
  58158. * Defines the clear coat layer parameters for the material.
  58159. */
  58160. readonly clearCoat: PBRClearCoatConfiguration;
  58161. /**
  58162. * Defines the anisotropic parameters for the material.
  58163. */
  58164. readonly anisotropy: PBRAnisotropicConfiguration;
  58165. /**
  58166. * Defines the BRDF parameters for the material.
  58167. */
  58168. readonly brdf: PBRBRDFConfiguration;
  58169. /**
  58170. * Defines the Sheen parameters for the material.
  58171. */
  58172. readonly sheen: PBRSheenConfiguration;
  58173. /**
  58174. * Defines the SubSurface parameters for the material.
  58175. */
  58176. readonly subSurface: PBRSubSurfaceConfiguration;
  58177. /**
  58178. * Defines the detail map parameters for the material.
  58179. */
  58180. readonly detailMap: DetailMapConfiguration;
  58181. protected _rebuildInParallel: boolean;
  58182. /**
  58183. * Instantiates a new PBRMaterial instance.
  58184. *
  58185. * @param name The material name
  58186. * @param scene The scene the material will be use in.
  58187. */
  58188. constructor(name: string, scene: Scene);
  58189. /**
  58190. * Gets a boolean indicating that current material needs to register RTT
  58191. */
  58192. get hasRenderTargetTextures(): boolean;
  58193. /**
  58194. * Gets the name of the material class.
  58195. */
  58196. getClassName(): string;
  58197. /**
  58198. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58199. */
  58200. get useLogarithmicDepth(): boolean;
  58201. /**
  58202. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58203. */
  58204. set useLogarithmicDepth(value: boolean);
  58205. /**
  58206. * Returns true if alpha blending should be disabled.
  58207. */
  58208. protected get _disableAlphaBlending(): boolean;
  58209. /**
  58210. * Specifies whether or not this material should be rendered in alpha blend mode.
  58211. */
  58212. needAlphaBlending(): boolean;
  58213. /**
  58214. * Specifies whether or not this material should be rendered in alpha test mode.
  58215. */
  58216. needAlphaTesting(): boolean;
  58217. /**
  58218. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58219. */
  58220. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58221. /**
  58222. * Gets the texture used for the alpha test.
  58223. */
  58224. getAlphaTestTexture(): Nullable<BaseTexture>;
  58225. /**
  58226. * Specifies that the submesh is ready to be used.
  58227. * @param mesh - BJS mesh.
  58228. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58229. * @param useInstances - Specifies that instances should be used.
  58230. * @returns - boolean indicating that the submesh is ready or not.
  58231. */
  58232. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58233. /**
  58234. * Specifies if the material uses metallic roughness workflow.
  58235. * @returns boolean specifiying if the material uses metallic roughness workflow.
  58236. */
  58237. isMetallicWorkflow(): boolean;
  58238. private _prepareEffect;
  58239. private _prepareDefines;
  58240. /**
  58241. * Force shader compilation
  58242. */
  58243. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  58244. /**
  58245. * Initializes the uniform buffer layout for the shader.
  58246. */
  58247. buildUniformLayout(): void;
  58248. /**
  58249. * Unbinds the material from the mesh
  58250. */
  58251. unbind(): void;
  58252. /**
  58253. * Binds the submesh data.
  58254. * @param world - The world matrix.
  58255. * @param mesh - The BJS mesh.
  58256. * @param subMesh - A submesh of the BJS mesh.
  58257. */
  58258. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58259. /**
  58260. * Returns the animatable textures.
  58261. * @returns - Array of animatable textures.
  58262. */
  58263. getAnimatables(): IAnimatable[];
  58264. /**
  58265. * Returns the texture used for reflections.
  58266. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  58267. */
  58268. private _getReflectionTexture;
  58269. /**
  58270. * Returns an array of the actively used textures.
  58271. * @returns - Array of BaseTextures
  58272. */
  58273. getActiveTextures(): BaseTexture[];
  58274. /**
  58275. * Checks to see if a texture is used in the material.
  58276. * @param texture - Base texture to use.
  58277. * @returns - Boolean specifying if a texture is used in the material.
  58278. */
  58279. hasTexture(texture: BaseTexture): boolean;
  58280. /**
  58281. * Disposes the resources of the material.
  58282. * @param forceDisposeEffect - Forces the disposal of effects.
  58283. * @param forceDisposeTextures - Forces the disposal of all textures.
  58284. */
  58285. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58286. }
  58287. }
  58288. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  58289. import { Nullable } from "babylonjs/types";
  58290. import { Scene } from "babylonjs/scene";
  58291. import { Color3 } from "babylonjs/Maths/math.color";
  58292. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  58293. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  58294. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58295. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58296. /**
  58297. * The Physically based material of BJS.
  58298. *
  58299. * This offers the main features of a standard PBR material.
  58300. * For more information, please refer to the documentation :
  58301. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58302. */
  58303. export class PBRMaterial extends PBRBaseMaterial {
  58304. /**
  58305. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58306. */
  58307. static readonly PBRMATERIAL_OPAQUE: number;
  58308. /**
  58309. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58310. */
  58311. static readonly PBRMATERIAL_ALPHATEST: number;
  58312. /**
  58313. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58314. */
  58315. static readonly PBRMATERIAL_ALPHABLEND: number;
  58316. /**
  58317. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58318. * They are also discarded below the alpha cutoff threshold to improve performances.
  58319. */
  58320. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58321. /**
  58322. * Defines the default value of how much AO map is occluding the analytical lights
  58323. * (point spot...).
  58324. */
  58325. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58326. /**
  58327. * Intensity of the direct lights e.g. the four lights available in your scene.
  58328. * This impacts both the direct diffuse and specular highlights.
  58329. */
  58330. directIntensity: number;
  58331. /**
  58332. * Intensity of the emissive part of the material.
  58333. * This helps controlling the emissive effect without modifying the emissive color.
  58334. */
  58335. emissiveIntensity: number;
  58336. /**
  58337. * Intensity of the environment e.g. how much the environment will light the object
  58338. * either through harmonics for rough material or through the refelction for shiny ones.
  58339. */
  58340. environmentIntensity: number;
  58341. /**
  58342. * This is a special control allowing the reduction of the specular highlights coming from the
  58343. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58344. */
  58345. specularIntensity: number;
  58346. /**
  58347. * Debug Control allowing disabling the bump map on this material.
  58348. */
  58349. disableBumpMap: boolean;
  58350. /**
  58351. * AKA Diffuse Texture in standard nomenclature.
  58352. */
  58353. albedoTexture: BaseTexture;
  58354. /**
  58355. * AKA Occlusion Texture in other nomenclature.
  58356. */
  58357. ambientTexture: BaseTexture;
  58358. /**
  58359. * AKA Occlusion Texture Intensity in other nomenclature.
  58360. */
  58361. ambientTextureStrength: number;
  58362. /**
  58363. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58364. * 1 means it completely occludes it
  58365. * 0 mean it has no impact
  58366. */
  58367. ambientTextureImpactOnAnalyticalLights: number;
  58368. /**
  58369. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  58370. */
  58371. opacityTexture: BaseTexture;
  58372. /**
  58373. * Stores the reflection values in a texture.
  58374. */
  58375. reflectionTexture: Nullable<BaseTexture>;
  58376. /**
  58377. * Stores the emissive values in a texture.
  58378. */
  58379. emissiveTexture: BaseTexture;
  58380. /**
  58381. * AKA Specular texture in other nomenclature.
  58382. */
  58383. reflectivityTexture: BaseTexture;
  58384. /**
  58385. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58386. */
  58387. metallicTexture: BaseTexture;
  58388. /**
  58389. * Specifies the metallic scalar of the metallic/roughness workflow.
  58390. * Can also be used to scale the metalness values of the metallic texture.
  58391. */
  58392. metallic: Nullable<number>;
  58393. /**
  58394. * Specifies the roughness scalar of the metallic/roughness workflow.
  58395. * Can also be used to scale the roughness values of the metallic texture.
  58396. */
  58397. roughness: Nullable<number>;
  58398. /**
  58399. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58400. * By default the indexOfrefraction is used to compute F0;
  58401. *
  58402. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58403. *
  58404. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58405. * F90 = metallicReflectanceColor;
  58406. */
  58407. metallicF0Factor: number;
  58408. /**
  58409. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58410. * By default the F90 is always 1;
  58411. *
  58412. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58413. *
  58414. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58415. * F90 = metallicReflectanceColor;
  58416. */
  58417. metallicReflectanceColor: Color3;
  58418. /**
  58419. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58420. * This is multiply against the scalar values defined in the material.
  58421. */
  58422. metallicReflectanceTexture: Nullable<BaseTexture>;
  58423. /**
  58424. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58425. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58426. */
  58427. microSurfaceTexture: BaseTexture;
  58428. /**
  58429. * Stores surface normal data used to displace a mesh in a texture.
  58430. */
  58431. bumpTexture: BaseTexture;
  58432. /**
  58433. * Stores the pre-calculated light information of a mesh in a texture.
  58434. */
  58435. lightmapTexture: BaseTexture;
  58436. /**
  58437. * Stores the refracted light information in a texture.
  58438. */
  58439. get refractionTexture(): Nullable<BaseTexture>;
  58440. set refractionTexture(value: Nullable<BaseTexture>);
  58441. /**
  58442. * The color of a material in ambient lighting.
  58443. */
  58444. ambientColor: Color3;
  58445. /**
  58446. * AKA Diffuse Color in other nomenclature.
  58447. */
  58448. albedoColor: Color3;
  58449. /**
  58450. * AKA Specular Color in other nomenclature.
  58451. */
  58452. reflectivityColor: Color3;
  58453. /**
  58454. * The color reflected from the material.
  58455. */
  58456. reflectionColor: Color3;
  58457. /**
  58458. * The color emitted from the material.
  58459. */
  58460. emissiveColor: Color3;
  58461. /**
  58462. * AKA Glossiness in other nomenclature.
  58463. */
  58464. microSurface: number;
  58465. /**
  58466. * Index of refraction of the material base layer.
  58467. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58468. *
  58469. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58470. *
  58471. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58472. */
  58473. get indexOfRefraction(): number;
  58474. set indexOfRefraction(value: number);
  58475. /**
  58476. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58477. */
  58478. get invertRefractionY(): boolean;
  58479. set invertRefractionY(value: boolean);
  58480. /**
  58481. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58482. * Materials half opaque for instance using refraction could benefit from this control.
  58483. */
  58484. get linkRefractionWithTransparency(): boolean;
  58485. set linkRefractionWithTransparency(value: boolean);
  58486. /**
  58487. * If true, the light map contains occlusion information instead of lighting info.
  58488. */
  58489. useLightmapAsShadowmap: boolean;
  58490. /**
  58491. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58492. */
  58493. useAlphaFromAlbedoTexture: boolean;
  58494. /**
  58495. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58496. */
  58497. forceAlphaTest: boolean;
  58498. /**
  58499. * Defines the alpha limits in alpha test mode.
  58500. */
  58501. alphaCutOff: number;
  58502. /**
  58503. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  58504. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58505. */
  58506. useSpecularOverAlpha: boolean;
  58507. /**
  58508. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58509. */
  58510. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58511. /**
  58512. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58513. */
  58514. useRoughnessFromMetallicTextureAlpha: boolean;
  58515. /**
  58516. * Specifies if the metallic texture contains the roughness information in its green channel.
  58517. */
  58518. useRoughnessFromMetallicTextureGreen: boolean;
  58519. /**
  58520. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58521. */
  58522. useMetallnessFromMetallicTextureBlue: boolean;
  58523. /**
  58524. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58525. */
  58526. useAmbientOcclusionFromMetallicTextureRed: boolean;
  58527. /**
  58528. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58529. */
  58530. useAmbientInGrayScale: boolean;
  58531. /**
  58532. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58533. * The material will try to infer what glossiness each pixel should be.
  58534. */
  58535. useAutoMicroSurfaceFromReflectivityMap: boolean;
  58536. /**
  58537. * BJS is using an harcoded light falloff based on a manually sets up range.
  58538. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58539. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58540. */
  58541. get usePhysicalLightFalloff(): boolean;
  58542. /**
  58543. * BJS is using an harcoded light falloff based on a manually sets up range.
  58544. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58545. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58546. */
  58547. set usePhysicalLightFalloff(value: boolean);
  58548. /**
  58549. * In order to support the falloff compatibility with gltf, a special mode has been added
  58550. * to reproduce the gltf light falloff.
  58551. */
  58552. get useGLTFLightFalloff(): boolean;
  58553. /**
  58554. * In order to support the falloff compatibility with gltf, a special mode has been added
  58555. * to reproduce the gltf light falloff.
  58556. */
  58557. set useGLTFLightFalloff(value: boolean);
  58558. /**
  58559. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58560. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58561. */
  58562. useRadianceOverAlpha: boolean;
  58563. /**
  58564. * Allows using an object space normal map (instead of tangent space).
  58565. */
  58566. useObjectSpaceNormalMap: boolean;
  58567. /**
  58568. * Allows using the bump map in parallax mode.
  58569. */
  58570. useParallax: boolean;
  58571. /**
  58572. * Allows using the bump map in parallax occlusion mode.
  58573. */
  58574. useParallaxOcclusion: boolean;
  58575. /**
  58576. * Controls the scale bias of the parallax mode.
  58577. */
  58578. parallaxScaleBias: number;
  58579. /**
  58580. * If sets to true, disables all the lights affecting the material.
  58581. */
  58582. disableLighting: boolean;
  58583. /**
  58584. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58585. */
  58586. forceIrradianceInFragment: boolean;
  58587. /**
  58588. * Number of Simultaneous lights allowed on the material.
  58589. */
  58590. maxSimultaneousLights: number;
  58591. /**
  58592. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58593. */
  58594. invertNormalMapX: boolean;
  58595. /**
  58596. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58597. */
  58598. invertNormalMapY: boolean;
  58599. /**
  58600. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58601. */
  58602. twoSidedLighting: boolean;
  58603. /**
  58604. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58605. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58606. */
  58607. useAlphaFresnel: boolean;
  58608. /**
  58609. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58610. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58611. */
  58612. useLinearAlphaFresnel: boolean;
  58613. /**
  58614. * Let user defines the brdf lookup texture used for IBL.
  58615. * A default 8bit version is embedded but you could point at :
  58616. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  58617. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  58618. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  58619. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  58620. */
  58621. environmentBRDFTexture: Nullable<BaseTexture>;
  58622. /**
  58623. * Force normal to face away from face.
  58624. */
  58625. forceNormalForward: boolean;
  58626. /**
  58627. * Enables specular anti aliasing in the PBR shader.
  58628. * It will both interacts on the Geometry for analytical and IBL lighting.
  58629. * It also prefilter the roughness map based on the bump values.
  58630. */
  58631. enableSpecularAntiAliasing: boolean;
  58632. /**
  58633. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58634. * makes the reflect vector face the model (under horizon).
  58635. */
  58636. useHorizonOcclusion: boolean;
  58637. /**
  58638. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58639. * too much the area relying on ambient texture to define their ambient occlusion.
  58640. */
  58641. useRadianceOcclusion: boolean;
  58642. /**
  58643. * If set to true, no lighting calculations will be applied.
  58644. */
  58645. unlit: boolean;
  58646. /**
  58647. * Gets the image processing configuration used either in this material.
  58648. */
  58649. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58650. /**
  58651. * Sets the Default image processing configuration used either in the this material.
  58652. *
  58653. * If sets to null, the scene one is in use.
  58654. */
  58655. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58656. /**
  58657. * Gets wether the color curves effect is enabled.
  58658. */
  58659. get cameraColorCurvesEnabled(): boolean;
  58660. /**
  58661. * Sets wether the color curves effect is enabled.
  58662. */
  58663. set cameraColorCurvesEnabled(value: boolean);
  58664. /**
  58665. * Gets wether the color grading effect is enabled.
  58666. */
  58667. get cameraColorGradingEnabled(): boolean;
  58668. /**
  58669. * Gets wether the color grading effect is enabled.
  58670. */
  58671. set cameraColorGradingEnabled(value: boolean);
  58672. /**
  58673. * Gets wether tonemapping is enabled or not.
  58674. */
  58675. get cameraToneMappingEnabled(): boolean;
  58676. /**
  58677. * Sets wether tonemapping is enabled or not
  58678. */
  58679. set cameraToneMappingEnabled(value: boolean);
  58680. /**
  58681. * The camera exposure used on this material.
  58682. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58683. * This corresponds to a photographic exposure.
  58684. */
  58685. get cameraExposure(): number;
  58686. /**
  58687. * The camera exposure used on this material.
  58688. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58689. * This corresponds to a photographic exposure.
  58690. */
  58691. set cameraExposure(value: number);
  58692. /**
  58693. * Gets The camera contrast used on this material.
  58694. */
  58695. get cameraContrast(): number;
  58696. /**
  58697. * Sets The camera contrast used on this material.
  58698. */
  58699. set cameraContrast(value: number);
  58700. /**
  58701. * Gets the Color Grading 2D Lookup Texture.
  58702. */
  58703. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58704. /**
  58705. * Sets the Color Grading 2D Lookup Texture.
  58706. */
  58707. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58708. /**
  58709. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58710. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58711. * 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;
  58712. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58713. */
  58714. get cameraColorCurves(): Nullable<ColorCurves>;
  58715. /**
  58716. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58717. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58718. * 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;
  58719. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58720. */
  58721. set cameraColorCurves(value: Nullable<ColorCurves>);
  58722. /**
  58723. * Instantiates a new PBRMaterial instance.
  58724. *
  58725. * @param name The material name
  58726. * @param scene The scene the material will be use in.
  58727. */
  58728. constructor(name: string, scene: Scene);
  58729. /**
  58730. * Returns the name of this material class.
  58731. */
  58732. getClassName(): string;
  58733. /**
  58734. * Makes a duplicate of the current material.
  58735. * @param name - name to use for the new material.
  58736. */
  58737. clone(name: string): PBRMaterial;
  58738. /**
  58739. * Serializes this PBR Material.
  58740. * @returns - An object with the serialized material.
  58741. */
  58742. serialize(): any;
  58743. /**
  58744. * Parses a PBR Material from a serialized object.
  58745. * @param source - Serialized object.
  58746. * @param scene - BJS scene instance.
  58747. * @param rootUrl - url for the scene object
  58748. * @returns - PBRMaterial
  58749. */
  58750. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58751. }
  58752. }
  58753. declare module "babylonjs/Misc/dds" {
  58754. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58755. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58756. import { Nullable } from "babylonjs/types";
  58757. import { Scene } from "babylonjs/scene";
  58758. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58759. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58760. /**
  58761. * Direct draw surface info
  58762. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58763. */
  58764. export interface DDSInfo {
  58765. /**
  58766. * Width of the texture
  58767. */
  58768. width: number;
  58769. /**
  58770. * Width of the texture
  58771. */
  58772. height: number;
  58773. /**
  58774. * Number of Mipmaps for the texture
  58775. * @see https://en.wikipedia.org/wiki/Mipmap
  58776. */
  58777. mipmapCount: number;
  58778. /**
  58779. * If the textures format is a known fourCC format
  58780. * @see https://www.fourcc.org/
  58781. */
  58782. isFourCC: boolean;
  58783. /**
  58784. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58785. */
  58786. isRGB: boolean;
  58787. /**
  58788. * If the texture is a lumincance format
  58789. */
  58790. isLuminance: boolean;
  58791. /**
  58792. * If this is a cube texture
  58793. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58794. */
  58795. isCube: boolean;
  58796. /**
  58797. * If the texture is a compressed format eg. FOURCC_DXT1
  58798. */
  58799. isCompressed: boolean;
  58800. /**
  58801. * The dxgiFormat of the texture
  58802. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58803. */
  58804. dxgiFormat: number;
  58805. /**
  58806. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58807. */
  58808. textureType: number;
  58809. /**
  58810. * Sphericle polynomial created for the dds texture
  58811. */
  58812. sphericalPolynomial?: SphericalPolynomial;
  58813. }
  58814. /**
  58815. * Class used to provide DDS decompression tools
  58816. */
  58817. export class DDSTools {
  58818. /**
  58819. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58820. */
  58821. static StoreLODInAlphaChannel: boolean;
  58822. /**
  58823. * Gets DDS information from an array buffer
  58824. * @param data defines the array buffer view to read data from
  58825. * @returns the DDS information
  58826. */
  58827. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58828. private static _FloatView;
  58829. private static _Int32View;
  58830. private static _ToHalfFloat;
  58831. private static _FromHalfFloat;
  58832. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58833. private static _GetHalfFloatRGBAArrayBuffer;
  58834. private static _GetFloatRGBAArrayBuffer;
  58835. private static _GetFloatAsUIntRGBAArrayBuffer;
  58836. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58837. private static _GetRGBAArrayBuffer;
  58838. private static _ExtractLongWordOrder;
  58839. private static _GetRGBArrayBuffer;
  58840. private static _GetLuminanceArrayBuffer;
  58841. /**
  58842. * Uploads DDS Levels to a Babylon Texture
  58843. * @hidden
  58844. */
  58845. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58846. }
  58847. module "babylonjs/Engines/thinEngine" {
  58848. interface ThinEngine {
  58849. /**
  58850. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58851. * @param rootUrl defines the url where the file to load is located
  58852. * @param scene defines the current scene
  58853. * @param lodScale defines scale to apply to the mip map selection
  58854. * @param lodOffset defines offset to apply to the mip map selection
  58855. * @param onLoad defines an optional callback raised when the texture is loaded
  58856. * @param onError defines an optional callback raised if there is an issue to load the texture
  58857. * @param format defines the format of the data
  58858. * @param forcedExtension defines the extension to use to pick the right loader
  58859. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58860. * @returns the cube texture as an InternalTexture
  58861. */
  58862. 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;
  58863. }
  58864. }
  58865. }
  58866. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58867. import { Nullable } from "babylonjs/types";
  58868. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58869. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58870. /**
  58871. * Implementation of the DDS Texture Loader.
  58872. * @hidden
  58873. */
  58874. export class _DDSTextureLoader implements IInternalTextureLoader {
  58875. /**
  58876. * Defines wether the loader supports cascade loading the different faces.
  58877. */
  58878. readonly supportCascades: boolean;
  58879. /**
  58880. * This returns if the loader support the current file information.
  58881. * @param extension defines the file extension of the file being loaded
  58882. * @returns true if the loader can load the specified file
  58883. */
  58884. canLoad(extension: string): boolean;
  58885. /**
  58886. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58887. * @param data contains the texture data
  58888. * @param texture defines the BabylonJS internal texture
  58889. * @param createPolynomials will be true if polynomials have been requested
  58890. * @param onLoad defines the callback to trigger once the texture is ready
  58891. * @param onError defines the callback to trigger in case of error
  58892. */
  58893. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58894. /**
  58895. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58896. * @param data contains the texture data
  58897. * @param texture defines the BabylonJS internal texture
  58898. * @param callback defines the method to call once ready to upload
  58899. */
  58900. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58901. }
  58902. }
  58903. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58904. import { Nullable } from "babylonjs/types";
  58905. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58906. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58907. /**
  58908. * Implementation of the ENV Texture Loader.
  58909. * @hidden
  58910. */
  58911. export class _ENVTextureLoader implements IInternalTextureLoader {
  58912. /**
  58913. * Defines wether the loader supports cascade loading the different faces.
  58914. */
  58915. readonly supportCascades: boolean;
  58916. /**
  58917. * This returns if the loader support the current file information.
  58918. * @param extension defines the file extension of the file being loaded
  58919. * @returns true if the loader can load the specified file
  58920. */
  58921. canLoad(extension: string): boolean;
  58922. /**
  58923. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58924. * @param data contains the texture data
  58925. * @param texture defines the BabylonJS internal texture
  58926. * @param createPolynomials will be true if polynomials have been requested
  58927. * @param onLoad defines the callback to trigger once the texture is ready
  58928. * @param onError defines the callback to trigger in case of error
  58929. */
  58930. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58931. /**
  58932. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58933. * @param data contains the texture data
  58934. * @param texture defines the BabylonJS internal texture
  58935. * @param callback defines the method to call once ready to upload
  58936. */
  58937. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58938. }
  58939. }
  58940. declare module "babylonjs/Misc/khronosTextureContainer" {
  58941. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58942. /**
  58943. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58944. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58945. */
  58946. export class KhronosTextureContainer {
  58947. /** contents of the KTX container file */
  58948. data: ArrayBufferView;
  58949. private static HEADER_LEN;
  58950. private static COMPRESSED_2D;
  58951. private static COMPRESSED_3D;
  58952. private static TEX_2D;
  58953. private static TEX_3D;
  58954. /**
  58955. * Gets the openGL type
  58956. */
  58957. glType: number;
  58958. /**
  58959. * Gets the openGL type size
  58960. */
  58961. glTypeSize: number;
  58962. /**
  58963. * Gets the openGL format
  58964. */
  58965. glFormat: number;
  58966. /**
  58967. * Gets the openGL internal format
  58968. */
  58969. glInternalFormat: number;
  58970. /**
  58971. * Gets the base internal format
  58972. */
  58973. glBaseInternalFormat: number;
  58974. /**
  58975. * Gets image width in pixel
  58976. */
  58977. pixelWidth: number;
  58978. /**
  58979. * Gets image height in pixel
  58980. */
  58981. pixelHeight: number;
  58982. /**
  58983. * Gets image depth in pixels
  58984. */
  58985. pixelDepth: number;
  58986. /**
  58987. * Gets the number of array elements
  58988. */
  58989. numberOfArrayElements: number;
  58990. /**
  58991. * Gets the number of faces
  58992. */
  58993. numberOfFaces: number;
  58994. /**
  58995. * Gets the number of mipmap levels
  58996. */
  58997. numberOfMipmapLevels: number;
  58998. /**
  58999. * Gets the bytes of key value data
  59000. */
  59001. bytesOfKeyValueData: number;
  59002. /**
  59003. * Gets the load type
  59004. */
  59005. loadType: number;
  59006. /**
  59007. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59008. */
  59009. isInvalid: boolean;
  59010. /**
  59011. * Creates a new KhronosTextureContainer
  59012. * @param data contents of the KTX container file
  59013. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59014. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59015. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59016. */
  59017. constructor(
  59018. /** contents of the KTX container file */
  59019. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59020. /**
  59021. * Uploads KTX content to a Babylon Texture.
  59022. * It is assumed that the texture has already been created & is currently bound
  59023. * @hidden
  59024. */
  59025. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59026. private _upload2DCompressedLevels;
  59027. /**
  59028. * Checks if the given data starts with a KTX file identifier.
  59029. * @param data the data to check
  59030. * @returns true if the data is a KTX file or false otherwise
  59031. */
  59032. static IsValid(data: ArrayBufferView): boolean;
  59033. }
  59034. }
  59035. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59036. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59037. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59038. /**
  59039. * Class for loading KTX2 files
  59040. * !!! Experimental Extension Subject to Changes !!!
  59041. * @hidden
  59042. */
  59043. export class KhronosTextureContainer2 {
  59044. private static _ModulePromise;
  59045. private static _TranscodeFormat;
  59046. constructor(engine: ThinEngine);
  59047. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  59048. private _determineTranscodeFormat;
  59049. /**
  59050. * Checks if the given data starts with a KTX2 file identifier.
  59051. * @param data the data to check
  59052. * @returns true if the data is a KTX2 file or false otherwise
  59053. */
  59054. static IsValid(data: ArrayBufferView): boolean;
  59055. }
  59056. }
  59057. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  59058. import { Nullable } from "babylonjs/types";
  59059. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59060. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59061. /**
  59062. * Implementation of the KTX Texture Loader.
  59063. * @hidden
  59064. */
  59065. export class _KTXTextureLoader implements IInternalTextureLoader {
  59066. /**
  59067. * Defines wether the loader supports cascade loading the different faces.
  59068. */
  59069. readonly supportCascades: boolean;
  59070. /**
  59071. * This returns if the loader support the current file information.
  59072. * @param extension defines the file extension of the file being loaded
  59073. * @param mimeType defines the optional mime type of the file being loaded
  59074. * @returns true if the loader can load the specified file
  59075. */
  59076. canLoad(extension: string, mimeType?: string): boolean;
  59077. /**
  59078. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59079. * @param data contains the texture data
  59080. * @param texture defines the BabylonJS internal texture
  59081. * @param createPolynomials will be true if polynomials have been requested
  59082. * @param onLoad defines the callback to trigger once the texture is ready
  59083. * @param onError defines the callback to trigger in case of error
  59084. */
  59085. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59086. /**
  59087. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59088. * @param data contains the texture data
  59089. * @param texture defines the BabylonJS internal texture
  59090. * @param callback defines the method to call once ready to upload
  59091. */
  59092. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59093. }
  59094. }
  59095. declare module "babylonjs/Helpers/sceneHelpers" {
  59096. import { Nullable } from "babylonjs/types";
  59097. import { Mesh } from "babylonjs/Meshes/mesh";
  59098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59099. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59100. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59101. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59102. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59103. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59104. import "babylonjs/Meshes/Builders/boxBuilder";
  59105. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  59106. /** @hidden */
  59107. export var _forceSceneHelpersToBundle: boolean;
  59108. module "babylonjs/scene" {
  59109. interface Scene {
  59110. /**
  59111. * Creates a default light for the scene.
  59112. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59113. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59114. */
  59115. createDefaultLight(replace?: boolean): void;
  59116. /**
  59117. * Creates a default camera for the scene.
  59118. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59119. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59120. * @param replace has default false, when true replaces the active camera in the scene
  59121. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59122. */
  59123. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59124. /**
  59125. * Creates a default camera and a default light.
  59126. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59127. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59128. * @param replace has the default false, when true replaces the active camera/light in the scene
  59129. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59130. */
  59131. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59132. /**
  59133. * Creates a new sky box
  59134. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59135. * @param environmentTexture defines the texture to use as environment texture
  59136. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59137. * @param scale defines the overall scale of the skybox
  59138. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59139. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59140. * @returns a new mesh holding the sky box
  59141. */
  59142. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59143. /**
  59144. * Creates a new environment
  59145. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59146. * @param options defines the options you can use to configure the environment
  59147. * @returns the new EnvironmentHelper
  59148. */
  59149. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59150. /**
  59151. * Creates a new VREXperienceHelper
  59152. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59153. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59154. * @returns a new VREXperienceHelper
  59155. */
  59156. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59157. /**
  59158. * Creates a new WebXRDefaultExperience
  59159. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59160. * @param options experience options
  59161. * @returns a promise for a new WebXRDefaultExperience
  59162. */
  59163. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59164. }
  59165. }
  59166. }
  59167. declare module "babylonjs/Helpers/videoDome" {
  59168. import { Scene } from "babylonjs/scene";
  59169. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59170. import { Mesh } from "babylonjs/Meshes/mesh";
  59171. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  59172. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  59173. import "babylonjs/Meshes/Builders/sphereBuilder";
  59174. /**
  59175. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59176. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59177. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59178. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59179. */
  59180. export class VideoDome extends TransformNode {
  59181. /**
  59182. * Define the video source as a Monoscopic panoramic 360 video.
  59183. */
  59184. static readonly MODE_MONOSCOPIC: number;
  59185. /**
  59186. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59187. */
  59188. static readonly MODE_TOPBOTTOM: number;
  59189. /**
  59190. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59191. */
  59192. static readonly MODE_SIDEBYSIDE: number;
  59193. private _halfDome;
  59194. private _useDirectMapping;
  59195. /**
  59196. * The video texture being displayed on the sphere
  59197. */
  59198. protected _videoTexture: VideoTexture;
  59199. /**
  59200. * Gets the video texture being displayed on the sphere
  59201. */
  59202. get videoTexture(): VideoTexture;
  59203. /**
  59204. * The skybox material
  59205. */
  59206. protected _material: BackgroundMaterial;
  59207. /**
  59208. * The surface used for the skybox
  59209. */
  59210. protected _mesh: Mesh;
  59211. /**
  59212. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59213. */
  59214. private _halfDomeMask;
  59215. /**
  59216. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59217. * Also see the options.resolution property.
  59218. */
  59219. get fovMultiplier(): number;
  59220. set fovMultiplier(value: number);
  59221. private _videoMode;
  59222. /**
  59223. * Gets or set the current video mode for the video. It can be:
  59224. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  59225. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59226. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59227. */
  59228. get videoMode(): number;
  59229. set videoMode(value: number);
  59230. /**
  59231. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  59232. *
  59233. */
  59234. get halfDome(): boolean;
  59235. /**
  59236. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  59237. */
  59238. set halfDome(enabled: boolean);
  59239. /**
  59240. * Oberserver used in Stereoscopic VR Mode.
  59241. */
  59242. private _onBeforeCameraRenderObserver;
  59243. /**
  59244. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  59245. * @param name Element's name, child elements will append suffixes for their own names.
  59246. * @param urlsOrVideo defines the url(s) or the video element to use
  59247. * @param options An object containing optional or exposed sub element properties
  59248. */
  59249. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  59250. resolution?: number;
  59251. clickToPlay?: boolean;
  59252. autoPlay?: boolean;
  59253. loop?: boolean;
  59254. size?: number;
  59255. poster?: string;
  59256. faceForward?: boolean;
  59257. useDirectMapping?: boolean;
  59258. halfDomeMode?: boolean;
  59259. }, scene: Scene);
  59260. private _changeVideoMode;
  59261. /**
  59262. * Releases resources associated with this node.
  59263. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59264. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59265. */
  59266. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59267. }
  59268. }
  59269. declare module "babylonjs/Helpers/index" {
  59270. export * from "babylonjs/Helpers/environmentHelper";
  59271. export * from "babylonjs/Helpers/photoDome";
  59272. export * from "babylonjs/Helpers/sceneHelpers";
  59273. export * from "babylonjs/Helpers/videoDome";
  59274. }
  59275. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  59276. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59277. import { IDisposable } from "babylonjs/scene";
  59278. import { Engine } from "babylonjs/Engines/engine";
  59279. /**
  59280. * This class can be used to get instrumentation data from a Babylon engine
  59281. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59282. */
  59283. export class EngineInstrumentation implements IDisposable {
  59284. /**
  59285. * Define the instrumented engine.
  59286. */
  59287. engine: Engine;
  59288. private _captureGPUFrameTime;
  59289. private _gpuFrameTimeToken;
  59290. private _gpuFrameTime;
  59291. private _captureShaderCompilationTime;
  59292. private _shaderCompilationTime;
  59293. private _onBeginFrameObserver;
  59294. private _onEndFrameObserver;
  59295. private _onBeforeShaderCompilationObserver;
  59296. private _onAfterShaderCompilationObserver;
  59297. /**
  59298. * Gets the perf counter used for GPU frame time
  59299. */
  59300. get gpuFrameTimeCounter(): PerfCounter;
  59301. /**
  59302. * Gets the GPU frame time capture status
  59303. */
  59304. get captureGPUFrameTime(): boolean;
  59305. /**
  59306. * Enable or disable the GPU frame time capture
  59307. */
  59308. set captureGPUFrameTime(value: boolean);
  59309. /**
  59310. * Gets the perf counter used for shader compilation time
  59311. */
  59312. get shaderCompilationTimeCounter(): PerfCounter;
  59313. /**
  59314. * Gets the shader compilation time capture status
  59315. */
  59316. get captureShaderCompilationTime(): boolean;
  59317. /**
  59318. * Enable or disable the shader compilation time capture
  59319. */
  59320. set captureShaderCompilationTime(value: boolean);
  59321. /**
  59322. * Instantiates a new engine instrumentation.
  59323. * This class can be used to get instrumentation data from a Babylon engine
  59324. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59325. * @param engine Defines the engine to instrument
  59326. */
  59327. constructor(
  59328. /**
  59329. * Define the instrumented engine.
  59330. */
  59331. engine: Engine);
  59332. /**
  59333. * Dispose and release associated resources.
  59334. */
  59335. dispose(): void;
  59336. }
  59337. }
  59338. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  59339. import { Scene, IDisposable } from "babylonjs/scene";
  59340. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59341. /**
  59342. * This class can be used to get instrumentation data from a Babylon engine
  59343. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59344. */
  59345. export class SceneInstrumentation implements IDisposable {
  59346. /**
  59347. * Defines the scene to instrument
  59348. */
  59349. scene: Scene;
  59350. private _captureActiveMeshesEvaluationTime;
  59351. private _activeMeshesEvaluationTime;
  59352. private _captureRenderTargetsRenderTime;
  59353. private _renderTargetsRenderTime;
  59354. private _captureFrameTime;
  59355. private _frameTime;
  59356. private _captureRenderTime;
  59357. private _renderTime;
  59358. private _captureInterFrameTime;
  59359. private _interFrameTime;
  59360. private _captureParticlesRenderTime;
  59361. private _particlesRenderTime;
  59362. private _captureSpritesRenderTime;
  59363. private _spritesRenderTime;
  59364. private _capturePhysicsTime;
  59365. private _physicsTime;
  59366. private _captureAnimationsTime;
  59367. private _animationsTime;
  59368. private _captureCameraRenderTime;
  59369. private _cameraRenderTime;
  59370. private _onBeforeActiveMeshesEvaluationObserver;
  59371. private _onAfterActiveMeshesEvaluationObserver;
  59372. private _onBeforeRenderTargetsRenderObserver;
  59373. private _onAfterRenderTargetsRenderObserver;
  59374. private _onAfterRenderObserver;
  59375. private _onBeforeDrawPhaseObserver;
  59376. private _onAfterDrawPhaseObserver;
  59377. private _onBeforeAnimationsObserver;
  59378. private _onBeforeParticlesRenderingObserver;
  59379. private _onAfterParticlesRenderingObserver;
  59380. private _onBeforeSpritesRenderingObserver;
  59381. private _onAfterSpritesRenderingObserver;
  59382. private _onBeforePhysicsObserver;
  59383. private _onAfterPhysicsObserver;
  59384. private _onAfterAnimationsObserver;
  59385. private _onBeforeCameraRenderObserver;
  59386. private _onAfterCameraRenderObserver;
  59387. /**
  59388. * Gets the perf counter used for active meshes evaluation time
  59389. */
  59390. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59391. /**
  59392. * Gets the active meshes evaluation time capture status
  59393. */
  59394. get captureActiveMeshesEvaluationTime(): boolean;
  59395. /**
  59396. * Enable or disable the active meshes evaluation time capture
  59397. */
  59398. set captureActiveMeshesEvaluationTime(value: boolean);
  59399. /**
  59400. * Gets the perf counter used for render targets render time
  59401. */
  59402. get renderTargetsRenderTimeCounter(): PerfCounter;
  59403. /**
  59404. * Gets the render targets render time capture status
  59405. */
  59406. get captureRenderTargetsRenderTime(): boolean;
  59407. /**
  59408. * Enable or disable the render targets render time capture
  59409. */
  59410. set captureRenderTargetsRenderTime(value: boolean);
  59411. /**
  59412. * Gets the perf counter used for particles render time
  59413. */
  59414. get particlesRenderTimeCounter(): PerfCounter;
  59415. /**
  59416. * Gets the particles render time capture status
  59417. */
  59418. get captureParticlesRenderTime(): boolean;
  59419. /**
  59420. * Enable or disable the particles render time capture
  59421. */
  59422. set captureParticlesRenderTime(value: boolean);
  59423. /**
  59424. * Gets the perf counter used for sprites render time
  59425. */
  59426. get spritesRenderTimeCounter(): PerfCounter;
  59427. /**
  59428. * Gets the sprites render time capture status
  59429. */
  59430. get captureSpritesRenderTime(): boolean;
  59431. /**
  59432. * Enable or disable the sprites render time capture
  59433. */
  59434. set captureSpritesRenderTime(value: boolean);
  59435. /**
  59436. * Gets the perf counter used for physics time
  59437. */
  59438. get physicsTimeCounter(): PerfCounter;
  59439. /**
  59440. * Gets the physics time capture status
  59441. */
  59442. get capturePhysicsTime(): boolean;
  59443. /**
  59444. * Enable or disable the physics time capture
  59445. */
  59446. set capturePhysicsTime(value: boolean);
  59447. /**
  59448. * Gets the perf counter used for animations time
  59449. */
  59450. get animationsTimeCounter(): PerfCounter;
  59451. /**
  59452. * Gets the animations time capture status
  59453. */
  59454. get captureAnimationsTime(): boolean;
  59455. /**
  59456. * Enable or disable the animations time capture
  59457. */
  59458. set captureAnimationsTime(value: boolean);
  59459. /**
  59460. * Gets the perf counter used for frame time capture
  59461. */
  59462. get frameTimeCounter(): PerfCounter;
  59463. /**
  59464. * Gets the frame time capture status
  59465. */
  59466. get captureFrameTime(): boolean;
  59467. /**
  59468. * Enable or disable the frame time capture
  59469. */
  59470. set captureFrameTime(value: boolean);
  59471. /**
  59472. * Gets the perf counter used for inter-frames time capture
  59473. */
  59474. get interFrameTimeCounter(): PerfCounter;
  59475. /**
  59476. * Gets the inter-frames time capture status
  59477. */
  59478. get captureInterFrameTime(): boolean;
  59479. /**
  59480. * Enable or disable the inter-frames time capture
  59481. */
  59482. set captureInterFrameTime(value: boolean);
  59483. /**
  59484. * Gets the perf counter used for render time capture
  59485. */
  59486. get renderTimeCounter(): PerfCounter;
  59487. /**
  59488. * Gets the render time capture status
  59489. */
  59490. get captureRenderTime(): boolean;
  59491. /**
  59492. * Enable or disable the render time capture
  59493. */
  59494. set captureRenderTime(value: boolean);
  59495. /**
  59496. * Gets the perf counter used for camera render time capture
  59497. */
  59498. get cameraRenderTimeCounter(): PerfCounter;
  59499. /**
  59500. * Gets the camera render time capture status
  59501. */
  59502. get captureCameraRenderTime(): boolean;
  59503. /**
  59504. * Enable or disable the camera render time capture
  59505. */
  59506. set captureCameraRenderTime(value: boolean);
  59507. /**
  59508. * Gets the perf counter used for draw calls
  59509. */
  59510. get drawCallsCounter(): PerfCounter;
  59511. /**
  59512. * Instantiates a new scene instrumentation.
  59513. * This class can be used to get instrumentation data from a Babylon engine
  59514. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59515. * @param scene Defines the scene to instrument
  59516. */
  59517. constructor(
  59518. /**
  59519. * Defines the scene to instrument
  59520. */
  59521. scene: Scene);
  59522. /**
  59523. * Dispose and release associated resources.
  59524. */
  59525. dispose(): void;
  59526. }
  59527. }
  59528. declare module "babylonjs/Instrumentation/index" {
  59529. export * from "babylonjs/Instrumentation/engineInstrumentation";
  59530. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  59531. export * from "babylonjs/Instrumentation/timeToken";
  59532. }
  59533. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  59534. /** @hidden */
  59535. export var glowMapGenerationPixelShader: {
  59536. name: string;
  59537. shader: string;
  59538. };
  59539. }
  59540. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  59541. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59542. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59543. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59544. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59545. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59546. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59547. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59548. /** @hidden */
  59549. export var glowMapGenerationVertexShader: {
  59550. name: string;
  59551. shader: string;
  59552. };
  59553. }
  59554. declare module "babylonjs/Layers/effectLayer" {
  59555. import { Observable } from "babylonjs/Misc/observable";
  59556. import { Nullable } from "babylonjs/types";
  59557. import { Camera } from "babylonjs/Cameras/camera";
  59558. import { Scene } from "babylonjs/scene";
  59559. import { ISize } from "babylonjs/Maths/math.size";
  59560. import { Color4 } from "babylonjs/Maths/math.color";
  59561. import { Engine } from "babylonjs/Engines/engine";
  59562. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59564. import { Mesh } from "babylonjs/Meshes/mesh";
  59565. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59566. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59567. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59568. import { Effect } from "babylonjs/Materials/effect";
  59569. import { Material } from "babylonjs/Materials/material";
  59570. import "babylonjs/Shaders/glowMapGeneration.fragment";
  59571. import "babylonjs/Shaders/glowMapGeneration.vertex";
  59572. /**
  59573. * Effect layer options. This helps customizing the behaviour
  59574. * of the effect layer.
  59575. */
  59576. export interface IEffectLayerOptions {
  59577. /**
  59578. * Multiplication factor apply to the canvas size to compute the render target size
  59579. * used to generated the objects (the smaller the faster).
  59580. */
  59581. mainTextureRatio: number;
  59582. /**
  59583. * Enforces a fixed size texture to ensure effect stability across devices.
  59584. */
  59585. mainTextureFixedSize?: number;
  59586. /**
  59587. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59588. */
  59589. alphaBlendingMode: number;
  59590. /**
  59591. * The camera attached to the layer.
  59592. */
  59593. camera: Nullable<Camera>;
  59594. /**
  59595. * The rendering group to draw the layer in.
  59596. */
  59597. renderingGroupId: number;
  59598. }
  59599. /**
  59600. * The effect layer Helps adding post process effect blended with the main pass.
  59601. *
  59602. * This can be for instance use to generate glow or higlight effects on the scene.
  59603. *
  59604. * The effect layer class can not be used directly and is intented to inherited from to be
  59605. * customized per effects.
  59606. */
  59607. export abstract class EffectLayer {
  59608. private _vertexBuffers;
  59609. private _indexBuffer;
  59610. private _cachedDefines;
  59611. private _effectLayerMapGenerationEffect;
  59612. private _effectLayerOptions;
  59613. private _mergeEffect;
  59614. protected _scene: Scene;
  59615. protected _engine: Engine;
  59616. protected _maxSize: number;
  59617. protected _mainTextureDesiredSize: ISize;
  59618. protected _mainTexture: RenderTargetTexture;
  59619. protected _shouldRender: boolean;
  59620. protected _postProcesses: PostProcess[];
  59621. protected _textures: BaseTexture[];
  59622. protected _emissiveTextureAndColor: {
  59623. texture: Nullable<BaseTexture>;
  59624. color: Color4;
  59625. };
  59626. /**
  59627. * The name of the layer
  59628. */
  59629. name: string;
  59630. /**
  59631. * The clear color of the texture used to generate the glow map.
  59632. */
  59633. neutralColor: Color4;
  59634. /**
  59635. * Specifies whether the highlight layer is enabled or not.
  59636. */
  59637. isEnabled: boolean;
  59638. /**
  59639. * Gets the camera attached to the layer.
  59640. */
  59641. get camera(): Nullable<Camera>;
  59642. /**
  59643. * Gets the rendering group id the layer should render in.
  59644. */
  59645. get renderingGroupId(): number;
  59646. set renderingGroupId(renderingGroupId: number);
  59647. /**
  59648. * An event triggered when the effect layer has been disposed.
  59649. */
  59650. onDisposeObservable: Observable<EffectLayer>;
  59651. /**
  59652. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59653. */
  59654. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59655. /**
  59656. * An event triggered when the generated texture is being merged in the scene.
  59657. */
  59658. onBeforeComposeObservable: Observable<EffectLayer>;
  59659. /**
  59660. * An event triggered when the mesh is rendered into the effect render target.
  59661. */
  59662. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59663. /**
  59664. * An event triggered after the mesh has been rendered into the effect render target.
  59665. */
  59666. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59667. /**
  59668. * An event triggered when the generated texture has been merged in the scene.
  59669. */
  59670. onAfterComposeObservable: Observable<EffectLayer>;
  59671. /**
  59672. * An event triggered when the efffect layer changes its size.
  59673. */
  59674. onSizeChangedObservable: Observable<EffectLayer>;
  59675. /** @hidden */
  59676. static _SceneComponentInitialization: (scene: Scene) => void;
  59677. /**
  59678. * Instantiates a new effect Layer and references it in the scene.
  59679. * @param name The name of the layer
  59680. * @param scene The scene to use the layer in
  59681. */
  59682. constructor(
  59683. /** The Friendly of the effect in the scene */
  59684. name: string, scene: Scene);
  59685. /**
  59686. * Get the effect name of the layer.
  59687. * @return The effect name
  59688. */
  59689. abstract getEffectName(): string;
  59690. /**
  59691. * Checks for the readiness of the element composing the layer.
  59692. * @param subMesh the mesh to check for
  59693. * @param useInstances specify whether or not to use instances to render the mesh
  59694. * @return true if ready otherwise, false
  59695. */
  59696. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59697. /**
  59698. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59699. * @returns true if the effect requires stencil during the main canvas render pass.
  59700. */
  59701. abstract needStencil(): boolean;
  59702. /**
  59703. * Create the merge effect. This is the shader use to blit the information back
  59704. * to the main canvas at the end of the scene rendering.
  59705. * @returns The effect containing the shader used to merge the effect on the main canvas
  59706. */
  59707. protected abstract _createMergeEffect(): Effect;
  59708. /**
  59709. * Creates the render target textures and post processes used in the effect layer.
  59710. */
  59711. protected abstract _createTextureAndPostProcesses(): void;
  59712. /**
  59713. * Implementation specific of rendering the generating effect on the main canvas.
  59714. * @param effect The effect used to render through
  59715. */
  59716. protected abstract _internalRender(effect: Effect): void;
  59717. /**
  59718. * Sets the required values for both the emissive texture and and the main color.
  59719. */
  59720. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59721. /**
  59722. * Free any resources and references associated to a mesh.
  59723. * Internal use
  59724. * @param mesh The mesh to free.
  59725. */
  59726. abstract _disposeMesh(mesh: Mesh): void;
  59727. /**
  59728. * Serializes this layer (Glow or Highlight for example)
  59729. * @returns a serialized layer object
  59730. */
  59731. abstract serialize?(): any;
  59732. /**
  59733. * Initializes the effect layer with the required options.
  59734. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59735. */
  59736. protected _init(options: Partial<IEffectLayerOptions>): void;
  59737. /**
  59738. * Generates the index buffer of the full screen quad blending to the main canvas.
  59739. */
  59740. private _generateIndexBuffer;
  59741. /**
  59742. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59743. */
  59744. private _generateVertexBuffer;
  59745. /**
  59746. * Sets the main texture desired size which is the closest power of two
  59747. * of the engine canvas size.
  59748. */
  59749. private _setMainTextureSize;
  59750. /**
  59751. * Creates the main texture for the effect layer.
  59752. */
  59753. protected _createMainTexture(): void;
  59754. /**
  59755. * Adds specific effects defines.
  59756. * @param defines The defines to add specifics to.
  59757. */
  59758. protected _addCustomEffectDefines(defines: string[]): void;
  59759. /**
  59760. * Checks for the readiness of the element composing the layer.
  59761. * @param subMesh the mesh to check for
  59762. * @param useInstances specify whether or not to use instances to render the mesh
  59763. * @param emissiveTexture the associated emissive texture used to generate the glow
  59764. * @return true if ready otherwise, false
  59765. */
  59766. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59767. /**
  59768. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59769. */
  59770. render(): void;
  59771. /**
  59772. * Determine if a given mesh will be used in the current effect.
  59773. * @param mesh mesh to test
  59774. * @returns true if the mesh will be used
  59775. */
  59776. hasMesh(mesh: AbstractMesh): boolean;
  59777. /**
  59778. * Returns true if the layer contains information to display, otherwise false.
  59779. * @returns true if the glow layer should be rendered
  59780. */
  59781. shouldRender(): boolean;
  59782. /**
  59783. * Returns true if the mesh should render, otherwise false.
  59784. * @param mesh The mesh to render
  59785. * @returns true if it should render otherwise false
  59786. */
  59787. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59788. /**
  59789. * Returns true if the mesh can be rendered, otherwise false.
  59790. * @param mesh The mesh to render
  59791. * @param material The material used on the mesh
  59792. * @returns true if it can be rendered otherwise false
  59793. */
  59794. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59795. /**
  59796. * Returns true if the mesh should render, otherwise false.
  59797. * @param mesh The mesh to render
  59798. * @returns true if it should render otherwise false
  59799. */
  59800. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59801. /**
  59802. * Renders the submesh passed in parameter to the generation map.
  59803. */
  59804. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59805. /**
  59806. * Defines whether the current material of the mesh should be use to render the effect.
  59807. * @param mesh defines the current mesh to render
  59808. */
  59809. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59810. /**
  59811. * Rebuild the required buffers.
  59812. * @hidden Internal use only.
  59813. */
  59814. _rebuild(): void;
  59815. /**
  59816. * Dispose only the render target textures and post process.
  59817. */
  59818. private _disposeTextureAndPostProcesses;
  59819. /**
  59820. * Dispose the highlight layer and free resources.
  59821. */
  59822. dispose(): void;
  59823. /**
  59824. * Gets the class name of the effect layer
  59825. * @returns the string with the class name of the effect layer
  59826. */
  59827. getClassName(): string;
  59828. /**
  59829. * Creates an effect layer from parsed effect layer data
  59830. * @param parsedEffectLayer defines effect layer data
  59831. * @param scene defines the current scene
  59832. * @param rootUrl defines the root URL containing the effect layer information
  59833. * @returns a parsed effect Layer
  59834. */
  59835. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59836. }
  59837. }
  59838. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59839. import { Scene } from "babylonjs/scene";
  59840. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59841. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59842. import { AbstractScene } from "babylonjs/abstractScene";
  59843. module "babylonjs/abstractScene" {
  59844. interface AbstractScene {
  59845. /**
  59846. * The list of effect layers (highlights/glow) added to the scene
  59847. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59848. * @see https://doc.babylonjs.com/how_to/glow_layer
  59849. */
  59850. effectLayers: Array<EffectLayer>;
  59851. /**
  59852. * Removes the given effect layer from this scene.
  59853. * @param toRemove defines the effect layer to remove
  59854. * @returns the index of the removed effect layer
  59855. */
  59856. removeEffectLayer(toRemove: EffectLayer): number;
  59857. /**
  59858. * Adds the given effect layer to this scene
  59859. * @param newEffectLayer defines the effect layer to add
  59860. */
  59861. addEffectLayer(newEffectLayer: EffectLayer): void;
  59862. }
  59863. }
  59864. /**
  59865. * Defines the layer scene component responsible to manage any effect layers
  59866. * in a given scene.
  59867. */
  59868. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59869. /**
  59870. * The component name helpfull to identify the component in the list of scene components.
  59871. */
  59872. readonly name: string;
  59873. /**
  59874. * The scene the component belongs to.
  59875. */
  59876. scene: Scene;
  59877. private _engine;
  59878. private _renderEffects;
  59879. private _needStencil;
  59880. private _previousStencilState;
  59881. /**
  59882. * Creates a new instance of the component for the given scene
  59883. * @param scene Defines the scene to register the component in
  59884. */
  59885. constructor(scene: Scene);
  59886. /**
  59887. * Registers the component in a given scene
  59888. */
  59889. register(): void;
  59890. /**
  59891. * Rebuilds the elements related to this component in case of
  59892. * context lost for instance.
  59893. */
  59894. rebuild(): void;
  59895. /**
  59896. * Serializes the component data to the specified json object
  59897. * @param serializationObject The object to serialize to
  59898. */
  59899. serialize(serializationObject: any): void;
  59900. /**
  59901. * Adds all the elements from the container to the scene
  59902. * @param container the container holding the elements
  59903. */
  59904. addFromContainer(container: AbstractScene): void;
  59905. /**
  59906. * Removes all the elements in the container from the scene
  59907. * @param container contains the elements to remove
  59908. * @param dispose if the removed element should be disposed (default: false)
  59909. */
  59910. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59911. /**
  59912. * Disposes the component and the associated ressources.
  59913. */
  59914. dispose(): void;
  59915. private _isReadyForMesh;
  59916. private _renderMainTexture;
  59917. private _setStencil;
  59918. private _setStencilBack;
  59919. private _draw;
  59920. private _drawCamera;
  59921. private _drawRenderingGroup;
  59922. }
  59923. }
  59924. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59925. /** @hidden */
  59926. export var glowMapMergePixelShader: {
  59927. name: string;
  59928. shader: string;
  59929. };
  59930. }
  59931. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59932. /** @hidden */
  59933. export var glowMapMergeVertexShader: {
  59934. name: string;
  59935. shader: string;
  59936. };
  59937. }
  59938. declare module "babylonjs/Layers/glowLayer" {
  59939. import { Nullable } from "babylonjs/types";
  59940. import { Camera } from "babylonjs/Cameras/camera";
  59941. import { Scene } from "babylonjs/scene";
  59942. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59944. import { Mesh } from "babylonjs/Meshes/mesh";
  59945. import { Texture } from "babylonjs/Materials/Textures/texture";
  59946. import { Effect } from "babylonjs/Materials/effect";
  59947. import { Material } from "babylonjs/Materials/material";
  59948. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59949. import { Color4 } from "babylonjs/Maths/math.color";
  59950. import "babylonjs/Shaders/glowMapMerge.fragment";
  59951. import "babylonjs/Shaders/glowMapMerge.vertex";
  59952. import "babylonjs/Layers/effectLayerSceneComponent";
  59953. module "babylonjs/abstractScene" {
  59954. interface AbstractScene {
  59955. /**
  59956. * Return a the first highlight layer of the scene with a given name.
  59957. * @param name The name of the highlight layer to look for.
  59958. * @return The highlight layer if found otherwise null.
  59959. */
  59960. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59961. }
  59962. }
  59963. /**
  59964. * Glow layer options. This helps customizing the behaviour
  59965. * of the glow layer.
  59966. */
  59967. export interface IGlowLayerOptions {
  59968. /**
  59969. * Multiplication factor apply to the canvas size to compute the render target size
  59970. * used to generated the glowing objects (the smaller the faster).
  59971. */
  59972. mainTextureRatio: number;
  59973. /**
  59974. * Enforces a fixed size texture to ensure resize independant blur.
  59975. */
  59976. mainTextureFixedSize?: number;
  59977. /**
  59978. * How big is the kernel of the blur texture.
  59979. */
  59980. blurKernelSize: number;
  59981. /**
  59982. * The camera attached to the layer.
  59983. */
  59984. camera: Nullable<Camera>;
  59985. /**
  59986. * Enable MSAA by chosing the number of samples.
  59987. */
  59988. mainTextureSamples?: number;
  59989. /**
  59990. * The rendering group to draw the layer in.
  59991. */
  59992. renderingGroupId: number;
  59993. }
  59994. /**
  59995. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59996. *
  59997. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59998. *
  59999. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60000. */
  60001. export class GlowLayer extends EffectLayer {
  60002. /**
  60003. * Effect Name of the layer.
  60004. */
  60005. static readonly EffectName: string;
  60006. /**
  60007. * The default blur kernel size used for the glow.
  60008. */
  60009. static DefaultBlurKernelSize: number;
  60010. /**
  60011. * The default texture size ratio used for the glow.
  60012. */
  60013. static DefaultTextureRatio: number;
  60014. /**
  60015. * Sets the kernel size of the blur.
  60016. */
  60017. set blurKernelSize(value: number);
  60018. /**
  60019. * Gets the kernel size of the blur.
  60020. */
  60021. get blurKernelSize(): number;
  60022. /**
  60023. * Sets the glow intensity.
  60024. */
  60025. set intensity(value: number);
  60026. /**
  60027. * Gets the glow intensity.
  60028. */
  60029. get intensity(): number;
  60030. private _options;
  60031. private _intensity;
  60032. private _horizontalBlurPostprocess1;
  60033. private _verticalBlurPostprocess1;
  60034. private _horizontalBlurPostprocess2;
  60035. private _verticalBlurPostprocess2;
  60036. private _blurTexture1;
  60037. private _blurTexture2;
  60038. private _postProcesses1;
  60039. private _postProcesses2;
  60040. private _includedOnlyMeshes;
  60041. private _excludedMeshes;
  60042. private _meshesUsingTheirOwnMaterials;
  60043. /**
  60044. * Callback used to let the user override the color selection on a per mesh basis
  60045. */
  60046. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60047. /**
  60048. * Callback used to let the user override the texture selection on a per mesh basis
  60049. */
  60050. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60051. /**
  60052. * Instantiates a new glow Layer and references it to the scene.
  60053. * @param name The name of the layer
  60054. * @param scene The scene to use the layer in
  60055. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60056. */
  60057. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60058. /**
  60059. * Get the effect name of the layer.
  60060. * @return The effect name
  60061. */
  60062. getEffectName(): string;
  60063. /**
  60064. * Create the merge effect. This is the shader use to blit the information back
  60065. * to the main canvas at the end of the scene rendering.
  60066. */
  60067. protected _createMergeEffect(): Effect;
  60068. /**
  60069. * Creates the render target textures and post processes used in the glow layer.
  60070. */
  60071. protected _createTextureAndPostProcesses(): void;
  60072. /**
  60073. * Checks for the readiness of the element composing the layer.
  60074. * @param subMesh the mesh to check for
  60075. * @param useInstances specify wether or not to use instances to render the mesh
  60076. * @param emissiveTexture the associated emissive texture used to generate the glow
  60077. * @return true if ready otherwise, false
  60078. */
  60079. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60080. /**
  60081. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60082. */
  60083. needStencil(): boolean;
  60084. /**
  60085. * Returns true if the mesh can be rendered, otherwise false.
  60086. * @param mesh The mesh to render
  60087. * @param material The material used on the mesh
  60088. * @returns true if it can be rendered otherwise false
  60089. */
  60090. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60091. /**
  60092. * Implementation specific of rendering the generating effect on the main canvas.
  60093. * @param effect The effect used to render through
  60094. */
  60095. protected _internalRender(effect: Effect): void;
  60096. /**
  60097. * Sets the required values for both the emissive texture and and the main color.
  60098. */
  60099. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60100. /**
  60101. * Returns true if the mesh should render, otherwise false.
  60102. * @param mesh The mesh to render
  60103. * @returns true if it should render otherwise false
  60104. */
  60105. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60106. /**
  60107. * Adds specific effects defines.
  60108. * @param defines The defines to add specifics to.
  60109. */
  60110. protected _addCustomEffectDefines(defines: string[]): void;
  60111. /**
  60112. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60113. * @param mesh The mesh to exclude from the glow layer
  60114. */
  60115. addExcludedMesh(mesh: Mesh): void;
  60116. /**
  60117. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60118. * @param mesh The mesh to remove
  60119. */
  60120. removeExcludedMesh(mesh: Mesh): void;
  60121. /**
  60122. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60123. * @param mesh The mesh to include in the glow layer
  60124. */
  60125. addIncludedOnlyMesh(mesh: Mesh): void;
  60126. /**
  60127. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60128. * @param mesh The mesh to remove
  60129. */
  60130. removeIncludedOnlyMesh(mesh: Mesh): void;
  60131. /**
  60132. * Determine if a given mesh will be used in the glow layer
  60133. * @param mesh The mesh to test
  60134. * @returns true if the mesh will be highlighted by the current glow layer
  60135. */
  60136. hasMesh(mesh: AbstractMesh): boolean;
  60137. /**
  60138. * Defines whether the current material of the mesh should be use to render the effect.
  60139. * @param mesh defines the current mesh to render
  60140. */
  60141. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60142. /**
  60143. * Add a mesh to be rendered through its own material and not with emissive only.
  60144. * @param mesh The mesh for which we need to use its material
  60145. */
  60146. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60147. /**
  60148. * Remove a mesh from being rendered through its own material and not with emissive only.
  60149. * @param mesh The mesh for which we need to not use its material
  60150. */
  60151. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60152. /**
  60153. * Free any resources and references associated to a mesh.
  60154. * Internal use
  60155. * @param mesh The mesh to free.
  60156. * @hidden
  60157. */
  60158. _disposeMesh(mesh: Mesh): void;
  60159. /**
  60160. * Gets the class name of the effect layer
  60161. * @returns the string with the class name of the effect layer
  60162. */
  60163. getClassName(): string;
  60164. /**
  60165. * Serializes this glow layer
  60166. * @returns a serialized glow layer object
  60167. */
  60168. serialize(): any;
  60169. /**
  60170. * Creates a Glow Layer from parsed glow layer data
  60171. * @param parsedGlowLayer defines glow layer data
  60172. * @param scene defines the current scene
  60173. * @param rootUrl defines the root URL containing the glow layer information
  60174. * @returns a parsed Glow Layer
  60175. */
  60176. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60177. }
  60178. }
  60179. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  60180. /** @hidden */
  60181. export var glowBlurPostProcessPixelShader: {
  60182. name: string;
  60183. shader: string;
  60184. };
  60185. }
  60186. declare module "babylonjs/Layers/highlightLayer" {
  60187. import { Observable } from "babylonjs/Misc/observable";
  60188. import { Nullable } from "babylonjs/types";
  60189. import { Camera } from "babylonjs/Cameras/camera";
  60190. import { Scene } from "babylonjs/scene";
  60191. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60193. import { Mesh } from "babylonjs/Meshes/mesh";
  60194. import { Effect } from "babylonjs/Materials/effect";
  60195. import { Material } from "babylonjs/Materials/material";
  60196. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60197. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60198. import "babylonjs/Shaders/glowMapMerge.fragment";
  60199. import "babylonjs/Shaders/glowMapMerge.vertex";
  60200. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  60201. module "babylonjs/abstractScene" {
  60202. interface AbstractScene {
  60203. /**
  60204. * Return a the first highlight layer of the scene with a given name.
  60205. * @param name The name of the highlight layer to look for.
  60206. * @return The highlight layer if found otherwise null.
  60207. */
  60208. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60209. }
  60210. }
  60211. /**
  60212. * Highlight layer options. This helps customizing the behaviour
  60213. * of the highlight layer.
  60214. */
  60215. export interface IHighlightLayerOptions {
  60216. /**
  60217. * Multiplication factor apply to the canvas size to compute the render target size
  60218. * used to generated the glowing objects (the smaller the faster).
  60219. */
  60220. mainTextureRatio: number;
  60221. /**
  60222. * Enforces a fixed size texture to ensure resize independant blur.
  60223. */
  60224. mainTextureFixedSize?: number;
  60225. /**
  60226. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60227. * of the picture to blur (the smaller the faster).
  60228. */
  60229. blurTextureSizeRatio: number;
  60230. /**
  60231. * How big in texel of the blur texture is the vertical blur.
  60232. */
  60233. blurVerticalSize: number;
  60234. /**
  60235. * How big in texel of the blur texture is the horizontal blur.
  60236. */
  60237. blurHorizontalSize: number;
  60238. /**
  60239. * Alpha blending mode used to apply the blur. Default is combine.
  60240. */
  60241. alphaBlendingMode: number;
  60242. /**
  60243. * The camera attached to the layer.
  60244. */
  60245. camera: Nullable<Camera>;
  60246. /**
  60247. * Should we display highlight as a solid stroke?
  60248. */
  60249. isStroke?: boolean;
  60250. /**
  60251. * The rendering group to draw the layer in.
  60252. */
  60253. renderingGroupId: number;
  60254. }
  60255. /**
  60256. * The highlight layer Helps adding a glow effect around a mesh.
  60257. *
  60258. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60259. * glowy meshes to your scene.
  60260. *
  60261. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60262. */
  60263. export class HighlightLayer extends EffectLayer {
  60264. name: string;
  60265. /**
  60266. * Effect Name of the highlight layer.
  60267. */
  60268. static readonly EffectName: string;
  60269. /**
  60270. * The neutral color used during the preparation of the glow effect.
  60271. * This is black by default as the blend operation is a blend operation.
  60272. */
  60273. static NeutralColor: Color4;
  60274. /**
  60275. * Stencil value used for glowing meshes.
  60276. */
  60277. static GlowingMeshStencilReference: number;
  60278. /**
  60279. * Stencil value used for the other meshes in the scene.
  60280. */
  60281. static NormalMeshStencilReference: number;
  60282. /**
  60283. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60284. */
  60285. innerGlow: boolean;
  60286. /**
  60287. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60288. */
  60289. outerGlow: boolean;
  60290. /**
  60291. * Specifies the horizontal size of the blur.
  60292. */
  60293. set blurHorizontalSize(value: number);
  60294. /**
  60295. * Specifies the vertical size of the blur.
  60296. */
  60297. set blurVerticalSize(value: number);
  60298. /**
  60299. * Gets the horizontal size of the blur.
  60300. */
  60301. get blurHorizontalSize(): number;
  60302. /**
  60303. * Gets the vertical size of the blur.
  60304. */
  60305. get blurVerticalSize(): number;
  60306. /**
  60307. * An event triggered when the highlight layer is being blurred.
  60308. */
  60309. onBeforeBlurObservable: Observable<HighlightLayer>;
  60310. /**
  60311. * An event triggered when the highlight layer has been blurred.
  60312. */
  60313. onAfterBlurObservable: Observable<HighlightLayer>;
  60314. private _instanceGlowingMeshStencilReference;
  60315. private _options;
  60316. private _downSamplePostprocess;
  60317. private _horizontalBlurPostprocess;
  60318. private _verticalBlurPostprocess;
  60319. private _blurTexture;
  60320. private _meshes;
  60321. private _excludedMeshes;
  60322. /**
  60323. * Instantiates a new highlight Layer and references it to the scene..
  60324. * @param name The name of the layer
  60325. * @param scene The scene to use the layer in
  60326. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60327. */
  60328. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60329. /**
  60330. * Get the effect name of the layer.
  60331. * @return The effect name
  60332. */
  60333. getEffectName(): string;
  60334. /**
  60335. * Create the merge effect. This is the shader use to blit the information back
  60336. * to the main canvas at the end of the scene rendering.
  60337. */
  60338. protected _createMergeEffect(): Effect;
  60339. /**
  60340. * Creates the render target textures and post processes used in the highlight layer.
  60341. */
  60342. protected _createTextureAndPostProcesses(): void;
  60343. /**
  60344. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60345. */
  60346. needStencil(): boolean;
  60347. /**
  60348. * Checks for the readiness of the element composing the layer.
  60349. * @param subMesh the mesh to check for
  60350. * @param useInstances specify wether or not to use instances to render the mesh
  60351. * @param emissiveTexture the associated emissive texture used to generate the glow
  60352. * @return true if ready otherwise, false
  60353. */
  60354. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60355. /**
  60356. * Implementation specific of rendering the generating effect on the main canvas.
  60357. * @param effect The effect used to render through
  60358. */
  60359. protected _internalRender(effect: Effect): void;
  60360. /**
  60361. * Returns true if the layer contains information to display, otherwise false.
  60362. */
  60363. shouldRender(): boolean;
  60364. /**
  60365. * Returns true if the mesh should render, otherwise false.
  60366. * @param mesh The mesh to render
  60367. * @returns true if it should render otherwise false
  60368. */
  60369. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60370. /**
  60371. * Returns true if the mesh can be rendered, otherwise false.
  60372. * @param mesh The mesh to render
  60373. * @param material The material used on the mesh
  60374. * @returns true if it can be rendered otherwise false
  60375. */
  60376. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60377. /**
  60378. * Adds specific effects defines.
  60379. * @param defines The defines to add specifics to.
  60380. */
  60381. protected _addCustomEffectDefines(defines: string[]): void;
  60382. /**
  60383. * Sets the required values for both the emissive texture and and the main color.
  60384. */
  60385. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60386. /**
  60387. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60388. * @param mesh The mesh to exclude from the highlight layer
  60389. */
  60390. addExcludedMesh(mesh: Mesh): void;
  60391. /**
  60392. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60393. * @param mesh The mesh to highlight
  60394. */
  60395. removeExcludedMesh(mesh: Mesh): void;
  60396. /**
  60397. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60398. * @param mesh mesh to test
  60399. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60400. */
  60401. hasMesh(mesh: AbstractMesh): boolean;
  60402. /**
  60403. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60404. * @param mesh The mesh to highlight
  60405. * @param color The color of the highlight
  60406. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60407. */
  60408. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60409. /**
  60410. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60411. * @param mesh The mesh to highlight
  60412. */
  60413. removeMesh(mesh: Mesh): void;
  60414. /**
  60415. * Remove all the meshes currently referenced in the highlight layer
  60416. */
  60417. removeAllMeshes(): void;
  60418. /**
  60419. * Force the stencil to the normal expected value for none glowing parts
  60420. */
  60421. private _defaultStencilReference;
  60422. /**
  60423. * Free any resources and references associated to a mesh.
  60424. * Internal use
  60425. * @param mesh The mesh to free.
  60426. * @hidden
  60427. */
  60428. _disposeMesh(mesh: Mesh): void;
  60429. /**
  60430. * Dispose the highlight layer and free resources.
  60431. */
  60432. dispose(): void;
  60433. /**
  60434. * Gets the class name of the effect layer
  60435. * @returns the string with the class name of the effect layer
  60436. */
  60437. getClassName(): string;
  60438. /**
  60439. * Serializes this Highlight layer
  60440. * @returns a serialized Highlight layer object
  60441. */
  60442. serialize(): any;
  60443. /**
  60444. * Creates a Highlight layer from parsed Highlight layer data
  60445. * @param parsedHightlightLayer defines the Highlight layer data
  60446. * @param scene defines the current scene
  60447. * @param rootUrl defines the root URL containing the Highlight layer information
  60448. * @returns a parsed Highlight layer
  60449. */
  60450. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60451. }
  60452. }
  60453. declare module "babylonjs/Layers/layerSceneComponent" {
  60454. import { Scene } from "babylonjs/scene";
  60455. import { ISceneComponent } from "babylonjs/sceneComponent";
  60456. import { Layer } from "babylonjs/Layers/layer";
  60457. import { AbstractScene } from "babylonjs/abstractScene";
  60458. module "babylonjs/abstractScene" {
  60459. interface AbstractScene {
  60460. /**
  60461. * The list of layers (background and foreground) of the scene
  60462. */
  60463. layers: Array<Layer>;
  60464. }
  60465. }
  60466. /**
  60467. * Defines the layer scene component responsible to manage any layers
  60468. * in a given scene.
  60469. */
  60470. export class LayerSceneComponent implements ISceneComponent {
  60471. /**
  60472. * The component name helpfull to identify the component in the list of scene components.
  60473. */
  60474. readonly name: string;
  60475. /**
  60476. * The scene the component belongs to.
  60477. */
  60478. scene: Scene;
  60479. private _engine;
  60480. /**
  60481. * Creates a new instance of the component for the given scene
  60482. * @param scene Defines the scene to register the component in
  60483. */
  60484. constructor(scene: Scene);
  60485. /**
  60486. * Registers the component in a given scene
  60487. */
  60488. register(): void;
  60489. /**
  60490. * Rebuilds the elements related to this component in case of
  60491. * context lost for instance.
  60492. */
  60493. rebuild(): void;
  60494. /**
  60495. * Disposes the component and the associated ressources.
  60496. */
  60497. dispose(): void;
  60498. private _draw;
  60499. private _drawCameraPredicate;
  60500. private _drawCameraBackground;
  60501. private _drawCameraForeground;
  60502. private _drawRenderTargetPredicate;
  60503. private _drawRenderTargetBackground;
  60504. private _drawRenderTargetForeground;
  60505. /**
  60506. * Adds all the elements from the container to the scene
  60507. * @param container the container holding the elements
  60508. */
  60509. addFromContainer(container: AbstractScene): void;
  60510. /**
  60511. * Removes all the elements in the container from the scene
  60512. * @param container contains the elements to remove
  60513. * @param dispose if the removed element should be disposed (default: false)
  60514. */
  60515. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60516. }
  60517. }
  60518. declare module "babylonjs/Shaders/layer.fragment" {
  60519. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60520. /** @hidden */
  60521. export var layerPixelShader: {
  60522. name: string;
  60523. shader: string;
  60524. };
  60525. }
  60526. declare module "babylonjs/Shaders/layer.vertex" {
  60527. /** @hidden */
  60528. export var layerVertexShader: {
  60529. name: string;
  60530. shader: string;
  60531. };
  60532. }
  60533. declare module "babylonjs/Layers/layer" {
  60534. import { Observable } from "babylonjs/Misc/observable";
  60535. import { Nullable } from "babylonjs/types";
  60536. import { Scene } from "babylonjs/scene";
  60537. import { Vector2 } from "babylonjs/Maths/math.vector";
  60538. import { Color4 } from "babylonjs/Maths/math.color";
  60539. import { Texture } from "babylonjs/Materials/Textures/texture";
  60540. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60541. import "babylonjs/Shaders/layer.fragment";
  60542. import "babylonjs/Shaders/layer.vertex";
  60543. /**
  60544. * This represents a full screen 2d layer.
  60545. * This can be useful to display a picture in the background of your scene for instance.
  60546. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60547. */
  60548. export class Layer {
  60549. /**
  60550. * Define the name of the layer.
  60551. */
  60552. name: string;
  60553. /**
  60554. * Define the texture the layer should display.
  60555. */
  60556. texture: Nullable<Texture>;
  60557. /**
  60558. * Is the layer in background or foreground.
  60559. */
  60560. isBackground: boolean;
  60561. /**
  60562. * Define the color of the layer (instead of texture).
  60563. */
  60564. color: Color4;
  60565. /**
  60566. * Define the scale of the layer in order to zoom in out of the texture.
  60567. */
  60568. scale: Vector2;
  60569. /**
  60570. * Define an offset for the layer in order to shift the texture.
  60571. */
  60572. offset: Vector2;
  60573. /**
  60574. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60575. */
  60576. alphaBlendingMode: number;
  60577. /**
  60578. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60579. * Alpha test will not mix with the background color in case of transparency.
  60580. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60581. */
  60582. alphaTest: boolean;
  60583. /**
  60584. * Define a mask to restrict the layer to only some of the scene cameras.
  60585. */
  60586. layerMask: number;
  60587. /**
  60588. * Define the list of render target the layer is visible into.
  60589. */
  60590. renderTargetTextures: RenderTargetTexture[];
  60591. /**
  60592. * Define if the layer is only used in renderTarget or if it also
  60593. * renders in the main frame buffer of the canvas.
  60594. */
  60595. renderOnlyInRenderTargetTextures: boolean;
  60596. private _scene;
  60597. private _vertexBuffers;
  60598. private _indexBuffer;
  60599. private _effect;
  60600. private _previousDefines;
  60601. /**
  60602. * An event triggered when the layer is disposed.
  60603. */
  60604. onDisposeObservable: Observable<Layer>;
  60605. private _onDisposeObserver;
  60606. /**
  60607. * Back compatibility with callback before the onDisposeObservable existed.
  60608. * The set callback will be triggered when the layer has been disposed.
  60609. */
  60610. set onDispose(callback: () => void);
  60611. /**
  60612. * An event triggered before rendering the scene
  60613. */
  60614. onBeforeRenderObservable: Observable<Layer>;
  60615. private _onBeforeRenderObserver;
  60616. /**
  60617. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60618. * The set callback will be triggered just before rendering the layer.
  60619. */
  60620. set onBeforeRender(callback: () => void);
  60621. /**
  60622. * An event triggered after rendering the scene
  60623. */
  60624. onAfterRenderObservable: Observable<Layer>;
  60625. private _onAfterRenderObserver;
  60626. /**
  60627. * Back compatibility with callback before the onAfterRenderObservable existed.
  60628. * The set callback will be triggered just after rendering the layer.
  60629. */
  60630. set onAfterRender(callback: () => void);
  60631. /**
  60632. * Instantiates a new layer.
  60633. * This represents a full screen 2d layer.
  60634. * This can be useful to display a picture in the background of your scene for instance.
  60635. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60636. * @param name Define the name of the layer in the scene
  60637. * @param imgUrl Define the url of the texture to display in the layer
  60638. * @param scene Define the scene the layer belongs to
  60639. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60640. * @param color Defines a color for the layer
  60641. */
  60642. constructor(
  60643. /**
  60644. * Define the name of the layer.
  60645. */
  60646. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60647. private _createIndexBuffer;
  60648. /** @hidden */
  60649. _rebuild(): void;
  60650. /**
  60651. * Renders the layer in the scene.
  60652. */
  60653. render(): void;
  60654. /**
  60655. * Disposes and releases the associated ressources.
  60656. */
  60657. dispose(): void;
  60658. }
  60659. }
  60660. declare module "babylonjs/Layers/index" {
  60661. export * from "babylonjs/Layers/effectLayer";
  60662. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60663. export * from "babylonjs/Layers/glowLayer";
  60664. export * from "babylonjs/Layers/highlightLayer";
  60665. export * from "babylonjs/Layers/layer";
  60666. export * from "babylonjs/Layers/layerSceneComponent";
  60667. }
  60668. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60669. /** @hidden */
  60670. export var lensFlarePixelShader: {
  60671. name: string;
  60672. shader: string;
  60673. };
  60674. }
  60675. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60676. /** @hidden */
  60677. export var lensFlareVertexShader: {
  60678. name: string;
  60679. shader: string;
  60680. };
  60681. }
  60682. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60683. import { Scene } from "babylonjs/scene";
  60684. import { Vector3 } from "babylonjs/Maths/math.vector";
  60685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60686. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60687. import "babylonjs/Shaders/lensFlare.fragment";
  60688. import "babylonjs/Shaders/lensFlare.vertex";
  60689. import { Viewport } from "babylonjs/Maths/math.viewport";
  60690. /**
  60691. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60692. * It is usually composed of several `lensFlare`.
  60693. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60694. */
  60695. export class LensFlareSystem {
  60696. /**
  60697. * Define the name of the lens flare system
  60698. */
  60699. name: string;
  60700. /**
  60701. * List of lens flares used in this system.
  60702. */
  60703. lensFlares: LensFlare[];
  60704. /**
  60705. * Define a limit from the border the lens flare can be visible.
  60706. */
  60707. borderLimit: number;
  60708. /**
  60709. * Define a viewport border we do not want to see the lens flare in.
  60710. */
  60711. viewportBorder: number;
  60712. /**
  60713. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60714. */
  60715. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60716. /**
  60717. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60718. */
  60719. layerMask: number;
  60720. /**
  60721. * Define the id of the lens flare system in the scene.
  60722. * (equal to name by default)
  60723. */
  60724. id: string;
  60725. private _scene;
  60726. private _emitter;
  60727. private _vertexBuffers;
  60728. private _indexBuffer;
  60729. private _effect;
  60730. private _positionX;
  60731. private _positionY;
  60732. private _isEnabled;
  60733. /** @hidden */
  60734. static _SceneComponentInitialization: (scene: Scene) => void;
  60735. /**
  60736. * Instantiates a lens flare system.
  60737. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60738. * It is usually composed of several `lensFlare`.
  60739. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60740. * @param name Define the name of the lens flare system in the scene
  60741. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60742. * @param scene Define the scene the lens flare system belongs to
  60743. */
  60744. constructor(
  60745. /**
  60746. * Define the name of the lens flare system
  60747. */
  60748. name: string, emitter: any, scene: Scene);
  60749. /**
  60750. * Define if the lens flare system is enabled.
  60751. */
  60752. get isEnabled(): boolean;
  60753. set isEnabled(value: boolean);
  60754. /**
  60755. * Get the scene the effects belongs to.
  60756. * @returns the scene holding the lens flare system
  60757. */
  60758. getScene(): Scene;
  60759. /**
  60760. * Get the emitter of the lens flare system.
  60761. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60762. * @returns the emitter of the lens flare system
  60763. */
  60764. getEmitter(): any;
  60765. /**
  60766. * Set the emitter of the lens flare system.
  60767. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60768. * @param newEmitter Define the new emitter of the system
  60769. */
  60770. setEmitter(newEmitter: any): void;
  60771. /**
  60772. * Get the lens flare system emitter position.
  60773. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60774. * @returns the position
  60775. */
  60776. getEmitterPosition(): Vector3;
  60777. /**
  60778. * @hidden
  60779. */
  60780. computeEffectivePosition(globalViewport: Viewport): boolean;
  60781. /** @hidden */
  60782. _isVisible(): boolean;
  60783. /**
  60784. * @hidden
  60785. */
  60786. render(): boolean;
  60787. /**
  60788. * Dispose and release the lens flare with its associated resources.
  60789. */
  60790. dispose(): void;
  60791. /**
  60792. * Parse a lens flare system from a JSON repressentation
  60793. * @param parsedLensFlareSystem Define the JSON to parse
  60794. * @param scene Define the scene the parsed system should be instantiated in
  60795. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60796. * @returns the parsed system
  60797. */
  60798. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60799. /**
  60800. * Serialize the current Lens Flare System into a JSON representation.
  60801. * @returns the serialized JSON
  60802. */
  60803. serialize(): any;
  60804. }
  60805. }
  60806. declare module "babylonjs/LensFlares/lensFlare" {
  60807. import { Nullable } from "babylonjs/types";
  60808. import { Color3 } from "babylonjs/Maths/math.color";
  60809. import { Texture } from "babylonjs/Materials/Textures/texture";
  60810. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60811. /**
  60812. * This represents one of the lens effect in a `lensFlareSystem`.
  60813. * It controls one of the indiviual texture used in the effect.
  60814. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60815. */
  60816. export class LensFlare {
  60817. /**
  60818. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60819. */
  60820. size: number;
  60821. /**
  60822. * 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.
  60823. */
  60824. position: number;
  60825. /**
  60826. * Define the lens color.
  60827. */
  60828. color: Color3;
  60829. /**
  60830. * Define the lens texture.
  60831. */
  60832. texture: Nullable<Texture>;
  60833. /**
  60834. * Define the alpha mode to render this particular lens.
  60835. */
  60836. alphaMode: number;
  60837. private _system;
  60838. /**
  60839. * Creates a new Lens Flare.
  60840. * This represents one of the lens effect in a `lensFlareSystem`.
  60841. * It controls one of the indiviual texture used in the effect.
  60842. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60843. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60844. * @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.
  60845. * @param color Define the lens color
  60846. * @param imgUrl Define the lens texture url
  60847. * @param system Define the `lensFlareSystem` this flare is part of
  60848. * @returns The newly created Lens Flare
  60849. */
  60850. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60851. /**
  60852. * Instantiates a new Lens Flare.
  60853. * This represents one of the lens effect in a `lensFlareSystem`.
  60854. * It controls one of the indiviual texture used in the effect.
  60855. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60856. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60857. * @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.
  60858. * @param color Define the lens color
  60859. * @param imgUrl Define the lens texture url
  60860. * @param system Define the `lensFlareSystem` this flare is part of
  60861. */
  60862. constructor(
  60863. /**
  60864. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60865. */
  60866. size: number,
  60867. /**
  60868. * 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.
  60869. */
  60870. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60871. /**
  60872. * Dispose and release the lens flare with its associated resources.
  60873. */
  60874. dispose(): void;
  60875. }
  60876. }
  60877. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60878. import { Nullable } from "babylonjs/types";
  60879. import { Scene } from "babylonjs/scene";
  60880. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60881. import { AbstractScene } from "babylonjs/abstractScene";
  60882. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60883. module "babylonjs/abstractScene" {
  60884. interface AbstractScene {
  60885. /**
  60886. * The list of lens flare system added to the scene
  60887. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60888. */
  60889. lensFlareSystems: Array<LensFlareSystem>;
  60890. /**
  60891. * Removes the given lens flare system from this scene.
  60892. * @param toRemove The lens flare system to remove
  60893. * @returns The index of the removed lens flare system
  60894. */
  60895. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60896. /**
  60897. * Adds the given lens flare system to this scene
  60898. * @param newLensFlareSystem The lens flare system to add
  60899. */
  60900. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60901. /**
  60902. * Gets a lens flare system using its name
  60903. * @param name defines the name to look for
  60904. * @returns the lens flare system or null if not found
  60905. */
  60906. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60907. /**
  60908. * Gets a lens flare system using its id
  60909. * @param id defines the id to look for
  60910. * @returns the lens flare system or null if not found
  60911. */
  60912. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60913. }
  60914. }
  60915. /**
  60916. * Defines the lens flare scene component responsible to manage any lens flares
  60917. * in a given scene.
  60918. */
  60919. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60920. /**
  60921. * The component name helpfull to identify the component in the list of scene components.
  60922. */
  60923. readonly name: string;
  60924. /**
  60925. * The scene the component belongs to.
  60926. */
  60927. scene: Scene;
  60928. /**
  60929. * Creates a new instance of the component for the given scene
  60930. * @param scene Defines the scene to register the component in
  60931. */
  60932. constructor(scene: Scene);
  60933. /**
  60934. * Registers the component in a given scene
  60935. */
  60936. register(): void;
  60937. /**
  60938. * Rebuilds the elements related to this component in case of
  60939. * context lost for instance.
  60940. */
  60941. rebuild(): void;
  60942. /**
  60943. * Adds all the elements from the container to the scene
  60944. * @param container the container holding the elements
  60945. */
  60946. addFromContainer(container: AbstractScene): void;
  60947. /**
  60948. * Removes all the elements in the container from the scene
  60949. * @param container contains the elements to remove
  60950. * @param dispose if the removed element should be disposed (default: false)
  60951. */
  60952. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60953. /**
  60954. * Serializes the component data to the specified json object
  60955. * @param serializationObject The object to serialize to
  60956. */
  60957. serialize(serializationObject: any): void;
  60958. /**
  60959. * Disposes the component and the associated ressources.
  60960. */
  60961. dispose(): void;
  60962. private _draw;
  60963. }
  60964. }
  60965. declare module "babylonjs/LensFlares/index" {
  60966. export * from "babylonjs/LensFlares/lensFlare";
  60967. export * from "babylonjs/LensFlares/lensFlareSystem";
  60968. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60969. }
  60970. declare module "babylonjs/Shaders/depth.fragment" {
  60971. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60972. /** @hidden */
  60973. export var depthPixelShader: {
  60974. name: string;
  60975. shader: string;
  60976. };
  60977. }
  60978. declare module "babylonjs/Shaders/depth.vertex" {
  60979. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60980. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60981. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60982. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60983. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60984. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60985. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60986. /** @hidden */
  60987. export var depthVertexShader: {
  60988. name: string;
  60989. shader: string;
  60990. };
  60991. }
  60992. declare module "babylonjs/Rendering/depthRenderer" {
  60993. import { Nullable } from "babylonjs/types";
  60994. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60995. import { Scene } from "babylonjs/scene";
  60996. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60997. import { Camera } from "babylonjs/Cameras/camera";
  60998. import "babylonjs/Shaders/depth.fragment";
  60999. import "babylonjs/Shaders/depth.vertex";
  61000. /**
  61001. * This represents a depth renderer in Babylon.
  61002. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61003. */
  61004. export class DepthRenderer {
  61005. private _scene;
  61006. private _depthMap;
  61007. private _effect;
  61008. private readonly _storeNonLinearDepth;
  61009. private readonly _clearColor;
  61010. /** Get if the depth renderer is using packed depth or not */
  61011. readonly isPacked: boolean;
  61012. private _cachedDefines;
  61013. private _camera;
  61014. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61015. enabled: boolean;
  61016. /**
  61017. * Specifiess that the depth renderer will only be used within
  61018. * the camera it is created for.
  61019. * This can help forcing its rendering during the camera processing.
  61020. */
  61021. useOnlyInActiveCamera: boolean;
  61022. /** @hidden */
  61023. static _SceneComponentInitialization: (scene: Scene) => void;
  61024. /**
  61025. * Instantiates a depth renderer
  61026. * @param scene The scene the renderer belongs to
  61027. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61028. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61029. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61030. */
  61031. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61032. /**
  61033. * Creates the depth rendering effect and checks if the effect is ready.
  61034. * @param subMesh The submesh to be used to render the depth map of
  61035. * @param useInstances If multiple world instances should be used
  61036. * @returns if the depth renderer is ready to render the depth map
  61037. */
  61038. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61039. /**
  61040. * Gets the texture which the depth map will be written to.
  61041. * @returns The depth map texture
  61042. */
  61043. getDepthMap(): RenderTargetTexture;
  61044. /**
  61045. * Disposes of the depth renderer.
  61046. */
  61047. dispose(): void;
  61048. }
  61049. }
  61050. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  61051. /** @hidden */
  61052. export var minmaxReduxPixelShader: {
  61053. name: string;
  61054. shader: string;
  61055. };
  61056. }
  61057. declare module "babylonjs/Misc/minMaxReducer" {
  61058. import { Nullable } from "babylonjs/types";
  61059. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61060. import { Camera } from "babylonjs/Cameras/camera";
  61061. import { Observer } from "babylonjs/Misc/observable";
  61062. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61063. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  61064. import { Observable } from "babylonjs/Misc/observable";
  61065. import "babylonjs/Shaders/minmaxRedux.fragment";
  61066. /**
  61067. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61068. * and maximum values from all values of the texture.
  61069. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61070. * The source values are read from the red channel of the texture.
  61071. */
  61072. export class MinMaxReducer {
  61073. /**
  61074. * Observable triggered when the computation has been performed
  61075. */
  61076. onAfterReductionPerformed: Observable<{
  61077. min: number;
  61078. max: number;
  61079. }>;
  61080. protected _camera: Camera;
  61081. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61082. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61083. protected _postProcessManager: PostProcessManager;
  61084. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61085. protected _forceFullscreenViewport: boolean;
  61086. /**
  61087. * Creates a min/max reducer
  61088. * @param camera The camera to use for the post processes
  61089. */
  61090. constructor(camera: Camera);
  61091. /**
  61092. * Gets the texture used to read the values from.
  61093. */
  61094. get sourceTexture(): Nullable<RenderTargetTexture>;
  61095. /**
  61096. * Sets the source texture to read the values from.
  61097. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61098. * because in such textures '1' value must not be taken into account to compute the maximum
  61099. * as this value is used to clear the texture.
  61100. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61101. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61102. * @param depthRedux Indicates if the texture is a depth texture or not
  61103. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61104. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61105. */
  61106. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61107. /**
  61108. * Defines the refresh rate of the computation.
  61109. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61110. */
  61111. get refreshRate(): number;
  61112. set refreshRate(value: number);
  61113. protected _activated: boolean;
  61114. /**
  61115. * Gets the activation status of the reducer
  61116. */
  61117. get activated(): boolean;
  61118. /**
  61119. * Activates the reduction computation.
  61120. * When activated, the observers registered in onAfterReductionPerformed are
  61121. * called after the compuation is performed
  61122. */
  61123. activate(): void;
  61124. /**
  61125. * Deactivates the reduction computation.
  61126. */
  61127. deactivate(): void;
  61128. /**
  61129. * Disposes the min/max reducer
  61130. * @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.
  61131. */
  61132. dispose(disposeAll?: boolean): void;
  61133. }
  61134. }
  61135. declare module "babylonjs/Misc/depthReducer" {
  61136. import { Nullable } from "babylonjs/types";
  61137. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61138. import { Camera } from "babylonjs/Cameras/camera";
  61139. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61140. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  61141. /**
  61142. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61143. */
  61144. export class DepthReducer extends MinMaxReducer {
  61145. private _depthRenderer;
  61146. private _depthRendererId;
  61147. /**
  61148. * Gets the depth renderer used for the computation.
  61149. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61150. */
  61151. get depthRenderer(): Nullable<DepthRenderer>;
  61152. /**
  61153. * Creates a depth reducer
  61154. * @param camera The camera used to render the depth texture
  61155. */
  61156. constructor(camera: Camera);
  61157. /**
  61158. * Sets the depth renderer to use to generate the depth map
  61159. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61160. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61161. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61162. */
  61163. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61164. /** @hidden */
  61165. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61166. /**
  61167. * Activates the reduction computation.
  61168. * When activated, the observers registered in onAfterReductionPerformed are
  61169. * called after the compuation is performed
  61170. */
  61171. activate(): void;
  61172. /**
  61173. * Deactivates the reduction computation.
  61174. */
  61175. deactivate(): void;
  61176. /**
  61177. * Disposes the depth reducer
  61178. * @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.
  61179. */
  61180. dispose(disposeAll?: boolean): void;
  61181. }
  61182. }
  61183. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  61184. import { Nullable } from "babylonjs/types";
  61185. import { Scene } from "babylonjs/scene";
  61186. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61187. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61189. import { Effect } from "babylonjs/Materials/effect";
  61190. import "babylonjs/Shaders/shadowMap.fragment";
  61191. import "babylonjs/Shaders/shadowMap.vertex";
  61192. import "babylonjs/Shaders/depthBoxBlur.fragment";
  61193. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  61194. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61195. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61196. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61197. /**
  61198. * A CSM implementation allowing casting shadows on large scenes.
  61199. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61200. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61201. */
  61202. export class CascadedShadowGenerator extends ShadowGenerator {
  61203. private static readonly frustumCornersNDCSpace;
  61204. /**
  61205. * Name of the CSM class
  61206. */
  61207. static CLASSNAME: string;
  61208. /**
  61209. * Defines the default number of cascades used by the CSM.
  61210. */
  61211. static readonly DEFAULT_CASCADES_COUNT: number;
  61212. /**
  61213. * Defines the minimum number of cascades used by the CSM.
  61214. */
  61215. static readonly MIN_CASCADES_COUNT: number;
  61216. /**
  61217. * Defines the maximum number of cascades used by the CSM.
  61218. */
  61219. static readonly MAX_CASCADES_COUNT: number;
  61220. protected _validateFilter(filter: number): number;
  61221. /**
  61222. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61223. */
  61224. penumbraDarkness: number;
  61225. private _numCascades;
  61226. /**
  61227. * Gets or set the number of cascades used by the CSM.
  61228. */
  61229. get numCascades(): number;
  61230. set numCascades(value: number);
  61231. /**
  61232. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61233. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61234. */
  61235. stabilizeCascades: boolean;
  61236. private _freezeShadowCastersBoundingInfo;
  61237. private _freezeShadowCastersBoundingInfoObservable;
  61238. /**
  61239. * Enables or disables the shadow casters bounding info computation.
  61240. * If your shadow casters don't move, you can disable this feature.
  61241. * If it is enabled, the bounding box computation is done every frame.
  61242. */
  61243. get freezeShadowCastersBoundingInfo(): boolean;
  61244. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61245. private _scbiMin;
  61246. private _scbiMax;
  61247. protected _computeShadowCastersBoundingInfo(): void;
  61248. protected _shadowCastersBoundingInfo: BoundingInfo;
  61249. /**
  61250. * Gets or sets the shadow casters bounding info.
  61251. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61252. * so that the system won't overwrite the bounds you provide
  61253. */
  61254. get shadowCastersBoundingInfo(): BoundingInfo;
  61255. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61256. protected _breaksAreDirty: boolean;
  61257. protected _minDistance: number;
  61258. protected _maxDistance: number;
  61259. /**
  61260. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61261. *
  61262. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61263. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61264. * @param min minimal distance for the breaks (default to 0.)
  61265. * @param max maximal distance for the breaks (default to 1.)
  61266. */
  61267. setMinMaxDistance(min: number, max: number): void;
  61268. /** Gets the minimal distance used in the cascade break computation */
  61269. get minDistance(): number;
  61270. /** Gets the maximal distance used in the cascade break computation */
  61271. get maxDistance(): number;
  61272. /**
  61273. * Gets the class name of that object
  61274. * @returns "CascadedShadowGenerator"
  61275. */
  61276. getClassName(): string;
  61277. private _cascadeMinExtents;
  61278. private _cascadeMaxExtents;
  61279. /**
  61280. * Gets a cascade minimum extents
  61281. * @param cascadeIndex index of the cascade
  61282. * @returns the minimum cascade extents
  61283. */
  61284. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61285. /**
  61286. * Gets a cascade maximum extents
  61287. * @param cascadeIndex index of the cascade
  61288. * @returns the maximum cascade extents
  61289. */
  61290. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61291. private _cascades;
  61292. private _currentLayer;
  61293. private _viewSpaceFrustumsZ;
  61294. private _viewMatrices;
  61295. private _projectionMatrices;
  61296. private _transformMatrices;
  61297. private _transformMatricesAsArray;
  61298. private _frustumLengths;
  61299. private _lightSizeUVCorrection;
  61300. private _depthCorrection;
  61301. private _frustumCornersWorldSpace;
  61302. private _frustumCenter;
  61303. private _shadowCameraPos;
  61304. private _shadowMaxZ;
  61305. /**
  61306. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61307. * It defaults to camera.maxZ
  61308. */
  61309. get shadowMaxZ(): number;
  61310. /**
  61311. * Sets the shadow max z distance.
  61312. */
  61313. set shadowMaxZ(value: number);
  61314. protected _debug: boolean;
  61315. /**
  61316. * Gets or sets the debug flag.
  61317. * When enabled, the cascades are materialized by different colors on the screen.
  61318. */
  61319. get debug(): boolean;
  61320. set debug(dbg: boolean);
  61321. private _depthClamp;
  61322. /**
  61323. * Gets or sets the depth clamping value.
  61324. *
  61325. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61326. * to account for the shadow casters far away.
  61327. *
  61328. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61329. */
  61330. get depthClamp(): boolean;
  61331. set depthClamp(value: boolean);
  61332. private _cascadeBlendPercentage;
  61333. /**
  61334. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61335. * It defaults to 0.1 (10% blending).
  61336. */
  61337. get cascadeBlendPercentage(): number;
  61338. set cascadeBlendPercentage(value: number);
  61339. private _lambda;
  61340. /**
  61341. * Gets or set the lambda parameter.
  61342. * This parameter is used to split the camera frustum and create the cascades.
  61343. * 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.
  61344. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61345. */
  61346. get lambda(): number;
  61347. set lambda(value: number);
  61348. /**
  61349. * Gets the view matrix corresponding to a given cascade
  61350. * @param cascadeNum cascade to retrieve the view matrix from
  61351. * @returns the cascade view matrix
  61352. */
  61353. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61354. /**
  61355. * Gets the projection matrix corresponding to a given cascade
  61356. * @param cascadeNum cascade to retrieve the projection matrix from
  61357. * @returns the cascade projection matrix
  61358. */
  61359. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61360. /**
  61361. * Gets the transformation matrix corresponding to a given cascade
  61362. * @param cascadeNum cascade to retrieve the transformation matrix from
  61363. * @returns the cascade transformation matrix
  61364. */
  61365. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61366. private _depthRenderer;
  61367. /**
  61368. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61369. *
  61370. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61371. *
  61372. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61373. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61374. * @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
  61375. */
  61376. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61377. private _depthReducer;
  61378. private _autoCalcDepthBounds;
  61379. /**
  61380. * Gets or sets the autoCalcDepthBounds property.
  61381. *
  61382. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61383. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61384. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61385. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61386. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61387. */
  61388. get autoCalcDepthBounds(): boolean;
  61389. set autoCalcDepthBounds(value: boolean);
  61390. /**
  61391. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61392. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61393. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61394. * for setting the refresh rate on the renderer yourself!
  61395. */
  61396. get autoCalcDepthBoundsRefreshRate(): number;
  61397. set autoCalcDepthBoundsRefreshRate(value: number);
  61398. /**
  61399. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61400. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61401. * you change the camera near/far planes!
  61402. */
  61403. splitFrustum(): void;
  61404. private _splitFrustum;
  61405. private _computeMatrices;
  61406. private _computeFrustumInWorldSpace;
  61407. private _computeCascadeFrustum;
  61408. /**
  61409. * Support test.
  61410. */
  61411. static get IsSupported(): boolean;
  61412. /** @hidden */
  61413. static _SceneComponentInitialization: (scene: Scene) => void;
  61414. /**
  61415. * Creates a Cascaded Shadow Generator object.
  61416. * A ShadowGenerator is the required tool to use the shadows.
  61417. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61418. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61419. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61420. * @param light The directional light object generating the shadows.
  61421. * @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.
  61422. */
  61423. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61424. protected _initializeGenerator(): void;
  61425. protected _createTargetRenderTexture(): void;
  61426. protected _initializeShadowMap(): void;
  61427. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61428. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61429. /**
  61430. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61431. * @param defines Defines of the material we want to update
  61432. * @param lightIndex Index of the light in the enabled light list of the material
  61433. */
  61434. prepareDefines(defines: any, lightIndex: number): void;
  61435. /**
  61436. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61437. * defined in the generator but impacting the effect).
  61438. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61439. * @param effect The effect we are binfing the information for
  61440. */
  61441. bindShadowLight(lightIndex: string, effect: Effect): void;
  61442. /**
  61443. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61444. * (eq to view projection * shadow projection matrices)
  61445. * @returns The transform matrix used to create the shadow map
  61446. */
  61447. getTransformMatrix(): Matrix;
  61448. /**
  61449. * Disposes the ShadowGenerator.
  61450. * Returns nothing.
  61451. */
  61452. dispose(): void;
  61453. /**
  61454. * Serializes the shadow generator setup to a json object.
  61455. * @returns The serialized JSON object
  61456. */
  61457. serialize(): any;
  61458. /**
  61459. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61460. * @param parsedShadowGenerator The JSON object to parse
  61461. * @param scene The scene to create the shadow map for
  61462. * @returns The parsed shadow generator
  61463. */
  61464. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61465. }
  61466. }
  61467. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  61468. import { Scene } from "babylonjs/scene";
  61469. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61470. import { AbstractScene } from "babylonjs/abstractScene";
  61471. /**
  61472. * Defines the shadow generator component responsible to manage any shadow generators
  61473. * in a given scene.
  61474. */
  61475. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61476. /**
  61477. * The component name helpfull to identify the component in the list of scene components.
  61478. */
  61479. readonly name: string;
  61480. /**
  61481. * The scene the component belongs to.
  61482. */
  61483. scene: Scene;
  61484. /**
  61485. * Creates a new instance of the component for the given scene
  61486. * @param scene Defines the scene to register the component in
  61487. */
  61488. constructor(scene: Scene);
  61489. /**
  61490. * Registers the component in a given scene
  61491. */
  61492. register(): void;
  61493. /**
  61494. * Rebuilds the elements related to this component in case of
  61495. * context lost for instance.
  61496. */
  61497. rebuild(): void;
  61498. /**
  61499. * Serializes the component data to the specified json object
  61500. * @param serializationObject The object to serialize to
  61501. */
  61502. serialize(serializationObject: any): void;
  61503. /**
  61504. * Adds all the elements from the container to the scene
  61505. * @param container the container holding the elements
  61506. */
  61507. addFromContainer(container: AbstractScene): void;
  61508. /**
  61509. * Removes all the elements in the container from the scene
  61510. * @param container contains the elements to remove
  61511. * @param dispose if the removed element should be disposed (default: false)
  61512. */
  61513. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61514. /**
  61515. * Rebuilds the elements related to this component in case of
  61516. * context lost for instance.
  61517. */
  61518. dispose(): void;
  61519. private _gatherRenderTargets;
  61520. }
  61521. }
  61522. declare module "babylonjs/Lights/Shadows/index" {
  61523. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  61524. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  61525. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  61526. }
  61527. declare module "babylonjs/Lights/pointLight" {
  61528. import { Scene } from "babylonjs/scene";
  61529. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61531. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  61532. import { Effect } from "babylonjs/Materials/effect";
  61533. /**
  61534. * A point light is a light defined by an unique point in world space.
  61535. * The light is emitted in every direction from this point.
  61536. * A good example of a point light is a standard light bulb.
  61537. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61538. */
  61539. export class PointLight extends ShadowLight {
  61540. private _shadowAngle;
  61541. /**
  61542. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61543. * This specifies what angle the shadow will use to be created.
  61544. *
  61545. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61546. */
  61547. get shadowAngle(): number;
  61548. /**
  61549. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61550. * This specifies what angle the shadow will use to be created.
  61551. *
  61552. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61553. */
  61554. set shadowAngle(value: number);
  61555. /**
  61556. * Gets the direction if it has been set.
  61557. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61558. */
  61559. get direction(): Vector3;
  61560. /**
  61561. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61562. */
  61563. set direction(value: Vector3);
  61564. /**
  61565. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61566. * A PointLight emits the light in every direction.
  61567. * It can cast shadows.
  61568. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61569. * ```javascript
  61570. * var pointLight = new PointLight("pl", camera.position, scene);
  61571. * ```
  61572. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61573. * @param name The light friendly name
  61574. * @param position The position of the point light in the scene
  61575. * @param scene The scene the lights belongs to
  61576. */
  61577. constructor(name: string, position: Vector3, scene: Scene);
  61578. /**
  61579. * Returns the string "PointLight"
  61580. * @returns the class name
  61581. */
  61582. getClassName(): string;
  61583. /**
  61584. * Returns the integer 0.
  61585. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61586. */
  61587. getTypeID(): number;
  61588. /**
  61589. * Specifies wether or not the shadowmap should be a cube texture.
  61590. * @returns true if the shadowmap needs to be a cube texture.
  61591. */
  61592. needCube(): boolean;
  61593. /**
  61594. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61595. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61596. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61597. */
  61598. getShadowDirection(faceIndex?: number): Vector3;
  61599. /**
  61600. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61601. * - fov = PI / 2
  61602. * - aspect ratio : 1.0
  61603. * - z-near and far equal to the active camera minZ and maxZ.
  61604. * Returns the PointLight.
  61605. */
  61606. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61607. protected _buildUniformLayout(): void;
  61608. /**
  61609. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61610. * @param effect The effect to update
  61611. * @param lightIndex The index of the light in the effect to update
  61612. * @returns The point light
  61613. */
  61614. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61615. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61616. /**
  61617. * Prepares the list of defines specific to the light type.
  61618. * @param defines the list of defines
  61619. * @param lightIndex defines the index of the light for the effect
  61620. */
  61621. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61622. }
  61623. }
  61624. declare module "babylonjs/Lights/index" {
  61625. export * from "babylonjs/Lights/light";
  61626. export * from "babylonjs/Lights/shadowLight";
  61627. export * from "babylonjs/Lights/Shadows/index";
  61628. export * from "babylonjs/Lights/directionalLight";
  61629. export * from "babylonjs/Lights/hemisphericLight";
  61630. export * from "babylonjs/Lights/pointLight";
  61631. export * from "babylonjs/Lights/spotLight";
  61632. }
  61633. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  61634. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61635. /**
  61636. * Header information of HDR texture files.
  61637. */
  61638. export interface HDRInfo {
  61639. /**
  61640. * The height of the texture in pixels.
  61641. */
  61642. height: number;
  61643. /**
  61644. * The width of the texture in pixels.
  61645. */
  61646. width: number;
  61647. /**
  61648. * The index of the beginning of the data in the binary file.
  61649. */
  61650. dataPosition: number;
  61651. }
  61652. /**
  61653. * This groups tools to convert HDR texture to native colors array.
  61654. */
  61655. export class HDRTools {
  61656. private static Ldexp;
  61657. private static Rgbe2float;
  61658. private static readStringLine;
  61659. /**
  61660. * Reads header information from an RGBE texture stored in a native array.
  61661. * More information on this format are available here:
  61662. * https://en.wikipedia.org/wiki/RGBE_image_format
  61663. *
  61664. * @param uint8array The binary file stored in native array.
  61665. * @return The header information.
  61666. */
  61667. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61668. /**
  61669. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61670. * This RGBE texture needs to store the information as a panorama.
  61671. *
  61672. * More information on this format are available here:
  61673. * https://en.wikipedia.org/wiki/RGBE_image_format
  61674. *
  61675. * @param buffer The binary file stored in an array buffer.
  61676. * @param size The expected size of the extracted cubemap.
  61677. * @return The Cube Map information.
  61678. */
  61679. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61680. /**
  61681. * Returns the pixels data extracted from an RGBE texture.
  61682. * This pixels will be stored left to right up to down in the R G B order in one array.
  61683. *
  61684. * More information on this format are available here:
  61685. * https://en.wikipedia.org/wiki/RGBE_image_format
  61686. *
  61687. * @param uint8array The binary file stored in an array buffer.
  61688. * @param hdrInfo The header information of the file.
  61689. * @return The pixels data in RGB right to left up to down order.
  61690. */
  61691. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61692. private static RGBE_ReadPixels_RLE;
  61693. }
  61694. }
  61695. declare module "babylonjs/Materials/effectRenderer" {
  61696. import { Nullable } from "babylonjs/types";
  61697. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61698. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61699. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61700. import { Viewport } from "babylonjs/Maths/math.viewport";
  61701. import { Observable } from "babylonjs/Misc/observable";
  61702. import { Effect } from "babylonjs/Materials/effect";
  61703. import "babylonjs/Shaders/postprocess.vertex";
  61704. /**
  61705. * Effect Render Options
  61706. */
  61707. export interface IEffectRendererOptions {
  61708. /**
  61709. * Defines the vertices positions.
  61710. */
  61711. positions?: number[];
  61712. /**
  61713. * Defines the indices.
  61714. */
  61715. indices?: number[];
  61716. }
  61717. /**
  61718. * Helper class to render one or more effects.
  61719. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61720. */
  61721. export class EffectRenderer {
  61722. private engine;
  61723. private static _DefaultOptions;
  61724. private _vertexBuffers;
  61725. private _indexBuffer;
  61726. private _fullscreenViewport;
  61727. /**
  61728. * Creates an effect renderer
  61729. * @param engine the engine to use for rendering
  61730. * @param options defines the options of the effect renderer
  61731. */
  61732. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61733. /**
  61734. * Sets the current viewport in normalized coordinates 0-1
  61735. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61736. */
  61737. setViewport(viewport?: Viewport): void;
  61738. /**
  61739. * Binds the embedded attributes buffer to the effect.
  61740. * @param effect Defines the effect to bind the attributes for
  61741. */
  61742. bindBuffers(effect: Effect): void;
  61743. /**
  61744. * Sets the current effect wrapper to use during draw.
  61745. * The effect needs to be ready before calling this api.
  61746. * This also sets the default full screen position attribute.
  61747. * @param effectWrapper Defines the effect to draw with
  61748. */
  61749. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61750. /**
  61751. * Restores engine states
  61752. */
  61753. restoreStates(): void;
  61754. /**
  61755. * Draws a full screen quad.
  61756. */
  61757. draw(): void;
  61758. private isRenderTargetTexture;
  61759. /**
  61760. * renders one or more effects to a specified texture
  61761. * @param effectWrapper the effect to renderer
  61762. * @param outputTexture texture to draw to, if null it will render to the screen.
  61763. */
  61764. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61765. /**
  61766. * Disposes of the effect renderer
  61767. */
  61768. dispose(): void;
  61769. }
  61770. /**
  61771. * Options to create an EffectWrapper
  61772. */
  61773. interface EffectWrapperCreationOptions {
  61774. /**
  61775. * Engine to use to create the effect
  61776. */
  61777. engine: ThinEngine;
  61778. /**
  61779. * Fragment shader for the effect
  61780. */
  61781. fragmentShader: string;
  61782. /**
  61783. * Use the shader store instead of direct source code
  61784. */
  61785. useShaderStore?: boolean;
  61786. /**
  61787. * Vertex shader for the effect
  61788. */
  61789. vertexShader?: string;
  61790. /**
  61791. * Attributes to use in the shader
  61792. */
  61793. attributeNames?: Array<string>;
  61794. /**
  61795. * Uniforms to use in the shader
  61796. */
  61797. uniformNames?: Array<string>;
  61798. /**
  61799. * Texture sampler names to use in the shader
  61800. */
  61801. samplerNames?: Array<string>;
  61802. /**
  61803. * Defines to use in the shader
  61804. */
  61805. defines?: Array<string>;
  61806. /**
  61807. * Callback when effect is compiled
  61808. */
  61809. onCompiled?: Nullable<(effect: Effect) => void>;
  61810. /**
  61811. * The friendly name of the effect displayed in Spector.
  61812. */
  61813. name?: string;
  61814. }
  61815. /**
  61816. * Wraps an effect to be used for rendering
  61817. */
  61818. export class EffectWrapper {
  61819. /**
  61820. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61821. */
  61822. onApplyObservable: Observable<{}>;
  61823. /**
  61824. * The underlying effect
  61825. */
  61826. effect: Effect;
  61827. /**
  61828. * Creates an effect to be renderer
  61829. * @param creationOptions options to create the effect
  61830. */
  61831. constructor(creationOptions: EffectWrapperCreationOptions);
  61832. /**
  61833. * Disposes of the effect wrapper
  61834. */
  61835. dispose(): void;
  61836. }
  61837. }
  61838. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61839. /** @hidden */
  61840. export var hdrFilteringVertexShader: {
  61841. name: string;
  61842. shader: string;
  61843. };
  61844. }
  61845. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61846. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61847. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61848. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61849. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61850. /** @hidden */
  61851. export var hdrFilteringPixelShader: {
  61852. name: string;
  61853. shader: string;
  61854. };
  61855. }
  61856. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61857. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61858. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61859. import { Nullable } from "babylonjs/types";
  61860. import "babylonjs/Shaders/hdrFiltering.vertex";
  61861. import "babylonjs/Shaders/hdrFiltering.fragment";
  61862. /**
  61863. * Options for texture filtering
  61864. */
  61865. interface IHDRFilteringOptions {
  61866. /**
  61867. * Scales pixel intensity for the input HDR map.
  61868. */
  61869. hdrScale?: number;
  61870. /**
  61871. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61872. */
  61873. quality?: number;
  61874. }
  61875. /**
  61876. * Filters HDR maps to get correct renderings of PBR reflections
  61877. */
  61878. export class HDRFiltering {
  61879. private _engine;
  61880. private _effectRenderer;
  61881. private _effectWrapper;
  61882. private _lodGenerationOffset;
  61883. private _lodGenerationScale;
  61884. /**
  61885. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61886. * you care about baking speed.
  61887. */
  61888. quality: number;
  61889. /**
  61890. * Scales pixel intensity for the input HDR map.
  61891. */
  61892. hdrScale: number;
  61893. /**
  61894. * Instantiates HDR filter for reflection maps
  61895. *
  61896. * @param engine Thin engine
  61897. * @param options Options
  61898. */
  61899. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61900. private _createRenderTarget;
  61901. private _prefilterInternal;
  61902. private _createEffect;
  61903. /**
  61904. * Get a value indicating if the filter is ready to be used
  61905. * @param texture Texture to filter
  61906. * @returns true if the filter is ready
  61907. */
  61908. isReady(texture: BaseTexture): boolean;
  61909. /**
  61910. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61911. * Prefiltering will be invoked at the end of next rendering pass.
  61912. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61913. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61914. * @param texture Texture to filter
  61915. * @param onFinished Callback when filtering is done
  61916. * @return Promise called when prefiltering is done
  61917. */
  61918. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61919. }
  61920. }
  61921. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61922. import { Nullable } from "babylonjs/types";
  61923. import { Scene } from "babylonjs/scene";
  61924. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61925. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61926. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61927. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61928. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61929. /**
  61930. * This represents a texture coming from an HDR input.
  61931. *
  61932. * The only supported format is currently panorama picture stored in RGBE format.
  61933. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61934. */
  61935. export class HDRCubeTexture extends BaseTexture {
  61936. private static _facesMapping;
  61937. private _generateHarmonics;
  61938. private _noMipmap;
  61939. private _prefilterOnLoad;
  61940. private _textureMatrix;
  61941. private _size;
  61942. private _onLoad;
  61943. private _onError;
  61944. /**
  61945. * The texture URL.
  61946. */
  61947. url: string;
  61948. /**
  61949. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61950. */
  61951. coordinatesMode: number;
  61952. protected _isBlocking: boolean;
  61953. /**
  61954. * Sets wether or not the texture is blocking during loading.
  61955. */
  61956. set isBlocking(value: boolean);
  61957. /**
  61958. * Gets wether or not the texture is blocking during loading.
  61959. */
  61960. get isBlocking(): boolean;
  61961. protected _rotationY: number;
  61962. /**
  61963. * Sets texture matrix rotation angle around Y axis in radians.
  61964. */
  61965. set rotationY(value: number);
  61966. /**
  61967. * Gets texture matrix rotation angle around Y axis radians.
  61968. */
  61969. get rotationY(): number;
  61970. /**
  61971. * Gets or sets the center of the bounding box associated with the cube texture
  61972. * It must define where the camera used to render the texture was set
  61973. */
  61974. boundingBoxPosition: Vector3;
  61975. private _boundingBoxSize;
  61976. /**
  61977. * Gets or sets the size of the bounding box associated with the cube texture
  61978. * When defined, the cubemap will switch to local mode
  61979. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61980. * @example https://www.babylonjs-playground.com/#RNASML
  61981. */
  61982. set boundingBoxSize(value: Vector3);
  61983. get boundingBoxSize(): Vector3;
  61984. /**
  61985. * Instantiates an HDRTexture from the following parameters.
  61986. *
  61987. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61988. * @param sceneOrEngine The scene or engine the texture will be used in
  61989. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61990. * @param noMipmap Forces to not generate the mipmap if true
  61991. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61992. * @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)
  61993. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61994. */
  61995. 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>);
  61996. /**
  61997. * Get the current class name of the texture useful for serialization or dynamic coding.
  61998. * @returns "HDRCubeTexture"
  61999. */
  62000. getClassName(): string;
  62001. /**
  62002. * Occurs when the file is raw .hdr file.
  62003. */
  62004. private loadTexture;
  62005. clone(): HDRCubeTexture;
  62006. delayLoad(): void;
  62007. /**
  62008. * Get the texture reflection matrix used to rotate/transform the reflection.
  62009. * @returns the reflection matrix
  62010. */
  62011. getReflectionTextureMatrix(): Matrix;
  62012. /**
  62013. * Set the texture reflection matrix used to rotate/transform the reflection.
  62014. * @param value Define the reflection matrix to set
  62015. */
  62016. setReflectionTextureMatrix(value: Matrix): void;
  62017. /**
  62018. * Parses a JSON representation of an HDR Texture in order to create the texture
  62019. * @param parsedTexture Define the JSON representation
  62020. * @param scene Define the scene the texture should be created in
  62021. * @param rootUrl Define the root url in case we need to load relative dependencies
  62022. * @returns the newly created texture after parsing
  62023. */
  62024. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62025. serialize(): any;
  62026. }
  62027. }
  62028. declare module "babylonjs/Physics/physicsEngine" {
  62029. import { Nullable } from "babylonjs/types";
  62030. import { Vector3 } from "babylonjs/Maths/math.vector";
  62031. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62032. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62033. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62034. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62035. /**
  62036. * Class used to control physics engine
  62037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62038. */
  62039. export class PhysicsEngine implements IPhysicsEngine {
  62040. private _physicsPlugin;
  62041. /**
  62042. * Global value used to control the smallest number supported by the simulation
  62043. */
  62044. static Epsilon: number;
  62045. private _impostors;
  62046. private _joints;
  62047. private _subTimeStep;
  62048. /**
  62049. * Gets the gravity vector used by the simulation
  62050. */
  62051. gravity: Vector3;
  62052. /**
  62053. * Factory used to create the default physics plugin.
  62054. * @returns The default physics plugin
  62055. */
  62056. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62057. /**
  62058. * Creates a new Physics Engine
  62059. * @param gravity defines the gravity vector used by the simulation
  62060. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62061. */
  62062. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62063. /**
  62064. * Sets the gravity vector used by the simulation
  62065. * @param gravity defines the gravity vector to use
  62066. */
  62067. setGravity(gravity: Vector3): void;
  62068. /**
  62069. * Set the time step of the physics engine.
  62070. * Default is 1/60.
  62071. * To slow it down, enter 1/600 for example.
  62072. * To speed it up, 1/30
  62073. * @param newTimeStep defines the new timestep to apply to this world.
  62074. */
  62075. setTimeStep(newTimeStep?: number): void;
  62076. /**
  62077. * Get the time step of the physics engine.
  62078. * @returns the current time step
  62079. */
  62080. getTimeStep(): number;
  62081. /**
  62082. * Set the sub time step of the physics engine.
  62083. * Default is 0 meaning there is no sub steps
  62084. * To increase physics resolution precision, set a small value (like 1 ms)
  62085. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62086. */
  62087. setSubTimeStep(subTimeStep?: number): void;
  62088. /**
  62089. * Get the sub time step of the physics engine.
  62090. * @returns the current sub time step
  62091. */
  62092. getSubTimeStep(): number;
  62093. /**
  62094. * Release all resources
  62095. */
  62096. dispose(): void;
  62097. /**
  62098. * Gets the name of the current physics plugin
  62099. * @returns the name of the plugin
  62100. */
  62101. getPhysicsPluginName(): string;
  62102. /**
  62103. * Adding a new impostor for the impostor tracking.
  62104. * This will be done by the impostor itself.
  62105. * @param impostor the impostor to add
  62106. */
  62107. addImpostor(impostor: PhysicsImpostor): void;
  62108. /**
  62109. * Remove an impostor from the engine.
  62110. * This impostor and its mesh will not longer be updated by the physics engine.
  62111. * @param impostor the impostor to remove
  62112. */
  62113. removeImpostor(impostor: PhysicsImpostor): void;
  62114. /**
  62115. * Add a joint to the physics engine
  62116. * @param mainImpostor defines the main impostor to which the joint is added.
  62117. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62118. * @param joint defines the joint that will connect both impostors.
  62119. */
  62120. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62121. /**
  62122. * Removes a joint from the simulation
  62123. * @param mainImpostor defines the impostor used with the joint
  62124. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62125. * @param joint defines the joint to remove
  62126. */
  62127. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62128. /**
  62129. * Called by the scene. No need to call it.
  62130. * @param delta defines the timespam between frames
  62131. */
  62132. _step(delta: number): void;
  62133. /**
  62134. * Gets the current plugin used to run the simulation
  62135. * @returns current plugin
  62136. */
  62137. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62138. /**
  62139. * Gets the list of physic impostors
  62140. * @returns an array of PhysicsImpostor
  62141. */
  62142. getImpostors(): Array<PhysicsImpostor>;
  62143. /**
  62144. * Gets the impostor for a physics enabled object
  62145. * @param object defines the object impersonated by the impostor
  62146. * @returns the PhysicsImpostor or null if not found
  62147. */
  62148. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62149. /**
  62150. * Gets the impostor for a physics body object
  62151. * @param body defines physics body used by the impostor
  62152. * @returns the PhysicsImpostor or null if not found
  62153. */
  62154. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62155. /**
  62156. * Does a raycast in the physics world
  62157. * @param from when should the ray start?
  62158. * @param to when should the ray end?
  62159. * @returns PhysicsRaycastResult
  62160. */
  62161. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62162. }
  62163. }
  62164. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  62165. import { Nullable } from "babylonjs/types";
  62166. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62168. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62169. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62170. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62171. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62172. /** @hidden */
  62173. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62174. private _useDeltaForWorldStep;
  62175. world: any;
  62176. name: string;
  62177. private _physicsMaterials;
  62178. private _fixedTimeStep;
  62179. private _cannonRaycastResult;
  62180. private _raycastResult;
  62181. private _physicsBodysToRemoveAfterStep;
  62182. private _firstFrame;
  62183. BJSCANNON: any;
  62184. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62185. setGravity(gravity: Vector3): void;
  62186. setTimeStep(timeStep: number): void;
  62187. getTimeStep(): number;
  62188. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62189. private _removeMarkedPhysicsBodiesFromWorld;
  62190. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62191. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62192. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62193. private _processChildMeshes;
  62194. removePhysicsBody(impostor: PhysicsImpostor): void;
  62195. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62196. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62197. private _addMaterial;
  62198. private _checkWithEpsilon;
  62199. private _createShape;
  62200. private _createHeightmap;
  62201. private _minus90X;
  62202. private _plus90X;
  62203. private _tmpPosition;
  62204. private _tmpDeltaPosition;
  62205. private _tmpUnityRotation;
  62206. private _updatePhysicsBodyTransformation;
  62207. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62208. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62209. isSupported(): boolean;
  62210. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62211. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62212. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62213. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62214. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62215. getBodyMass(impostor: PhysicsImpostor): number;
  62216. getBodyFriction(impostor: PhysicsImpostor): number;
  62217. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62218. getBodyRestitution(impostor: PhysicsImpostor): number;
  62219. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62220. sleepBody(impostor: PhysicsImpostor): void;
  62221. wakeUpBody(impostor: PhysicsImpostor): void;
  62222. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62223. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62224. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62225. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62226. getRadius(impostor: PhysicsImpostor): number;
  62227. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62228. dispose(): void;
  62229. private _extendNamespace;
  62230. /**
  62231. * Does a raycast in the physics world
  62232. * @param from when should the ray start?
  62233. * @param to when should the ray end?
  62234. * @returns PhysicsRaycastResult
  62235. */
  62236. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62237. }
  62238. }
  62239. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  62240. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62241. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62242. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62244. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62245. import { Nullable } from "babylonjs/types";
  62246. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62247. /** @hidden */
  62248. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62249. private _useDeltaForWorldStep;
  62250. world: any;
  62251. name: string;
  62252. BJSOIMO: any;
  62253. private _raycastResult;
  62254. private _fixedTimeStep;
  62255. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62256. setGravity(gravity: Vector3): void;
  62257. setTimeStep(timeStep: number): void;
  62258. getTimeStep(): number;
  62259. private _tmpImpostorsArray;
  62260. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62261. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62262. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62263. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62264. private _tmpPositionVector;
  62265. removePhysicsBody(impostor: PhysicsImpostor): void;
  62266. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62267. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62268. isSupported(): boolean;
  62269. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62270. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62271. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62272. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62273. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62274. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62275. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62276. getBodyMass(impostor: PhysicsImpostor): number;
  62277. getBodyFriction(impostor: PhysicsImpostor): number;
  62278. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62279. getBodyRestitution(impostor: PhysicsImpostor): number;
  62280. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62281. sleepBody(impostor: PhysicsImpostor): void;
  62282. wakeUpBody(impostor: PhysicsImpostor): void;
  62283. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62284. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62285. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62286. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62287. getRadius(impostor: PhysicsImpostor): number;
  62288. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62289. dispose(): void;
  62290. /**
  62291. * Does a raycast in the physics world
  62292. * @param from when should the ray start?
  62293. * @param to when should the ray end?
  62294. * @returns PhysicsRaycastResult
  62295. */
  62296. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62297. }
  62298. }
  62299. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  62300. import { Nullable } from "babylonjs/types";
  62301. import { Scene } from "babylonjs/scene";
  62302. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  62303. import { Color4 } from "babylonjs/Maths/math.color";
  62304. import { Mesh } from "babylonjs/Meshes/mesh";
  62305. /**
  62306. * Class containing static functions to help procedurally build meshes
  62307. */
  62308. export class RibbonBuilder {
  62309. /**
  62310. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62311. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62312. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62313. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62314. * * 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
  62315. * * 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
  62316. * * 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
  62317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62318. * * 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
  62319. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62320. * * 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
  62321. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62322. * * 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
  62323. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62325. * @param name defines the name of the mesh
  62326. * @param options defines the options used to create the mesh
  62327. * @param scene defines the hosting scene
  62328. * @returns the ribbon mesh
  62329. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62330. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62331. */
  62332. static CreateRibbon(name: string, options: {
  62333. pathArray: Vector3[][];
  62334. closeArray?: boolean;
  62335. closePath?: boolean;
  62336. offset?: number;
  62337. updatable?: boolean;
  62338. sideOrientation?: number;
  62339. frontUVs?: Vector4;
  62340. backUVs?: Vector4;
  62341. instance?: Mesh;
  62342. invertUV?: boolean;
  62343. uvs?: Vector2[];
  62344. colors?: Color4[];
  62345. }, scene?: Nullable<Scene>): Mesh;
  62346. }
  62347. }
  62348. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  62349. import { Nullable } from "babylonjs/types";
  62350. import { Scene } from "babylonjs/scene";
  62351. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62352. import { Mesh } from "babylonjs/Meshes/mesh";
  62353. /**
  62354. * Class containing static functions to help procedurally build meshes
  62355. */
  62356. export class ShapeBuilder {
  62357. /**
  62358. * 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.
  62359. * * 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.
  62360. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62361. * * 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.
  62362. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62363. * * 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
  62364. * * 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
  62365. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62367. * * 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
  62368. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62370. * @param name defines the name of the mesh
  62371. * @param options defines the options used to create the mesh
  62372. * @param scene defines the hosting scene
  62373. * @returns the extruded shape mesh
  62374. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62375. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62376. */
  62377. static ExtrudeShape(name: string, options: {
  62378. shape: Vector3[];
  62379. path: Vector3[];
  62380. scale?: number;
  62381. rotation?: number;
  62382. cap?: number;
  62383. updatable?: boolean;
  62384. sideOrientation?: number;
  62385. frontUVs?: Vector4;
  62386. backUVs?: Vector4;
  62387. instance?: Mesh;
  62388. invertUV?: boolean;
  62389. }, scene?: Nullable<Scene>): Mesh;
  62390. /**
  62391. * Creates an custom extruded shape mesh.
  62392. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62393. * * 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.
  62394. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62395. * * 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
  62396. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62397. * * 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
  62398. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62399. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62400. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62401. * * 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
  62402. * * 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
  62403. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62405. * * 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
  62406. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62408. * @param name defines the name of the mesh
  62409. * @param options defines the options used to create the mesh
  62410. * @param scene defines the hosting scene
  62411. * @returns the custom extruded shape mesh
  62412. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62413. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62414. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62415. */
  62416. static ExtrudeShapeCustom(name: string, options: {
  62417. shape: Vector3[];
  62418. path: Vector3[];
  62419. scaleFunction?: any;
  62420. rotationFunction?: any;
  62421. ribbonCloseArray?: boolean;
  62422. ribbonClosePath?: boolean;
  62423. cap?: number;
  62424. updatable?: boolean;
  62425. sideOrientation?: number;
  62426. frontUVs?: Vector4;
  62427. backUVs?: Vector4;
  62428. instance?: Mesh;
  62429. invertUV?: boolean;
  62430. }, scene?: Nullable<Scene>): Mesh;
  62431. private static _ExtrudeShapeGeneric;
  62432. }
  62433. }
  62434. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62435. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62436. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62437. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62438. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62439. import { Nullable } from "babylonjs/types";
  62440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62441. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62442. /**
  62443. * AmmoJS Physics plugin
  62444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62445. * @see https://github.com/kripken/ammo.js/
  62446. */
  62447. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62448. private _useDeltaForWorldStep;
  62449. /**
  62450. * Reference to the Ammo library
  62451. */
  62452. bjsAMMO: any;
  62453. /**
  62454. * Created ammoJS world which physics bodies are added to
  62455. */
  62456. world: any;
  62457. /**
  62458. * Name of the plugin
  62459. */
  62460. name: string;
  62461. private _timeStep;
  62462. private _fixedTimeStep;
  62463. private _maxSteps;
  62464. private _tmpQuaternion;
  62465. private _tmpAmmoTransform;
  62466. private _tmpAmmoQuaternion;
  62467. private _tmpAmmoConcreteContactResultCallback;
  62468. private _collisionConfiguration;
  62469. private _dispatcher;
  62470. private _overlappingPairCache;
  62471. private _solver;
  62472. private _softBodySolver;
  62473. private _tmpAmmoVectorA;
  62474. private _tmpAmmoVectorB;
  62475. private _tmpAmmoVectorC;
  62476. private _tmpAmmoVectorD;
  62477. private _tmpContactCallbackResult;
  62478. private _tmpAmmoVectorRCA;
  62479. private _tmpAmmoVectorRCB;
  62480. private _raycastResult;
  62481. private static readonly DISABLE_COLLISION_FLAG;
  62482. private static readonly KINEMATIC_FLAG;
  62483. private static readonly DISABLE_DEACTIVATION_FLAG;
  62484. /**
  62485. * Initializes the ammoJS plugin
  62486. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62487. * @param ammoInjection can be used to inject your own ammo reference
  62488. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62489. */
  62490. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62491. /**
  62492. * Sets the gravity of the physics world (m/(s^2))
  62493. * @param gravity Gravity to set
  62494. */
  62495. setGravity(gravity: Vector3): void;
  62496. /**
  62497. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62498. * @param timeStep timestep to use in seconds
  62499. */
  62500. setTimeStep(timeStep: number): void;
  62501. /**
  62502. * 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)
  62503. * @param fixedTimeStep fixedTimeStep to use in seconds
  62504. */
  62505. setFixedTimeStep(fixedTimeStep: number): void;
  62506. /**
  62507. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62508. * @param maxSteps the maximum number of steps by the physics engine per frame
  62509. */
  62510. setMaxSteps(maxSteps: number): void;
  62511. /**
  62512. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62513. * @returns the current timestep in seconds
  62514. */
  62515. getTimeStep(): number;
  62516. /**
  62517. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62518. */
  62519. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62520. private _isImpostorInContact;
  62521. private _isImpostorPairInContact;
  62522. private _stepSimulation;
  62523. /**
  62524. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62525. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62526. * After the step the babylon meshes are set to the position of the physics imposters
  62527. * @param delta amount of time to step forward
  62528. * @param impostors array of imposters to update before/after the step
  62529. */
  62530. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62531. /**
  62532. * Update babylon mesh to match physics world object
  62533. * @param impostor imposter to match
  62534. */
  62535. private _afterSoftStep;
  62536. /**
  62537. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62538. * @param impostor imposter to match
  62539. */
  62540. private _ropeStep;
  62541. /**
  62542. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62543. * @param impostor imposter to match
  62544. */
  62545. private _softbodyOrClothStep;
  62546. private _tmpMatrix;
  62547. /**
  62548. * Applies an impulse on the imposter
  62549. * @param impostor imposter to apply impulse to
  62550. * @param force amount of force to be applied to the imposter
  62551. * @param contactPoint the location to apply the impulse on the imposter
  62552. */
  62553. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62554. /**
  62555. * Applies a force on the imposter
  62556. * @param impostor imposter to apply force
  62557. * @param force amount of force to be applied to the imposter
  62558. * @param contactPoint the location to apply the force on the imposter
  62559. */
  62560. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62561. /**
  62562. * Creates a physics body using the plugin
  62563. * @param impostor the imposter to create the physics body on
  62564. */
  62565. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62566. /**
  62567. * Removes the physics body from the imposter and disposes of the body's memory
  62568. * @param impostor imposter to remove the physics body from
  62569. */
  62570. removePhysicsBody(impostor: PhysicsImpostor): void;
  62571. /**
  62572. * Generates a joint
  62573. * @param impostorJoint the imposter joint to create the joint with
  62574. */
  62575. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62576. /**
  62577. * Removes a joint
  62578. * @param impostorJoint the imposter joint to remove the joint from
  62579. */
  62580. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62581. private _addMeshVerts;
  62582. /**
  62583. * Initialise the soft body vertices to match its object's (mesh) vertices
  62584. * Softbody vertices (nodes) are in world space and to match this
  62585. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62586. * @param impostor to create the softbody for
  62587. */
  62588. private _softVertexData;
  62589. /**
  62590. * Create an impostor's soft body
  62591. * @param impostor to create the softbody for
  62592. */
  62593. private _createSoftbody;
  62594. /**
  62595. * Create cloth for an impostor
  62596. * @param impostor to create the softbody for
  62597. */
  62598. private _createCloth;
  62599. /**
  62600. * Create rope for an impostor
  62601. * @param impostor to create the softbody for
  62602. */
  62603. private _createRope;
  62604. /**
  62605. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62606. * @param impostor to create the custom physics shape for
  62607. */
  62608. private _createCustom;
  62609. private _addHullVerts;
  62610. private _createShape;
  62611. /**
  62612. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62613. * @param impostor imposter containing the physics body and babylon object
  62614. */
  62615. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62616. /**
  62617. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62618. * @param impostor imposter containing the physics body and babylon object
  62619. * @param newPosition new position
  62620. * @param newRotation new rotation
  62621. */
  62622. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62623. /**
  62624. * If this plugin is supported
  62625. * @returns true if its supported
  62626. */
  62627. isSupported(): boolean;
  62628. /**
  62629. * Sets the linear velocity of the physics body
  62630. * @param impostor imposter to set the velocity on
  62631. * @param velocity velocity to set
  62632. */
  62633. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62634. /**
  62635. * Sets the angular velocity of the physics body
  62636. * @param impostor imposter to set the velocity on
  62637. * @param velocity velocity to set
  62638. */
  62639. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62640. /**
  62641. * gets the linear velocity
  62642. * @param impostor imposter to get linear velocity from
  62643. * @returns linear velocity
  62644. */
  62645. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62646. /**
  62647. * gets the angular velocity
  62648. * @param impostor imposter to get angular velocity from
  62649. * @returns angular velocity
  62650. */
  62651. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62652. /**
  62653. * Sets the mass of physics body
  62654. * @param impostor imposter to set the mass on
  62655. * @param mass mass to set
  62656. */
  62657. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62658. /**
  62659. * Gets the mass of the physics body
  62660. * @param impostor imposter to get the mass from
  62661. * @returns mass
  62662. */
  62663. getBodyMass(impostor: PhysicsImpostor): number;
  62664. /**
  62665. * Gets friction of the impostor
  62666. * @param impostor impostor to get friction from
  62667. * @returns friction value
  62668. */
  62669. getBodyFriction(impostor: PhysicsImpostor): number;
  62670. /**
  62671. * Sets friction of the impostor
  62672. * @param impostor impostor to set friction on
  62673. * @param friction friction value
  62674. */
  62675. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62676. /**
  62677. * Gets restitution of the impostor
  62678. * @param impostor impostor to get restitution from
  62679. * @returns restitution value
  62680. */
  62681. getBodyRestitution(impostor: PhysicsImpostor): number;
  62682. /**
  62683. * Sets resitution of the impostor
  62684. * @param impostor impostor to set resitution on
  62685. * @param restitution resitution value
  62686. */
  62687. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62688. /**
  62689. * Gets pressure inside the impostor
  62690. * @param impostor impostor to get pressure from
  62691. * @returns pressure value
  62692. */
  62693. getBodyPressure(impostor: PhysicsImpostor): number;
  62694. /**
  62695. * Sets pressure inside a soft body impostor
  62696. * Cloth and rope must remain 0 pressure
  62697. * @param impostor impostor to set pressure on
  62698. * @param pressure pressure value
  62699. */
  62700. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62701. /**
  62702. * Gets stiffness of the impostor
  62703. * @param impostor impostor to get stiffness from
  62704. * @returns pressure value
  62705. */
  62706. getBodyStiffness(impostor: PhysicsImpostor): number;
  62707. /**
  62708. * Sets stiffness of the impostor
  62709. * @param impostor impostor to set stiffness on
  62710. * @param stiffness stiffness value from 0 to 1
  62711. */
  62712. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62713. /**
  62714. * Gets velocityIterations of the impostor
  62715. * @param impostor impostor to get velocity iterations from
  62716. * @returns velocityIterations value
  62717. */
  62718. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62719. /**
  62720. * Sets velocityIterations of the impostor
  62721. * @param impostor impostor to set velocity iterations on
  62722. * @param velocityIterations velocityIterations value
  62723. */
  62724. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62725. /**
  62726. * Gets positionIterations of the impostor
  62727. * @param impostor impostor to get position iterations from
  62728. * @returns positionIterations value
  62729. */
  62730. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62731. /**
  62732. * Sets positionIterations of the impostor
  62733. * @param impostor impostor to set position on
  62734. * @param positionIterations positionIterations value
  62735. */
  62736. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62737. /**
  62738. * Append an anchor to a cloth object
  62739. * @param impostor is the cloth impostor to add anchor to
  62740. * @param otherImpostor is the rigid impostor to anchor to
  62741. * @param width ratio across width from 0 to 1
  62742. * @param height ratio up height from 0 to 1
  62743. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62744. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62745. */
  62746. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62747. /**
  62748. * Append an hook to a rope object
  62749. * @param impostor is the rope impostor to add hook to
  62750. * @param otherImpostor is the rigid impostor to hook to
  62751. * @param length ratio along the rope from 0 to 1
  62752. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62753. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62754. */
  62755. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62756. /**
  62757. * Sleeps the physics body and stops it from being active
  62758. * @param impostor impostor to sleep
  62759. */
  62760. sleepBody(impostor: PhysicsImpostor): void;
  62761. /**
  62762. * Activates the physics body
  62763. * @param impostor impostor to activate
  62764. */
  62765. wakeUpBody(impostor: PhysicsImpostor): void;
  62766. /**
  62767. * Updates the distance parameters of the joint
  62768. * @param joint joint to update
  62769. * @param maxDistance maximum distance of the joint
  62770. * @param minDistance minimum distance of the joint
  62771. */
  62772. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62773. /**
  62774. * Sets a motor on the joint
  62775. * @param joint joint to set motor on
  62776. * @param speed speed of the motor
  62777. * @param maxForce maximum force of the motor
  62778. * @param motorIndex index of the motor
  62779. */
  62780. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62781. /**
  62782. * Sets the motors limit
  62783. * @param joint joint to set limit on
  62784. * @param upperLimit upper limit
  62785. * @param lowerLimit lower limit
  62786. */
  62787. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62788. /**
  62789. * Syncs the position and rotation of a mesh with the impostor
  62790. * @param mesh mesh to sync
  62791. * @param impostor impostor to update the mesh with
  62792. */
  62793. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62794. /**
  62795. * Gets the radius of the impostor
  62796. * @param impostor impostor to get radius from
  62797. * @returns the radius
  62798. */
  62799. getRadius(impostor: PhysicsImpostor): number;
  62800. /**
  62801. * Gets the box size of the impostor
  62802. * @param impostor impostor to get box size from
  62803. * @param result the resulting box size
  62804. */
  62805. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62806. /**
  62807. * Disposes of the impostor
  62808. */
  62809. dispose(): void;
  62810. /**
  62811. * Does a raycast in the physics world
  62812. * @param from when should the ray start?
  62813. * @param to when should the ray end?
  62814. * @returns PhysicsRaycastResult
  62815. */
  62816. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62817. }
  62818. }
  62819. declare module "babylonjs/Probes/reflectionProbe" {
  62820. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62821. import { Vector3 } from "babylonjs/Maths/math.vector";
  62822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62823. import { Nullable } from "babylonjs/types";
  62824. import { Scene } from "babylonjs/scene";
  62825. module "babylonjs/abstractScene" {
  62826. interface AbstractScene {
  62827. /**
  62828. * The list of reflection probes added to the scene
  62829. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62830. */
  62831. reflectionProbes: Array<ReflectionProbe>;
  62832. /**
  62833. * Removes the given reflection probe from this scene.
  62834. * @param toRemove The reflection probe to remove
  62835. * @returns The index of the removed reflection probe
  62836. */
  62837. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62838. /**
  62839. * Adds the given reflection probe to this scene.
  62840. * @param newReflectionProbe The reflection probe to add
  62841. */
  62842. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62843. }
  62844. }
  62845. /**
  62846. * Class used to generate realtime reflection / refraction cube textures
  62847. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62848. */
  62849. export class ReflectionProbe {
  62850. /** defines the name of the probe */
  62851. name: string;
  62852. private _scene;
  62853. private _renderTargetTexture;
  62854. private _projectionMatrix;
  62855. private _viewMatrix;
  62856. private _target;
  62857. private _add;
  62858. private _attachedMesh;
  62859. private _invertYAxis;
  62860. /** Gets or sets probe position (center of the cube map) */
  62861. position: Vector3;
  62862. /**
  62863. * Creates a new reflection probe
  62864. * @param name defines the name of the probe
  62865. * @param size defines the texture resolution (for each face)
  62866. * @param scene defines the hosting scene
  62867. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62868. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62869. */
  62870. constructor(
  62871. /** defines the name of the probe */
  62872. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62873. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62874. get samples(): number;
  62875. set samples(value: number);
  62876. /** Gets or sets the refresh rate to use (on every frame by default) */
  62877. get refreshRate(): number;
  62878. set refreshRate(value: number);
  62879. /**
  62880. * Gets the hosting scene
  62881. * @returns a Scene
  62882. */
  62883. getScene(): Scene;
  62884. /** Gets the internal CubeTexture used to render to */
  62885. get cubeTexture(): RenderTargetTexture;
  62886. /** Gets the list of meshes to render */
  62887. get renderList(): Nullable<AbstractMesh[]>;
  62888. /**
  62889. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62890. * @param mesh defines the mesh to attach to
  62891. */
  62892. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62893. /**
  62894. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62895. * @param renderingGroupId The rendering group id corresponding to its index
  62896. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62897. */
  62898. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62899. /**
  62900. * Clean all associated resources
  62901. */
  62902. dispose(): void;
  62903. /**
  62904. * Converts the reflection probe information to a readable string for debug purpose.
  62905. * @param fullDetails Supports for multiple levels of logging within scene loading
  62906. * @returns the human readable reflection probe info
  62907. */
  62908. toString(fullDetails?: boolean): string;
  62909. /**
  62910. * Get the class name of the relfection probe.
  62911. * @returns "ReflectionProbe"
  62912. */
  62913. getClassName(): string;
  62914. /**
  62915. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62916. * @returns The JSON representation of the texture
  62917. */
  62918. serialize(): any;
  62919. /**
  62920. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62921. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62922. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62923. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62924. * @returns The parsed reflection probe if successful
  62925. */
  62926. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62927. }
  62928. }
  62929. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62930. /** @hidden */
  62931. export var _BabylonLoaderRegistered: boolean;
  62932. /**
  62933. * Helps setting up some configuration for the babylon file loader.
  62934. */
  62935. export class BabylonFileLoaderConfiguration {
  62936. /**
  62937. * The loader does not allow injecting custom physix engine into the plugins.
  62938. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62939. * So you could set this variable to your engine import to make it work.
  62940. */
  62941. static LoaderInjectedPhysicsEngine: any;
  62942. }
  62943. }
  62944. declare module "babylonjs/Loading/Plugins/index" {
  62945. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62946. }
  62947. declare module "babylonjs/Loading/index" {
  62948. export * from "babylonjs/Loading/loadingScreen";
  62949. export * from "babylonjs/Loading/Plugins/index";
  62950. export * from "babylonjs/Loading/sceneLoader";
  62951. export * from "babylonjs/Loading/sceneLoaderFlags";
  62952. }
  62953. declare module "babylonjs/Materials/Background/index" {
  62954. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62955. }
  62956. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62957. import { Scene } from "babylonjs/scene";
  62958. import { Color3 } from "babylonjs/Maths/math.color";
  62959. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62960. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62961. /**
  62962. * The Physically based simple base material of BJS.
  62963. *
  62964. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62965. * It is used as the base class for both the specGloss and metalRough conventions.
  62966. */
  62967. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62968. /**
  62969. * Number of Simultaneous lights allowed on the material.
  62970. */
  62971. maxSimultaneousLights: number;
  62972. /**
  62973. * If sets to true, disables all the lights affecting the material.
  62974. */
  62975. disableLighting: boolean;
  62976. /**
  62977. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62978. */
  62979. environmentTexture: BaseTexture;
  62980. /**
  62981. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62982. */
  62983. invertNormalMapX: boolean;
  62984. /**
  62985. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62986. */
  62987. invertNormalMapY: boolean;
  62988. /**
  62989. * Normal map used in the model.
  62990. */
  62991. normalTexture: BaseTexture;
  62992. /**
  62993. * Emissivie color used to self-illuminate the model.
  62994. */
  62995. emissiveColor: Color3;
  62996. /**
  62997. * Emissivie texture used to self-illuminate the model.
  62998. */
  62999. emissiveTexture: BaseTexture;
  63000. /**
  63001. * Occlusion Channel Strenght.
  63002. */
  63003. occlusionStrength: number;
  63004. /**
  63005. * Occlusion Texture of the material (adding extra occlusion effects).
  63006. */
  63007. occlusionTexture: BaseTexture;
  63008. /**
  63009. * Defines the alpha limits in alpha test mode.
  63010. */
  63011. alphaCutOff: number;
  63012. /**
  63013. * Gets the current double sided mode.
  63014. */
  63015. get doubleSided(): boolean;
  63016. /**
  63017. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63018. */
  63019. set doubleSided(value: boolean);
  63020. /**
  63021. * Stores the pre-calculated light information of a mesh in a texture.
  63022. */
  63023. lightmapTexture: BaseTexture;
  63024. /**
  63025. * If true, the light map contains occlusion information instead of lighting info.
  63026. */
  63027. useLightmapAsShadowmap: boolean;
  63028. /**
  63029. * Instantiates a new PBRMaterial instance.
  63030. *
  63031. * @param name The material name
  63032. * @param scene The scene the material will be use in.
  63033. */
  63034. constructor(name: string, scene: Scene);
  63035. getClassName(): string;
  63036. }
  63037. }
  63038. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63039. import { Scene } from "babylonjs/scene";
  63040. import { Color3 } from "babylonjs/Maths/math.color";
  63041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63042. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63043. /**
  63044. * The PBR material of BJS following the metal roughness convention.
  63045. *
  63046. * This fits to the PBR convention in the GLTF definition:
  63047. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63048. */
  63049. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63050. /**
  63051. * The base color has two different interpretations depending on the value of metalness.
  63052. * When the material is a metal, the base color is the specific measured reflectance value
  63053. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63054. * of the material.
  63055. */
  63056. baseColor: Color3;
  63057. /**
  63058. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63059. * well as opacity information in the alpha channel.
  63060. */
  63061. baseTexture: BaseTexture;
  63062. /**
  63063. * Specifies the metallic scalar value of the material.
  63064. * Can also be used to scale the metalness values of the metallic texture.
  63065. */
  63066. metallic: number;
  63067. /**
  63068. * Specifies the roughness scalar value of the material.
  63069. * Can also be used to scale the roughness values of the metallic texture.
  63070. */
  63071. roughness: number;
  63072. /**
  63073. * Texture containing both the metallic value in the B channel and the
  63074. * roughness value in the G channel to keep better precision.
  63075. */
  63076. metallicRoughnessTexture: BaseTexture;
  63077. /**
  63078. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63079. *
  63080. * @param name The material name
  63081. * @param scene The scene the material will be use in.
  63082. */
  63083. constructor(name: string, scene: Scene);
  63084. /**
  63085. * Return the currrent class name of the material.
  63086. */
  63087. getClassName(): string;
  63088. /**
  63089. * Makes a duplicate of the current material.
  63090. * @param name - name to use for the new material.
  63091. */
  63092. clone(name: string): PBRMetallicRoughnessMaterial;
  63093. /**
  63094. * Serialize the material to a parsable JSON object.
  63095. */
  63096. serialize(): any;
  63097. /**
  63098. * Parses a JSON object correponding to the serialize function.
  63099. */
  63100. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63101. }
  63102. }
  63103. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63104. import { Scene } from "babylonjs/scene";
  63105. import { Color3 } from "babylonjs/Maths/math.color";
  63106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63107. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63108. /**
  63109. * The PBR material of BJS following the specular glossiness convention.
  63110. *
  63111. * This fits to the PBR convention in the GLTF definition:
  63112. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63113. */
  63114. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63115. /**
  63116. * Specifies the diffuse color of the material.
  63117. */
  63118. diffuseColor: Color3;
  63119. /**
  63120. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63121. * channel.
  63122. */
  63123. diffuseTexture: BaseTexture;
  63124. /**
  63125. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63126. */
  63127. specularColor: Color3;
  63128. /**
  63129. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63130. */
  63131. glossiness: number;
  63132. /**
  63133. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63134. */
  63135. specularGlossinessTexture: BaseTexture;
  63136. /**
  63137. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63138. *
  63139. * @param name The material name
  63140. * @param scene The scene the material will be use in.
  63141. */
  63142. constructor(name: string, scene: Scene);
  63143. /**
  63144. * Return the currrent class name of the material.
  63145. */
  63146. getClassName(): string;
  63147. /**
  63148. * Makes a duplicate of the current material.
  63149. * @param name - name to use for the new material.
  63150. */
  63151. clone(name: string): PBRSpecularGlossinessMaterial;
  63152. /**
  63153. * Serialize the material to a parsable JSON object.
  63154. */
  63155. serialize(): any;
  63156. /**
  63157. * Parses a JSON object correponding to the serialize function.
  63158. */
  63159. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63160. }
  63161. }
  63162. declare module "babylonjs/Materials/PBR/index" {
  63163. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63164. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63165. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63166. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63167. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63168. }
  63169. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63170. import { Nullable } from "babylonjs/types";
  63171. import { Scene } from "babylonjs/scene";
  63172. import { Matrix } from "babylonjs/Maths/math.vector";
  63173. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63174. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63175. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63176. /**
  63177. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63178. * It can help converting any input color in a desired output one. This can then be used to create effects
  63179. * from sepia, black and white to sixties or futuristic rendering...
  63180. *
  63181. * The only supported format is currently 3dl.
  63182. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63183. */
  63184. export class ColorGradingTexture extends BaseTexture {
  63185. /**
  63186. * The texture URL.
  63187. */
  63188. url: string;
  63189. /**
  63190. * Empty line regex stored for GC.
  63191. */
  63192. private static _noneEmptyLineRegex;
  63193. private _textureMatrix;
  63194. private _onLoad;
  63195. /**
  63196. * Instantiates a ColorGradingTexture from the following parameters.
  63197. *
  63198. * @param url The location of the color gradind data (currently only supporting 3dl)
  63199. * @param sceneOrEngine The scene or engine the texture will be used in
  63200. * @param onLoad defines a callback triggered when the texture has been loaded
  63201. */
  63202. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63203. /**
  63204. * Fires the onload event from the constructor if requested.
  63205. */
  63206. private _triggerOnLoad;
  63207. /**
  63208. * Returns the texture matrix used in most of the material.
  63209. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63210. */
  63211. getTextureMatrix(): Matrix;
  63212. /**
  63213. * Occurs when the file being loaded is a .3dl LUT file.
  63214. */
  63215. private load3dlTexture;
  63216. /**
  63217. * Starts the loading process of the texture.
  63218. */
  63219. private loadTexture;
  63220. /**
  63221. * Clones the color gradind texture.
  63222. */
  63223. clone(): ColorGradingTexture;
  63224. /**
  63225. * Called during delayed load for textures.
  63226. */
  63227. delayLoad(): void;
  63228. /**
  63229. * Parses a color grading texture serialized by Babylon.
  63230. * @param parsedTexture The texture information being parsedTexture
  63231. * @param scene The scene to load the texture in
  63232. * @param rootUrl The root url of the data assets to load
  63233. * @return A color gradind texture
  63234. */
  63235. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63236. /**
  63237. * Serializes the LUT texture to json format.
  63238. */
  63239. serialize(): any;
  63240. }
  63241. }
  63242. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63244. import { Scene } from "babylonjs/scene";
  63245. import { Nullable } from "babylonjs/types";
  63246. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63247. /**
  63248. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63249. */
  63250. export class EquiRectangularCubeTexture extends BaseTexture {
  63251. /** The six faces of the cube. */
  63252. private static _FacesMapping;
  63253. private _noMipmap;
  63254. private _onLoad;
  63255. private _onError;
  63256. /** The size of the cubemap. */
  63257. private _size;
  63258. /** The buffer of the image. */
  63259. private _buffer;
  63260. /** The width of the input image. */
  63261. private _width;
  63262. /** The height of the input image. */
  63263. private _height;
  63264. /** The URL to the image. */
  63265. url: string;
  63266. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63267. coordinatesMode: number;
  63268. /**
  63269. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63270. * @param url The location of the image
  63271. * @param scene The scene the texture will be used in
  63272. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63273. * @param noMipmap Forces to not generate the mipmap if true
  63274. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63275. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63276. * @param onLoad — defines a callback called when texture is loaded
  63277. * @param onError — defines a callback called if there is an error
  63278. */
  63279. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63280. /**
  63281. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63282. */
  63283. private loadImage;
  63284. /**
  63285. * Convert the image buffer into a cubemap and create a CubeTexture.
  63286. */
  63287. private loadTexture;
  63288. /**
  63289. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63290. * @param buffer The ArrayBuffer that should be converted.
  63291. * @returns The buffer as Float32Array.
  63292. */
  63293. private getFloat32ArrayFromArrayBuffer;
  63294. /**
  63295. * Get the current class name of the texture useful for serialization or dynamic coding.
  63296. * @returns "EquiRectangularCubeTexture"
  63297. */
  63298. getClassName(): string;
  63299. /**
  63300. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63301. * @returns A clone of the current EquiRectangularCubeTexture.
  63302. */
  63303. clone(): EquiRectangularCubeTexture;
  63304. }
  63305. }
  63306. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63307. import { Nullable } from "babylonjs/types";
  63308. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63309. import { Matrix } from "babylonjs/Maths/math.vector";
  63310. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63311. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63312. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63313. import { Scene } from "babylonjs/scene";
  63314. /**
  63315. * Defines the options related to the creation of an HtmlElementTexture
  63316. */
  63317. export interface IHtmlElementTextureOptions {
  63318. /**
  63319. * Defines wether mip maps should be created or not.
  63320. */
  63321. generateMipMaps?: boolean;
  63322. /**
  63323. * Defines the sampling mode of the texture.
  63324. */
  63325. samplingMode?: number;
  63326. /**
  63327. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63328. */
  63329. engine: Nullable<ThinEngine>;
  63330. /**
  63331. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63332. */
  63333. scene: Nullable<Scene>;
  63334. }
  63335. /**
  63336. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63337. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63338. * is automatically managed.
  63339. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63340. * in your application.
  63341. *
  63342. * As the update is not automatic, you need to call them manually.
  63343. */
  63344. export class HtmlElementTexture extends BaseTexture {
  63345. /**
  63346. * The texture URL.
  63347. */
  63348. element: HTMLVideoElement | HTMLCanvasElement;
  63349. private static readonly DefaultOptions;
  63350. private _textureMatrix;
  63351. private _isVideo;
  63352. private _generateMipMaps;
  63353. private _samplingMode;
  63354. /**
  63355. * Instantiates a HtmlElementTexture from the following parameters.
  63356. *
  63357. * @param name Defines the name of the texture
  63358. * @param element Defines the video or canvas the texture is filled with
  63359. * @param options Defines the other none mandatory texture creation options
  63360. */
  63361. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63362. private _createInternalTexture;
  63363. /**
  63364. * Returns the texture matrix used in most of the material.
  63365. */
  63366. getTextureMatrix(): Matrix;
  63367. /**
  63368. * Updates the content of the texture.
  63369. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63370. */
  63371. update(invertY?: Nullable<boolean>): void;
  63372. }
  63373. }
  63374. declare module "babylonjs/Misc/tga" {
  63375. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63376. /**
  63377. * Based on jsTGALoader - Javascript loader for TGA file
  63378. * By Vincent Thibault
  63379. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63380. */
  63381. export class TGATools {
  63382. private static _TYPE_INDEXED;
  63383. private static _TYPE_RGB;
  63384. private static _TYPE_GREY;
  63385. private static _TYPE_RLE_INDEXED;
  63386. private static _TYPE_RLE_RGB;
  63387. private static _TYPE_RLE_GREY;
  63388. private static _ORIGIN_MASK;
  63389. private static _ORIGIN_SHIFT;
  63390. private static _ORIGIN_BL;
  63391. private static _ORIGIN_BR;
  63392. private static _ORIGIN_UL;
  63393. private static _ORIGIN_UR;
  63394. /**
  63395. * Gets the header of a TGA file
  63396. * @param data defines the TGA data
  63397. * @returns the header
  63398. */
  63399. static GetTGAHeader(data: Uint8Array): any;
  63400. /**
  63401. * Uploads TGA content to a Babylon Texture
  63402. * @hidden
  63403. */
  63404. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63405. /** @hidden */
  63406. 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;
  63407. /** @hidden */
  63408. 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;
  63409. /** @hidden */
  63410. 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;
  63411. /** @hidden */
  63412. 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;
  63413. /** @hidden */
  63414. 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;
  63415. /** @hidden */
  63416. 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;
  63417. }
  63418. }
  63419. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63420. import { Nullable } from "babylonjs/types";
  63421. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63422. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63423. /**
  63424. * Implementation of the TGA Texture Loader.
  63425. * @hidden
  63426. */
  63427. export class _TGATextureLoader implements IInternalTextureLoader {
  63428. /**
  63429. * Defines wether the loader supports cascade loading the different faces.
  63430. */
  63431. readonly supportCascades: boolean;
  63432. /**
  63433. * This returns if the loader support the current file information.
  63434. * @param extension defines the file extension of the file being loaded
  63435. * @returns true if the loader can load the specified file
  63436. */
  63437. canLoad(extension: string): boolean;
  63438. /**
  63439. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63440. * @param data contains the texture data
  63441. * @param texture defines the BabylonJS internal texture
  63442. * @param createPolynomials will be true if polynomials have been requested
  63443. * @param onLoad defines the callback to trigger once the texture is ready
  63444. * @param onError defines the callback to trigger in case of error
  63445. */
  63446. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63447. /**
  63448. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63449. * @param data contains the texture data
  63450. * @param texture defines the BabylonJS internal texture
  63451. * @param callback defines the method to call once ready to upload
  63452. */
  63453. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63454. }
  63455. }
  63456. declare module "babylonjs/Misc/basis" {
  63457. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63458. /**
  63459. * Info about the .basis files
  63460. */
  63461. class BasisFileInfo {
  63462. /**
  63463. * If the file has alpha
  63464. */
  63465. hasAlpha: boolean;
  63466. /**
  63467. * Info about each image of the basis file
  63468. */
  63469. images: Array<{
  63470. levels: Array<{
  63471. width: number;
  63472. height: number;
  63473. transcodedPixels: ArrayBufferView;
  63474. }>;
  63475. }>;
  63476. }
  63477. /**
  63478. * Result of transcoding a basis file
  63479. */
  63480. class TranscodeResult {
  63481. /**
  63482. * Info about the .basis file
  63483. */
  63484. fileInfo: BasisFileInfo;
  63485. /**
  63486. * Format to use when loading the file
  63487. */
  63488. format: number;
  63489. }
  63490. /**
  63491. * Configuration options for the Basis transcoder
  63492. */
  63493. export class BasisTranscodeConfiguration {
  63494. /**
  63495. * Supported compression formats used to determine the supported output format of the transcoder
  63496. */
  63497. supportedCompressionFormats?: {
  63498. /**
  63499. * etc1 compression format
  63500. */
  63501. etc1?: boolean;
  63502. /**
  63503. * s3tc compression format
  63504. */
  63505. s3tc?: boolean;
  63506. /**
  63507. * pvrtc compression format
  63508. */
  63509. pvrtc?: boolean;
  63510. /**
  63511. * etc2 compression format
  63512. */
  63513. etc2?: boolean;
  63514. };
  63515. /**
  63516. * If mipmap levels should be loaded for transcoded images (Default: true)
  63517. */
  63518. loadMipmapLevels?: boolean;
  63519. /**
  63520. * Index of a single image to load (Default: all images)
  63521. */
  63522. loadSingleImage?: number;
  63523. }
  63524. /**
  63525. * Used to load .Basis files
  63526. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63527. */
  63528. export class BasisTools {
  63529. private static _IgnoreSupportedFormats;
  63530. /**
  63531. * URL to use when loading the basis transcoder
  63532. */
  63533. static JSModuleURL: string;
  63534. /**
  63535. * URL to use when loading the wasm module for the transcoder
  63536. */
  63537. static WasmModuleURL: string;
  63538. /**
  63539. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63540. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63541. * @returns internal format corresponding to the Basis format
  63542. */
  63543. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63544. private static _WorkerPromise;
  63545. private static _Worker;
  63546. private static _actionId;
  63547. private static _CreateWorkerAsync;
  63548. /**
  63549. * Transcodes a loaded image file to compressed pixel data
  63550. * @param data image data to transcode
  63551. * @param config configuration options for the transcoding
  63552. * @returns a promise resulting in the transcoded image
  63553. */
  63554. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63555. /**
  63556. * Loads a texture from the transcode result
  63557. * @param texture texture load to
  63558. * @param transcodeResult the result of transcoding the basis file to load from
  63559. */
  63560. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63561. }
  63562. }
  63563. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  63564. import { Nullable } from "babylonjs/types";
  63565. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63566. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63567. /**
  63568. * Loader for .basis file format
  63569. */
  63570. export class _BasisTextureLoader implements IInternalTextureLoader {
  63571. /**
  63572. * Defines whether the loader supports cascade loading the different faces.
  63573. */
  63574. readonly supportCascades: boolean;
  63575. /**
  63576. * This returns if the loader support the current file information.
  63577. * @param extension defines the file extension of the file being loaded
  63578. * @returns true if the loader can load the specified file
  63579. */
  63580. canLoad(extension: string): boolean;
  63581. /**
  63582. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63583. * @param data contains the texture data
  63584. * @param texture defines the BabylonJS internal texture
  63585. * @param createPolynomials will be true if polynomials have been requested
  63586. * @param onLoad defines the callback to trigger once the texture is ready
  63587. * @param onError defines the callback to trigger in case of error
  63588. */
  63589. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63590. /**
  63591. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63592. * @param data contains the texture data
  63593. * @param texture defines the BabylonJS internal texture
  63594. * @param callback defines the method to call once ready to upload
  63595. */
  63596. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63597. }
  63598. }
  63599. declare module "babylonjs/Materials/Textures/Loaders/index" {
  63600. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  63601. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  63602. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  63603. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  63604. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  63605. }
  63606. declare module "babylonjs/Materials/Textures/Packer/frame" {
  63607. import { Vector2 } from "babylonjs/Maths/math.vector";
  63608. /**
  63609. * Defines the basic options interface of a TexturePacker Frame
  63610. */
  63611. export interface ITexturePackerFrame {
  63612. /**
  63613. * The frame ID
  63614. */
  63615. id: number;
  63616. /**
  63617. * The frames Scale
  63618. */
  63619. scale: Vector2;
  63620. /**
  63621. * The Frames offset
  63622. */
  63623. offset: Vector2;
  63624. }
  63625. /**
  63626. * This is a support class for frame Data on texture packer sets.
  63627. */
  63628. export class TexturePackerFrame implements ITexturePackerFrame {
  63629. /**
  63630. * The frame ID
  63631. */
  63632. id: number;
  63633. /**
  63634. * The frames Scale
  63635. */
  63636. scale: Vector2;
  63637. /**
  63638. * The Frames offset
  63639. */
  63640. offset: Vector2;
  63641. /**
  63642. * Initializes a texture package frame.
  63643. * @param id The numerical frame identifier
  63644. * @param scale Scalar Vector2 for UV frame
  63645. * @param offset Vector2 for the frame position in UV units.
  63646. * @returns TexturePackerFrame
  63647. */
  63648. constructor(id: number, scale: Vector2, offset: Vector2);
  63649. }
  63650. }
  63651. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63653. import { Scene } from "babylonjs/scene";
  63654. import { Nullable } from "babylonjs/types";
  63655. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63656. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63657. /**
  63658. * Defines the basic options interface of a TexturePacker
  63659. */
  63660. export interface ITexturePackerOptions {
  63661. /**
  63662. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63663. */
  63664. map?: string[];
  63665. /**
  63666. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63667. */
  63668. uvsIn?: string;
  63669. /**
  63670. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63671. */
  63672. uvsOut?: string;
  63673. /**
  63674. * number representing the layout style. Defaults to LAYOUT_STRIP
  63675. */
  63676. layout?: number;
  63677. /**
  63678. * number of columns if using custom column count layout(2). This defaults to 4.
  63679. */
  63680. colnum?: number;
  63681. /**
  63682. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63683. */
  63684. updateInputMeshes?: boolean;
  63685. /**
  63686. * boolean flag to dispose all the source textures. Defaults to true.
  63687. */
  63688. disposeSources?: boolean;
  63689. /**
  63690. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63691. */
  63692. fillBlanks?: boolean;
  63693. /**
  63694. * string value representing the context fill style color. Defaults to 'black'.
  63695. */
  63696. customFillColor?: string;
  63697. /**
  63698. * Width and Height Value of each Frame in the TexturePacker Sets
  63699. */
  63700. frameSize?: number;
  63701. /**
  63702. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63703. */
  63704. paddingRatio?: number;
  63705. /**
  63706. * Number that declares the fill method for the padding gutter.
  63707. */
  63708. paddingMode?: number;
  63709. /**
  63710. * If in SUBUV_COLOR padding mode what color to use.
  63711. */
  63712. paddingColor?: Color3 | Color4;
  63713. }
  63714. /**
  63715. * Defines the basic interface of a TexturePacker JSON File
  63716. */
  63717. export interface ITexturePackerJSON {
  63718. /**
  63719. * The frame ID
  63720. */
  63721. name: string;
  63722. /**
  63723. * The base64 channel data
  63724. */
  63725. sets: any;
  63726. /**
  63727. * The options of the Packer
  63728. */
  63729. options: ITexturePackerOptions;
  63730. /**
  63731. * The frame data of the Packer
  63732. */
  63733. frames: Array<number>;
  63734. }
  63735. /**
  63736. * This is a support class that generates a series of packed texture sets.
  63737. * @see https://doc.babylonjs.com/babylon101/materials
  63738. */
  63739. export class TexturePacker {
  63740. /** Packer Layout Constant 0 */
  63741. static readonly LAYOUT_STRIP: number;
  63742. /** Packer Layout Constant 1 */
  63743. static readonly LAYOUT_POWER2: number;
  63744. /** Packer Layout Constant 2 */
  63745. static readonly LAYOUT_COLNUM: number;
  63746. /** Packer Layout Constant 0 */
  63747. static readonly SUBUV_WRAP: number;
  63748. /** Packer Layout Constant 1 */
  63749. static readonly SUBUV_EXTEND: number;
  63750. /** Packer Layout Constant 2 */
  63751. static readonly SUBUV_COLOR: number;
  63752. /** The Name of the Texture Package */
  63753. name: string;
  63754. /** The scene scope of the TexturePacker */
  63755. scene: Scene;
  63756. /** The Meshes to target */
  63757. meshes: AbstractMesh[];
  63758. /** Arguments passed with the Constructor */
  63759. options: ITexturePackerOptions;
  63760. /** The promise that is started upon initialization */
  63761. promise: Nullable<Promise<TexturePacker | string>>;
  63762. /** The Container object for the channel sets that are generated */
  63763. sets: object;
  63764. /** The Container array for the frames that are generated */
  63765. frames: TexturePackerFrame[];
  63766. /** The expected number of textures the system is parsing. */
  63767. private _expecting;
  63768. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63769. private _paddingValue;
  63770. /**
  63771. * Initializes a texture package series from an array of meshes or a single mesh.
  63772. * @param name The name of the package
  63773. * @param meshes The target meshes to compose the package from
  63774. * @param options The arguments that texture packer should follow while building.
  63775. * @param scene The scene which the textures are scoped to.
  63776. * @returns TexturePacker
  63777. */
  63778. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63779. /**
  63780. * Starts the package process
  63781. * @param resolve The promises resolution function
  63782. * @returns TexturePacker
  63783. */
  63784. private _createFrames;
  63785. /**
  63786. * Calculates the Size of the Channel Sets
  63787. * @returns Vector2
  63788. */
  63789. private _calculateSize;
  63790. /**
  63791. * Calculates the UV data for the frames.
  63792. * @param baseSize the base frameSize
  63793. * @param padding the base frame padding
  63794. * @param dtSize size of the Dynamic Texture for that channel
  63795. * @param dtUnits is 1/dtSize
  63796. * @param update flag to update the input meshes
  63797. */
  63798. private _calculateMeshUVFrames;
  63799. /**
  63800. * Calculates the frames Offset.
  63801. * @param index of the frame
  63802. * @returns Vector2
  63803. */
  63804. private _getFrameOffset;
  63805. /**
  63806. * Updates a Mesh to the frame data
  63807. * @param mesh that is the target
  63808. * @param frameID or the frame index
  63809. */
  63810. private _updateMeshUV;
  63811. /**
  63812. * Updates a Meshes materials to use the texture packer channels
  63813. * @param m is the mesh to target
  63814. * @param force all channels on the packer to be set.
  63815. */
  63816. private _updateTextureReferences;
  63817. /**
  63818. * Public method to set a Mesh to a frame
  63819. * @param m that is the target
  63820. * @param frameID or the frame index
  63821. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63822. */
  63823. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63824. /**
  63825. * Starts the async promise to compile the texture packer.
  63826. * @returns Promise<void>
  63827. */
  63828. processAsync(): Promise<void>;
  63829. /**
  63830. * Disposes all textures associated with this packer
  63831. */
  63832. dispose(): void;
  63833. /**
  63834. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63835. * @param imageType is the image type to use.
  63836. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63837. */
  63838. download(imageType?: string, quality?: number): void;
  63839. /**
  63840. * Public method to load a texturePacker JSON file.
  63841. * @param data of the JSON file in string format.
  63842. */
  63843. updateFromJSON(data: string): void;
  63844. }
  63845. }
  63846. declare module "babylonjs/Materials/Textures/Packer/index" {
  63847. export * from "babylonjs/Materials/Textures/Packer/packer";
  63848. export * from "babylonjs/Materials/Textures/Packer/frame";
  63849. }
  63850. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63851. import { Scene } from "babylonjs/scene";
  63852. import { Texture } from "babylonjs/Materials/Textures/texture";
  63853. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63854. /**
  63855. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  63856. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63857. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63858. */
  63859. export class CustomProceduralTexture extends ProceduralTexture {
  63860. private _animate;
  63861. private _time;
  63862. private _config;
  63863. private _texturePath;
  63864. /**
  63865. * Instantiates a new Custom Procedural Texture.
  63866. * 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.
  63867. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63868. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63869. * @param name Define the name of the texture
  63870. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63871. * @param size Define the size of the texture to create
  63872. * @param scene Define the scene the texture belongs to
  63873. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63874. * @param generateMipMaps Define if the texture should creates mip maps or not
  63875. */
  63876. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63877. private _loadJson;
  63878. /**
  63879. * Is the texture ready to be used ? (rendered at least once)
  63880. * @returns true if ready, otherwise, false.
  63881. */
  63882. isReady(): boolean;
  63883. /**
  63884. * Render the texture to its associated render target.
  63885. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63886. */
  63887. render(useCameraPostProcess?: boolean): void;
  63888. /**
  63889. * Update the list of dependant textures samplers in the shader.
  63890. */
  63891. updateTextures(): void;
  63892. /**
  63893. * Update the uniform values of the procedural texture in the shader.
  63894. */
  63895. updateShaderUniforms(): void;
  63896. /**
  63897. * Define if the texture animates or not.
  63898. */
  63899. get animate(): boolean;
  63900. set animate(value: boolean);
  63901. }
  63902. }
  63903. declare module "babylonjs/Shaders/noise.fragment" {
  63904. /** @hidden */
  63905. export var noisePixelShader: {
  63906. name: string;
  63907. shader: string;
  63908. };
  63909. }
  63910. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63911. import { Nullable } from "babylonjs/types";
  63912. import { Scene } from "babylonjs/scene";
  63913. import { Texture } from "babylonjs/Materials/Textures/texture";
  63914. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63915. import "babylonjs/Shaders/noise.fragment";
  63916. /**
  63917. * Class used to generate noise procedural textures
  63918. */
  63919. export class NoiseProceduralTexture extends ProceduralTexture {
  63920. private _time;
  63921. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63922. brightness: number;
  63923. /** Defines the number of octaves to process */
  63924. octaves: number;
  63925. /** Defines the level of persistence (0.8 by default) */
  63926. persistence: number;
  63927. /** Gets or sets animation speed factor (default is 1) */
  63928. animationSpeedFactor: number;
  63929. /**
  63930. * Creates a new NoiseProceduralTexture
  63931. * @param name defines the name fo the texture
  63932. * @param size defines the size of the texture (default is 256)
  63933. * @param scene defines the hosting scene
  63934. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63935. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63936. */
  63937. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63938. private _updateShaderUniforms;
  63939. protected _getDefines(): string;
  63940. /** Generate the current state of the procedural texture */
  63941. render(useCameraPostProcess?: boolean): void;
  63942. /**
  63943. * Serializes this noise procedural texture
  63944. * @returns a serialized noise procedural texture object
  63945. */
  63946. serialize(): any;
  63947. /**
  63948. * Clone the texture.
  63949. * @returns the cloned texture
  63950. */
  63951. clone(): NoiseProceduralTexture;
  63952. /**
  63953. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63954. * @param parsedTexture defines parsed texture data
  63955. * @param scene defines the current scene
  63956. * @param rootUrl defines the root URL containing noise procedural texture information
  63957. * @returns a parsed NoiseProceduralTexture
  63958. */
  63959. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63960. }
  63961. }
  63962. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63963. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63964. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63965. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63966. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63967. }
  63968. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63969. import { Nullable } from "babylonjs/types";
  63970. import { Scene } from "babylonjs/scene";
  63971. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63972. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63973. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63974. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63975. /**
  63976. * Raw cube texture where the raw buffers are passed in
  63977. */
  63978. export class RawCubeTexture extends CubeTexture {
  63979. /**
  63980. * Creates a cube texture where the raw buffers are passed in.
  63981. * @param scene defines the scene the texture is attached to
  63982. * @param data defines the array of data to use to create each face
  63983. * @param size defines the size of the textures
  63984. * @param format defines the format of the data
  63985. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63986. * @param generateMipMaps defines if the engine should generate the mip levels
  63987. * @param invertY defines if data must be stored with Y axis inverted
  63988. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63989. * @param compression defines the compression used (null by default)
  63990. */
  63991. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63992. /**
  63993. * Updates the raw cube texture.
  63994. * @param data defines the data to store
  63995. * @param format defines the data format
  63996. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63997. * @param invertY defines if data must be stored with Y axis inverted
  63998. * @param compression defines the compression used (null by default)
  63999. * @param level defines which level of the texture to update
  64000. */
  64001. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64002. /**
  64003. * Updates a raw cube texture with RGBD encoded data.
  64004. * @param data defines the array of data [mipmap][face] to use to create each face
  64005. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64006. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64007. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64008. * @returns a promsie that resolves when the operation is complete
  64009. */
  64010. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64011. /**
  64012. * Clones the raw cube texture.
  64013. * @return a new cube texture
  64014. */
  64015. clone(): CubeTexture;
  64016. /** @hidden */
  64017. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64018. }
  64019. }
  64020. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64021. import { Scene } from "babylonjs/scene";
  64022. import { Texture } from "babylonjs/Materials/Textures/texture";
  64023. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64024. /**
  64025. * Class used to store 2D array textures containing user data
  64026. */
  64027. export class RawTexture2DArray extends Texture {
  64028. /** Gets or sets the texture format to use */
  64029. format: number;
  64030. /**
  64031. * Create a new RawTexture2DArray
  64032. * @param data defines the data of the texture
  64033. * @param width defines the width of the texture
  64034. * @param height defines the height of the texture
  64035. * @param depth defines the number of layers of the texture
  64036. * @param format defines the texture format to use
  64037. * @param scene defines the hosting scene
  64038. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64039. * @param invertY defines if texture must be stored with Y axis inverted
  64040. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64041. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64042. */
  64043. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64044. /** Gets or sets the texture format to use */
  64045. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64046. /**
  64047. * Update the texture with new data
  64048. * @param data defines the data to store in the texture
  64049. */
  64050. update(data: ArrayBufferView): void;
  64051. }
  64052. }
  64053. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64054. import { Scene } from "babylonjs/scene";
  64055. import { Texture } from "babylonjs/Materials/Textures/texture";
  64056. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64057. /**
  64058. * Class used to store 3D textures containing user data
  64059. */
  64060. export class RawTexture3D extends Texture {
  64061. /** Gets or sets the texture format to use */
  64062. format: number;
  64063. /**
  64064. * Create a new RawTexture3D
  64065. * @param data defines the data of the texture
  64066. * @param width defines the width of the texture
  64067. * @param height defines the height of the texture
  64068. * @param depth defines the depth of the texture
  64069. * @param format defines the texture format to use
  64070. * @param scene defines the hosting scene
  64071. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64072. * @param invertY defines if texture must be stored with Y axis inverted
  64073. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64074. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64075. */
  64076. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64077. /** Gets or sets the texture format to use */
  64078. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64079. /**
  64080. * Update the texture with new data
  64081. * @param data defines the data to store in the texture
  64082. */
  64083. update(data: ArrayBufferView): void;
  64084. }
  64085. }
  64086. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64087. import { Scene } from "babylonjs/scene";
  64088. import { Plane } from "babylonjs/Maths/math.plane";
  64089. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64090. /**
  64091. * Creates a refraction texture used by refraction channel of the standard material.
  64092. * It is like a mirror but to see through a material.
  64093. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64094. */
  64095. export class RefractionTexture extends RenderTargetTexture {
  64096. /**
  64097. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64098. * 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.
  64099. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64100. */
  64101. refractionPlane: Plane;
  64102. /**
  64103. * Define how deep under the surface we should see.
  64104. */
  64105. depth: number;
  64106. /**
  64107. * Creates a refraction texture used by refraction channel of the standard material.
  64108. * It is like a mirror but to see through a material.
  64109. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64110. * @param name Define the texture name
  64111. * @param size Define the size of the underlying texture
  64112. * @param scene Define the scene the refraction belongs to
  64113. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64114. */
  64115. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64116. /**
  64117. * Clone the refraction texture.
  64118. * @returns the cloned texture
  64119. */
  64120. clone(): RefractionTexture;
  64121. /**
  64122. * Serialize the texture to a JSON representation you could use in Parse later on
  64123. * @returns the serialized JSON representation
  64124. */
  64125. serialize(): any;
  64126. }
  64127. }
  64128. declare module "babylonjs/Materials/Textures/index" {
  64129. export * from "babylonjs/Materials/Textures/baseTexture";
  64130. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64131. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64132. export * from "babylonjs/Materials/Textures/cubeTexture";
  64133. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64134. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64135. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64136. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64137. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64138. export * from "babylonjs/Materials/Textures/internalTexture";
  64139. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64140. export * from "babylonjs/Materials/Textures/Loaders/index";
  64141. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64142. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64143. export * from "babylonjs/Materials/Textures/Packer/index";
  64144. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64145. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64146. export * from "babylonjs/Materials/Textures/rawTexture";
  64147. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64148. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64149. export * from "babylonjs/Materials/Textures/refractionTexture";
  64150. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64151. export * from "babylonjs/Materials/Textures/texture";
  64152. export * from "babylonjs/Materials/Textures/videoTexture";
  64153. }
  64154. declare module "babylonjs/Materials/Node/Enums/index" {
  64155. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64156. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64157. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64158. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64159. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64160. }
  64161. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64165. import { Mesh } from "babylonjs/Meshes/mesh";
  64166. import { Effect } from "babylonjs/Materials/effect";
  64167. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64168. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64169. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64170. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64171. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64172. /**
  64173. * Block used to add support for vertex skinning (bones)
  64174. */
  64175. export class BonesBlock extends NodeMaterialBlock {
  64176. /**
  64177. * Creates a new BonesBlock
  64178. * @param name defines the block name
  64179. */
  64180. constructor(name: string);
  64181. /**
  64182. * Initialize the block and prepare the context for build
  64183. * @param state defines the state that will be used for the build
  64184. */
  64185. initialize(state: NodeMaterialBuildState): void;
  64186. /**
  64187. * Gets the current class name
  64188. * @returns the class name
  64189. */
  64190. getClassName(): string;
  64191. /**
  64192. * Gets the matrix indices input component
  64193. */
  64194. get matricesIndices(): NodeMaterialConnectionPoint;
  64195. /**
  64196. * Gets the matrix weights input component
  64197. */
  64198. get matricesWeights(): NodeMaterialConnectionPoint;
  64199. /**
  64200. * Gets the extra matrix indices input component
  64201. */
  64202. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64203. /**
  64204. * Gets the extra matrix weights input component
  64205. */
  64206. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64207. /**
  64208. * Gets the world input component
  64209. */
  64210. get world(): NodeMaterialConnectionPoint;
  64211. /**
  64212. * Gets the output component
  64213. */
  64214. get output(): NodeMaterialConnectionPoint;
  64215. autoConfigure(material: NodeMaterial): void;
  64216. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64217. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64218. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64219. protected _buildBlock(state: NodeMaterialBuildState): this;
  64220. }
  64221. }
  64222. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64223. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64225. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64227. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64228. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64229. /**
  64230. * Block used to add support for instances
  64231. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64232. */
  64233. export class InstancesBlock extends NodeMaterialBlock {
  64234. /**
  64235. * Creates a new InstancesBlock
  64236. * @param name defines the block name
  64237. */
  64238. constructor(name: string);
  64239. /**
  64240. * Gets the current class name
  64241. * @returns the class name
  64242. */
  64243. getClassName(): string;
  64244. /**
  64245. * Gets the first world row input component
  64246. */
  64247. get world0(): NodeMaterialConnectionPoint;
  64248. /**
  64249. * Gets the second world row input component
  64250. */
  64251. get world1(): NodeMaterialConnectionPoint;
  64252. /**
  64253. * Gets the third world row input component
  64254. */
  64255. get world2(): NodeMaterialConnectionPoint;
  64256. /**
  64257. * Gets the forth world row input component
  64258. */
  64259. get world3(): NodeMaterialConnectionPoint;
  64260. /**
  64261. * Gets the world input component
  64262. */
  64263. get world(): NodeMaterialConnectionPoint;
  64264. /**
  64265. * Gets the output component
  64266. */
  64267. get output(): NodeMaterialConnectionPoint;
  64268. /**
  64269. * Gets the isntanceID component
  64270. */
  64271. get instanceID(): NodeMaterialConnectionPoint;
  64272. autoConfigure(material: NodeMaterial): void;
  64273. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64274. protected _buildBlock(state: NodeMaterialBuildState): this;
  64275. }
  64276. }
  64277. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64278. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64279. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64280. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64282. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64283. import { Effect } from "babylonjs/Materials/effect";
  64284. import { Mesh } from "babylonjs/Meshes/mesh";
  64285. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64286. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64287. /**
  64288. * Block used to add morph targets support to vertex shader
  64289. */
  64290. export class MorphTargetsBlock extends NodeMaterialBlock {
  64291. private _repeatableContentAnchor;
  64292. /**
  64293. * Create a new MorphTargetsBlock
  64294. * @param name defines the block name
  64295. */
  64296. constructor(name: string);
  64297. /**
  64298. * Gets the current class name
  64299. * @returns the class name
  64300. */
  64301. getClassName(): string;
  64302. /**
  64303. * Gets the position input component
  64304. */
  64305. get position(): NodeMaterialConnectionPoint;
  64306. /**
  64307. * Gets the normal input component
  64308. */
  64309. get normal(): NodeMaterialConnectionPoint;
  64310. /**
  64311. * Gets the tangent input component
  64312. */
  64313. get tangent(): NodeMaterialConnectionPoint;
  64314. /**
  64315. * Gets the tangent input component
  64316. */
  64317. get uv(): NodeMaterialConnectionPoint;
  64318. /**
  64319. * Gets the position output component
  64320. */
  64321. get positionOutput(): NodeMaterialConnectionPoint;
  64322. /**
  64323. * Gets the normal output component
  64324. */
  64325. get normalOutput(): NodeMaterialConnectionPoint;
  64326. /**
  64327. * Gets the tangent output component
  64328. */
  64329. get tangentOutput(): NodeMaterialConnectionPoint;
  64330. /**
  64331. * Gets the tangent output component
  64332. */
  64333. get uvOutput(): NodeMaterialConnectionPoint;
  64334. initialize(state: NodeMaterialBuildState): void;
  64335. autoConfigure(material: NodeMaterial): void;
  64336. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64337. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64338. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64339. protected _buildBlock(state: NodeMaterialBuildState): this;
  64340. }
  64341. }
  64342. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64344. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64345. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64346. import { Nullable } from "babylonjs/types";
  64347. import { Scene } from "babylonjs/scene";
  64348. import { Effect } from "babylonjs/Materials/effect";
  64349. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64350. import { Mesh } from "babylonjs/Meshes/mesh";
  64351. import { Light } from "babylonjs/Lights/light";
  64352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64353. /**
  64354. * Block used to get data information from a light
  64355. */
  64356. export class LightInformationBlock extends NodeMaterialBlock {
  64357. private _lightDataUniformName;
  64358. private _lightColorUniformName;
  64359. private _lightTypeDefineName;
  64360. /**
  64361. * Gets or sets the light associated with this block
  64362. */
  64363. light: Nullable<Light>;
  64364. /**
  64365. * Creates a new LightInformationBlock
  64366. * @param name defines the block name
  64367. */
  64368. constructor(name: string);
  64369. /**
  64370. * Gets the current class name
  64371. * @returns the class name
  64372. */
  64373. getClassName(): string;
  64374. /**
  64375. * Gets the world position input component
  64376. */
  64377. get worldPosition(): NodeMaterialConnectionPoint;
  64378. /**
  64379. * Gets the direction output component
  64380. */
  64381. get direction(): NodeMaterialConnectionPoint;
  64382. /**
  64383. * Gets the direction output component
  64384. */
  64385. get color(): NodeMaterialConnectionPoint;
  64386. /**
  64387. * Gets the direction output component
  64388. */
  64389. get intensity(): NodeMaterialConnectionPoint;
  64390. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64392. protected _buildBlock(state: NodeMaterialBuildState): this;
  64393. serialize(): any;
  64394. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64395. }
  64396. }
  64397. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64398. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64399. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64400. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64401. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64402. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64403. }
  64404. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64406. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64409. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64410. import { Effect } from "babylonjs/Materials/effect";
  64411. import { Mesh } from "babylonjs/Meshes/mesh";
  64412. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64413. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64414. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64415. /**
  64416. * Block used to add image processing support to fragment shader
  64417. */
  64418. export class ImageProcessingBlock extends NodeMaterialBlock {
  64419. /**
  64420. * Create a new ImageProcessingBlock
  64421. * @param name defines the block name
  64422. */
  64423. constructor(name: string);
  64424. /**
  64425. * Gets the current class name
  64426. * @returns the class name
  64427. */
  64428. getClassName(): string;
  64429. /**
  64430. * Gets the color input component
  64431. */
  64432. get color(): NodeMaterialConnectionPoint;
  64433. /**
  64434. * Gets the output component
  64435. */
  64436. get output(): NodeMaterialConnectionPoint;
  64437. /**
  64438. * Initialize the block and prepare the context for build
  64439. * @param state defines the state that will be used for the build
  64440. */
  64441. initialize(state: NodeMaterialBuildState): void;
  64442. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64443. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64444. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64445. protected _buildBlock(state: NodeMaterialBuildState): this;
  64446. }
  64447. }
  64448. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  64449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64452. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64454. import { Effect } from "babylonjs/Materials/effect";
  64455. import { Mesh } from "babylonjs/Meshes/mesh";
  64456. import { Scene } from "babylonjs/scene";
  64457. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  64458. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  64459. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  64460. /**
  64461. * Block used to pertub normals based on a normal map
  64462. */
  64463. export class PerturbNormalBlock extends NodeMaterialBlock {
  64464. private _tangentSpaceParameterName;
  64465. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64466. invertX: boolean;
  64467. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64468. invertY: boolean;
  64469. /**
  64470. * Create a new PerturbNormalBlock
  64471. * @param name defines the block name
  64472. */
  64473. constructor(name: string);
  64474. /**
  64475. * Gets the current class name
  64476. * @returns the class name
  64477. */
  64478. getClassName(): string;
  64479. /**
  64480. * Gets the world position input component
  64481. */
  64482. get worldPosition(): NodeMaterialConnectionPoint;
  64483. /**
  64484. * Gets the world normal input component
  64485. */
  64486. get worldNormal(): NodeMaterialConnectionPoint;
  64487. /**
  64488. * Gets the world tangent input component
  64489. */
  64490. get worldTangent(): NodeMaterialConnectionPoint;
  64491. /**
  64492. * Gets the uv input component
  64493. */
  64494. get uv(): NodeMaterialConnectionPoint;
  64495. /**
  64496. * Gets the normal map color input component
  64497. */
  64498. get normalMapColor(): NodeMaterialConnectionPoint;
  64499. /**
  64500. * Gets the strength input component
  64501. */
  64502. get strength(): NodeMaterialConnectionPoint;
  64503. /**
  64504. * Gets the output component
  64505. */
  64506. get output(): NodeMaterialConnectionPoint;
  64507. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64508. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64509. autoConfigure(material: NodeMaterial): void;
  64510. protected _buildBlock(state: NodeMaterialBuildState): this;
  64511. protected _dumpPropertiesCode(): string;
  64512. serialize(): any;
  64513. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64514. }
  64515. }
  64516. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  64517. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64518. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64519. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64520. /**
  64521. * Block used to discard a pixel if a value is smaller than a cutoff
  64522. */
  64523. export class DiscardBlock extends NodeMaterialBlock {
  64524. /**
  64525. * Create a new DiscardBlock
  64526. * @param name defines the block name
  64527. */
  64528. constructor(name: string);
  64529. /**
  64530. * Gets the current class name
  64531. * @returns the class name
  64532. */
  64533. getClassName(): string;
  64534. /**
  64535. * Gets the color input component
  64536. */
  64537. get value(): NodeMaterialConnectionPoint;
  64538. /**
  64539. * Gets the cutoff input component
  64540. */
  64541. get cutoff(): NodeMaterialConnectionPoint;
  64542. protected _buildBlock(state: NodeMaterialBuildState): this;
  64543. }
  64544. }
  64545. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  64546. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64547. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64548. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64549. /**
  64550. * Block used to test if the fragment shader is front facing
  64551. */
  64552. export class FrontFacingBlock extends NodeMaterialBlock {
  64553. /**
  64554. * Creates a new FrontFacingBlock
  64555. * @param name defines the block name
  64556. */
  64557. constructor(name: string);
  64558. /**
  64559. * Gets the current class name
  64560. * @returns the class name
  64561. */
  64562. getClassName(): string;
  64563. /**
  64564. * Gets the output component
  64565. */
  64566. get output(): NodeMaterialConnectionPoint;
  64567. protected _buildBlock(state: NodeMaterialBuildState): this;
  64568. }
  64569. }
  64570. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  64571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64574. /**
  64575. * Block used to get the derivative value on x and y of a given input
  64576. */
  64577. export class DerivativeBlock extends NodeMaterialBlock {
  64578. /**
  64579. * Create a new DerivativeBlock
  64580. * @param name defines the block name
  64581. */
  64582. constructor(name: string);
  64583. /**
  64584. * Gets the current class name
  64585. * @returns the class name
  64586. */
  64587. getClassName(): string;
  64588. /**
  64589. * Gets the input component
  64590. */
  64591. get input(): NodeMaterialConnectionPoint;
  64592. /**
  64593. * Gets the derivative output on x
  64594. */
  64595. get dx(): NodeMaterialConnectionPoint;
  64596. /**
  64597. * Gets the derivative output on y
  64598. */
  64599. get dy(): NodeMaterialConnectionPoint;
  64600. protected _buildBlock(state: NodeMaterialBuildState): this;
  64601. }
  64602. }
  64603. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  64604. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64605. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64607. /**
  64608. * Block used to make gl_FragCoord available
  64609. */
  64610. export class FragCoordBlock extends NodeMaterialBlock {
  64611. /**
  64612. * Creates a new FragCoordBlock
  64613. * @param name defines the block name
  64614. */
  64615. constructor(name: string);
  64616. /**
  64617. * Gets the current class name
  64618. * @returns the class name
  64619. */
  64620. getClassName(): string;
  64621. /**
  64622. * Gets the xy component
  64623. */
  64624. get xy(): NodeMaterialConnectionPoint;
  64625. /**
  64626. * Gets the xyz component
  64627. */
  64628. get xyz(): NodeMaterialConnectionPoint;
  64629. /**
  64630. * Gets the xyzw component
  64631. */
  64632. get xyzw(): NodeMaterialConnectionPoint;
  64633. /**
  64634. * Gets the x component
  64635. */
  64636. get x(): NodeMaterialConnectionPoint;
  64637. /**
  64638. * Gets the y component
  64639. */
  64640. get y(): NodeMaterialConnectionPoint;
  64641. /**
  64642. * Gets the z component
  64643. */
  64644. get z(): NodeMaterialConnectionPoint;
  64645. /**
  64646. * Gets the w component
  64647. */
  64648. get output(): NodeMaterialConnectionPoint;
  64649. protected writeOutputs(state: NodeMaterialBuildState): string;
  64650. protected _buildBlock(state: NodeMaterialBuildState): this;
  64651. }
  64652. }
  64653. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  64654. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64655. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64656. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64657. import { Effect } from "babylonjs/Materials/effect";
  64658. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64659. import { Mesh } from "babylonjs/Meshes/mesh";
  64660. /**
  64661. * Block used to get the screen sizes
  64662. */
  64663. export class ScreenSizeBlock extends NodeMaterialBlock {
  64664. private _varName;
  64665. private _scene;
  64666. /**
  64667. * Creates a new ScreenSizeBlock
  64668. * @param name defines the block name
  64669. */
  64670. constructor(name: string);
  64671. /**
  64672. * Gets the current class name
  64673. * @returns the class name
  64674. */
  64675. getClassName(): string;
  64676. /**
  64677. * Gets the xy component
  64678. */
  64679. get xy(): NodeMaterialConnectionPoint;
  64680. /**
  64681. * Gets the x component
  64682. */
  64683. get x(): NodeMaterialConnectionPoint;
  64684. /**
  64685. * Gets the y component
  64686. */
  64687. get y(): NodeMaterialConnectionPoint;
  64688. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64689. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64690. protected _buildBlock(state: NodeMaterialBuildState): this;
  64691. }
  64692. }
  64693. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  64694. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  64695. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  64696. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  64697. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  64698. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  64699. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  64700. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  64701. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  64702. }
  64703. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  64704. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64705. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64706. import { Mesh } from "babylonjs/Meshes/mesh";
  64707. import { Effect } from "babylonjs/Materials/effect";
  64708. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64710. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64711. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64712. /**
  64713. * Block used to add support for scene fog
  64714. */
  64715. export class FogBlock extends NodeMaterialBlock {
  64716. private _fogDistanceName;
  64717. private _fogParameters;
  64718. /**
  64719. * Create a new FogBlock
  64720. * @param name defines the block name
  64721. */
  64722. constructor(name: string);
  64723. /**
  64724. * Gets the current class name
  64725. * @returns the class name
  64726. */
  64727. getClassName(): string;
  64728. /**
  64729. * Gets the world position input component
  64730. */
  64731. get worldPosition(): NodeMaterialConnectionPoint;
  64732. /**
  64733. * Gets the view input component
  64734. */
  64735. get view(): NodeMaterialConnectionPoint;
  64736. /**
  64737. * Gets the color input component
  64738. */
  64739. get input(): NodeMaterialConnectionPoint;
  64740. /**
  64741. * Gets the fog color input component
  64742. */
  64743. get fogColor(): NodeMaterialConnectionPoint;
  64744. /**
  64745. * Gets the output component
  64746. */
  64747. get output(): NodeMaterialConnectionPoint;
  64748. autoConfigure(material: NodeMaterial): void;
  64749. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64750. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64751. protected _buildBlock(state: NodeMaterialBuildState): this;
  64752. }
  64753. }
  64754. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64755. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64756. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64757. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64759. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64760. import { Effect } from "babylonjs/Materials/effect";
  64761. import { Mesh } from "babylonjs/Meshes/mesh";
  64762. import { Light } from "babylonjs/Lights/light";
  64763. import { Nullable } from "babylonjs/types";
  64764. import { Scene } from "babylonjs/scene";
  64765. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64766. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64767. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64768. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64769. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64770. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64771. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64772. /**
  64773. * Block used to add light in the fragment shader
  64774. */
  64775. export class LightBlock extends NodeMaterialBlock {
  64776. private _lightId;
  64777. /**
  64778. * Gets or sets the light associated with this block
  64779. */
  64780. light: Nullable<Light>;
  64781. /**
  64782. * Create a new LightBlock
  64783. * @param name defines the block name
  64784. */
  64785. constructor(name: string);
  64786. /**
  64787. * Gets the current class name
  64788. * @returns the class name
  64789. */
  64790. getClassName(): string;
  64791. /**
  64792. * Gets the world position input component
  64793. */
  64794. get worldPosition(): NodeMaterialConnectionPoint;
  64795. /**
  64796. * Gets the world normal input component
  64797. */
  64798. get worldNormal(): NodeMaterialConnectionPoint;
  64799. /**
  64800. * Gets the camera (or eye) position component
  64801. */
  64802. get cameraPosition(): NodeMaterialConnectionPoint;
  64803. /**
  64804. * Gets the glossiness component
  64805. */
  64806. get glossiness(): NodeMaterialConnectionPoint;
  64807. /**
  64808. * Gets the glossinness power component
  64809. */
  64810. get glossPower(): NodeMaterialConnectionPoint;
  64811. /**
  64812. * Gets the diffuse color component
  64813. */
  64814. get diffuseColor(): NodeMaterialConnectionPoint;
  64815. /**
  64816. * Gets the specular color component
  64817. */
  64818. get specularColor(): NodeMaterialConnectionPoint;
  64819. /**
  64820. * Gets the diffuse output component
  64821. */
  64822. get diffuseOutput(): NodeMaterialConnectionPoint;
  64823. /**
  64824. * Gets the specular output component
  64825. */
  64826. get specularOutput(): NodeMaterialConnectionPoint;
  64827. /**
  64828. * Gets the shadow output component
  64829. */
  64830. get shadow(): NodeMaterialConnectionPoint;
  64831. autoConfigure(material: NodeMaterial): void;
  64832. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64833. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64834. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64835. private _injectVertexCode;
  64836. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64837. serialize(): any;
  64838. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64839. }
  64840. }
  64841. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64844. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64845. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64846. /**
  64847. * Block used to read a reflection texture from a sampler
  64848. */
  64849. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64850. /**
  64851. * Create a new ReflectionTextureBlock
  64852. * @param name defines the block name
  64853. */
  64854. constructor(name: string);
  64855. /**
  64856. * Gets the current class name
  64857. * @returns the class name
  64858. */
  64859. getClassName(): string;
  64860. /**
  64861. * Gets the world position input component
  64862. */
  64863. get position(): NodeMaterialConnectionPoint;
  64864. /**
  64865. * Gets the world position input component
  64866. */
  64867. get worldPosition(): NodeMaterialConnectionPoint;
  64868. /**
  64869. * Gets the world normal input component
  64870. */
  64871. get worldNormal(): NodeMaterialConnectionPoint;
  64872. /**
  64873. * Gets the world input component
  64874. */
  64875. get world(): NodeMaterialConnectionPoint;
  64876. /**
  64877. * Gets the camera (or eye) position component
  64878. */
  64879. get cameraPosition(): NodeMaterialConnectionPoint;
  64880. /**
  64881. * Gets the view input component
  64882. */
  64883. get view(): NodeMaterialConnectionPoint;
  64884. /**
  64885. * Gets the rgb output component
  64886. */
  64887. get rgb(): NodeMaterialConnectionPoint;
  64888. /**
  64889. * Gets the rgba output component
  64890. */
  64891. get rgba(): NodeMaterialConnectionPoint;
  64892. /**
  64893. * Gets the r output component
  64894. */
  64895. get r(): NodeMaterialConnectionPoint;
  64896. /**
  64897. * Gets the g output component
  64898. */
  64899. get g(): NodeMaterialConnectionPoint;
  64900. /**
  64901. * Gets the b output component
  64902. */
  64903. get b(): NodeMaterialConnectionPoint;
  64904. /**
  64905. * Gets the a output component
  64906. */
  64907. get a(): NodeMaterialConnectionPoint;
  64908. autoConfigure(material: NodeMaterial): void;
  64909. protected _buildBlock(state: NodeMaterialBuildState): this;
  64910. }
  64911. }
  64912. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64913. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64914. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64915. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64916. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64917. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64918. }
  64919. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64920. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64921. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64922. }
  64923. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64924. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64925. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64926. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64927. /**
  64928. * Block used to add 2 vectors
  64929. */
  64930. export class AddBlock extends NodeMaterialBlock {
  64931. /**
  64932. * Creates a new AddBlock
  64933. * @param name defines the block name
  64934. */
  64935. constructor(name: string);
  64936. /**
  64937. * Gets the current class name
  64938. * @returns the class name
  64939. */
  64940. getClassName(): string;
  64941. /**
  64942. * Gets the left operand input component
  64943. */
  64944. get left(): NodeMaterialConnectionPoint;
  64945. /**
  64946. * Gets the right operand input component
  64947. */
  64948. get right(): NodeMaterialConnectionPoint;
  64949. /**
  64950. * Gets the output component
  64951. */
  64952. get output(): NodeMaterialConnectionPoint;
  64953. protected _buildBlock(state: NodeMaterialBuildState): this;
  64954. }
  64955. }
  64956. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64960. /**
  64961. * Block used to scale a vector by a float
  64962. */
  64963. export class ScaleBlock extends NodeMaterialBlock {
  64964. /**
  64965. * Creates a new ScaleBlock
  64966. * @param name defines the block name
  64967. */
  64968. constructor(name: string);
  64969. /**
  64970. * Gets the current class name
  64971. * @returns the class name
  64972. */
  64973. getClassName(): string;
  64974. /**
  64975. * Gets the input component
  64976. */
  64977. get input(): NodeMaterialConnectionPoint;
  64978. /**
  64979. * Gets the factor input component
  64980. */
  64981. get factor(): NodeMaterialConnectionPoint;
  64982. /**
  64983. * Gets the output component
  64984. */
  64985. get output(): NodeMaterialConnectionPoint;
  64986. protected _buildBlock(state: NodeMaterialBuildState): this;
  64987. }
  64988. }
  64989. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64990. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64991. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64992. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64993. import { Scene } from "babylonjs/scene";
  64994. /**
  64995. * Block used to clamp a float
  64996. */
  64997. export class ClampBlock extends NodeMaterialBlock {
  64998. /** Gets or sets the minimum range */
  64999. minimum: number;
  65000. /** Gets or sets the maximum range */
  65001. maximum: number;
  65002. /**
  65003. * Creates a new ClampBlock
  65004. * @param name defines the block name
  65005. */
  65006. constructor(name: string);
  65007. /**
  65008. * Gets the current class name
  65009. * @returns the class name
  65010. */
  65011. getClassName(): string;
  65012. /**
  65013. * Gets the value input component
  65014. */
  65015. get value(): NodeMaterialConnectionPoint;
  65016. /**
  65017. * Gets the output component
  65018. */
  65019. get output(): NodeMaterialConnectionPoint;
  65020. protected _buildBlock(state: NodeMaterialBuildState): this;
  65021. protected _dumpPropertiesCode(): string;
  65022. serialize(): any;
  65023. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65024. }
  65025. }
  65026. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65027. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65028. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65029. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65030. /**
  65031. * Block used to apply a cross product between 2 vectors
  65032. */
  65033. export class CrossBlock extends NodeMaterialBlock {
  65034. /**
  65035. * Creates a new CrossBlock
  65036. * @param name defines the block name
  65037. */
  65038. constructor(name: string);
  65039. /**
  65040. * Gets the current class name
  65041. * @returns the class name
  65042. */
  65043. getClassName(): string;
  65044. /**
  65045. * Gets the left operand input component
  65046. */
  65047. get left(): NodeMaterialConnectionPoint;
  65048. /**
  65049. * Gets the right operand input component
  65050. */
  65051. get right(): NodeMaterialConnectionPoint;
  65052. /**
  65053. * Gets the output component
  65054. */
  65055. get output(): NodeMaterialConnectionPoint;
  65056. protected _buildBlock(state: NodeMaterialBuildState): this;
  65057. }
  65058. }
  65059. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65060. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65062. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65063. /**
  65064. * Block used to apply a dot product between 2 vectors
  65065. */
  65066. export class DotBlock extends NodeMaterialBlock {
  65067. /**
  65068. * Creates a new DotBlock
  65069. * @param name defines the block name
  65070. */
  65071. constructor(name: string);
  65072. /**
  65073. * Gets the current class name
  65074. * @returns the class name
  65075. */
  65076. getClassName(): string;
  65077. /**
  65078. * Gets the left operand input component
  65079. */
  65080. get left(): NodeMaterialConnectionPoint;
  65081. /**
  65082. * Gets the right operand input component
  65083. */
  65084. get right(): NodeMaterialConnectionPoint;
  65085. /**
  65086. * Gets the output component
  65087. */
  65088. get output(): NodeMaterialConnectionPoint;
  65089. protected _buildBlock(state: NodeMaterialBuildState): this;
  65090. }
  65091. }
  65092. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65096. /**
  65097. * Block used to normalize a vector
  65098. */
  65099. export class NormalizeBlock extends NodeMaterialBlock {
  65100. /**
  65101. * Creates a new NormalizeBlock
  65102. * @param name defines the block name
  65103. */
  65104. constructor(name: string);
  65105. /**
  65106. * Gets the current class name
  65107. * @returns the class name
  65108. */
  65109. getClassName(): string;
  65110. /**
  65111. * Gets the input component
  65112. */
  65113. get input(): NodeMaterialConnectionPoint;
  65114. /**
  65115. * Gets the output component
  65116. */
  65117. get output(): NodeMaterialConnectionPoint;
  65118. protected _buildBlock(state: NodeMaterialBuildState): this;
  65119. }
  65120. }
  65121. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65124. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65125. import { Scene } from "babylonjs/scene";
  65126. /**
  65127. * Operations supported by the Trigonometry block
  65128. */
  65129. export enum TrigonometryBlockOperations {
  65130. /** Cos */
  65131. Cos = 0,
  65132. /** Sin */
  65133. Sin = 1,
  65134. /** Abs */
  65135. Abs = 2,
  65136. /** Exp */
  65137. Exp = 3,
  65138. /** Exp2 */
  65139. Exp2 = 4,
  65140. /** Round */
  65141. Round = 5,
  65142. /** Floor */
  65143. Floor = 6,
  65144. /** Ceiling */
  65145. Ceiling = 7,
  65146. /** Square root */
  65147. Sqrt = 8,
  65148. /** Log */
  65149. Log = 9,
  65150. /** Tangent */
  65151. Tan = 10,
  65152. /** Arc tangent */
  65153. ArcTan = 11,
  65154. /** Arc cosinus */
  65155. ArcCos = 12,
  65156. /** Arc sinus */
  65157. ArcSin = 13,
  65158. /** Fraction */
  65159. Fract = 14,
  65160. /** Sign */
  65161. Sign = 15,
  65162. /** To radians (from degrees) */
  65163. Radians = 16,
  65164. /** To degrees (from radians) */
  65165. Degrees = 17
  65166. }
  65167. /**
  65168. * Block used to apply trigonometry operation to floats
  65169. */
  65170. export class TrigonometryBlock extends NodeMaterialBlock {
  65171. /**
  65172. * Gets or sets the operation applied by the block
  65173. */
  65174. operation: TrigonometryBlockOperations;
  65175. /**
  65176. * Creates a new TrigonometryBlock
  65177. * @param name defines the block name
  65178. */
  65179. constructor(name: string);
  65180. /**
  65181. * Gets the current class name
  65182. * @returns the class name
  65183. */
  65184. getClassName(): string;
  65185. /**
  65186. * Gets the input component
  65187. */
  65188. get input(): NodeMaterialConnectionPoint;
  65189. /**
  65190. * Gets the output component
  65191. */
  65192. get output(): NodeMaterialConnectionPoint;
  65193. protected _buildBlock(state: NodeMaterialBuildState): this;
  65194. serialize(): any;
  65195. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65196. protected _dumpPropertiesCode(): string;
  65197. }
  65198. }
  65199. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65202. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65203. /**
  65204. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65205. */
  65206. export class ColorMergerBlock extends NodeMaterialBlock {
  65207. /**
  65208. * Create a new ColorMergerBlock
  65209. * @param name defines the block name
  65210. */
  65211. constructor(name: string);
  65212. /**
  65213. * Gets the current class name
  65214. * @returns the class name
  65215. */
  65216. getClassName(): string;
  65217. /**
  65218. * Gets the rgb component (input)
  65219. */
  65220. get rgbIn(): NodeMaterialConnectionPoint;
  65221. /**
  65222. * Gets the r component (input)
  65223. */
  65224. get r(): NodeMaterialConnectionPoint;
  65225. /**
  65226. * Gets the g component (input)
  65227. */
  65228. get g(): NodeMaterialConnectionPoint;
  65229. /**
  65230. * Gets the b component (input)
  65231. */
  65232. get b(): NodeMaterialConnectionPoint;
  65233. /**
  65234. * Gets the a component (input)
  65235. */
  65236. get a(): NodeMaterialConnectionPoint;
  65237. /**
  65238. * Gets the rgba component (output)
  65239. */
  65240. get rgba(): NodeMaterialConnectionPoint;
  65241. /**
  65242. * Gets the rgb component (output)
  65243. */
  65244. get rgbOut(): NodeMaterialConnectionPoint;
  65245. /**
  65246. * Gets the rgb component (output)
  65247. * @deprecated Please use rgbOut instead.
  65248. */
  65249. get rgb(): NodeMaterialConnectionPoint;
  65250. protected _buildBlock(state: NodeMaterialBuildState): this;
  65251. }
  65252. }
  65253. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65254. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65255. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65256. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65257. /**
  65258. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65259. */
  65260. export class VectorSplitterBlock extends NodeMaterialBlock {
  65261. /**
  65262. * Create a new VectorSplitterBlock
  65263. * @param name defines the block name
  65264. */
  65265. constructor(name: string);
  65266. /**
  65267. * Gets the current class name
  65268. * @returns the class name
  65269. */
  65270. getClassName(): string;
  65271. /**
  65272. * Gets the xyzw component (input)
  65273. */
  65274. get xyzw(): NodeMaterialConnectionPoint;
  65275. /**
  65276. * Gets the xyz component (input)
  65277. */
  65278. get xyzIn(): NodeMaterialConnectionPoint;
  65279. /**
  65280. * Gets the xy component (input)
  65281. */
  65282. get xyIn(): NodeMaterialConnectionPoint;
  65283. /**
  65284. * Gets the xyz component (output)
  65285. */
  65286. get xyzOut(): NodeMaterialConnectionPoint;
  65287. /**
  65288. * Gets the xy component (output)
  65289. */
  65290. get xyOut(): NodeMaterialConnectionPoint;
  65291. /**
  65292. * Gets the x component (output)
  65293. */
  65294. get x(): NodeMaterialConnectionPoint;
  65295. /**
  65296. * Gets the y component (output)
  65297. */
  65298. get y(): NodeMaterialConnectionPoint;
  65299. /**
  65300. * Gets the z component (output)
  65301. */
  65302. get z(): NodeMaterialConnectionPoint;
  65303. /**
  65304. * Gets the w component (output)
  65305. */
  65306. get w(): NodeMaterialConnectionPoint;
  65307. protected _inputRename(name: string): string;
  65308. protected _outputRename(name: string): string;
  65309. protected _buildBlock(state: NodeMaterialBuildState): this;
  65310. }
  65311. }
  65312. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65313. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65314. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65315. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65316. /**
  65317. * Block used to lerp between 2 values
  65318. */
  65319. export class LerpBlock extends NodeMaterialBlock {
  65320. /**
  65321. * Creates a new LerpBlock
  65322. * @param name defines the block name
  65323. */
  65324. constructor(name: string);
  65325. /**
  65326. * Gets the current class name
  65327. * @returns the class name
  65328. */
  65329. getClassName(): string;
  65330. /**
  65331. * Gets the left operand input component
  65332. */
  65333. get left(): NodeMaterialConnectionPoint;
  65334. /**
  65335. * Gets the right operand input component
  65336. */
  65337. get right(): NodeMaterialConnectionPoint;
  65338. /**
  65339. * Gets the gradient operand input component
  65340. */
  65341. get gradient(): NodeMaterialConnectionPoint;
  65342. /**
  65343. * Gets the output component
  65344. */
  65345. get output(): NodeMaterialConnectionPoint;
  65346. protected _buildBlock(state: NodeMaterialBuildState): this;
  65347. }
  65348. }
  65349. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65350. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65351. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65352. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65353. /**
  65354. * Block used to divide 2 vectors
  65355. */
  65356. export class DivideBlock extends NodeMaterialBlock {
  65357. /**
  65358. * Creates a new DivideBlock
  65359. * @param name defines the block name
  65360. */
  65361. constructor(name: string);
  65362. /**
  65363. * Gets the current class name
  65364. * @returns the class name
  65365. */
  65366. getClassName(): string;
  65367. /**
  65368. * Gets the left operand input component
  65369. */
  65370. get left(): NodeMaterialConnectionPoint;
  65371. /**
  65372. * Gets the right operand input component
  65373. */
  65374. get right(): NodeMaterialConnectionPoint;
  65375. /**
  65376. * Gets the output component
  65377. */
  65378. get output(): NodeMaterialConnectionPoint;
  65379. protected _buildBlock(state: NodeMaterialBuildState): this;
  65380. }
  65381. }
  65382. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  65383. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65384. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65385. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65386. /**
  65387. * Block used to subtract 2 vectors
  65388. */
  65389. export class SubtractBlock extends NodeMaterialBlock {
  65390. /**
  65391. * Creates a new SubtractBlock
  65392. * @param name defines the block name
  65393. */
  65394. constructor(name: string);
  65395. /**
  65396. * Gets the current class name
  65397. * @returns the class name
  65398. */
  65399. getClassName(): string;
  65400. /**
  65401. * Gets the left operand input component
  65402. */
  65403. get left(): NodeMaterialConnectionPoint;
  65404. /**
  65405. * Gets the right operand input component
  65406. */
  65407. get right(): NodeMaterialConnectionPoint;
  65408. /**
  65409. * Gets the output component
  65410. */
  65411. get output(): NodeMaterialConnectionPoint;
  65412. protected _buildBlock(state: NodeMaterialBuildState): this;
  65413. }
  65414. }
  65415. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65419. /**
  65420. * Block used to step a value
  65421. */
  65422. export class StepBlock extends NodeMaterialBlock {
  65423. /**
  65424. * Creates a new StepBlock
  65425. * @param name defines the block name
  65426. */
  65427. constructor(name: string);
  65428. /**
  65429. * Gets the current class name
  65430. * @returns the class name
  65431. */
  65432. getClassName(): string;
  65433. /**
  65434. * Gets the value operand input component
  65435. */
  65436. get value(): NodeMaterialConnectionPoint;
  65437. /**
  65438. * Gets the edge operand input component
  65439. */
  65440. get edge(): NodeMaterialConnectionPoint;
  65441. /**
  65442. * Gets the output component
  65443. */
  65444. get output(): NodeMaterialConnectionPoint;
  65445. protected _buildBlock(state: NodeMaterialBuildState): this;
  65446. }
  65447. }
  65448. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  65449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65452. /**
  65453. * Block used to get the opposite (1 - x) of a value
  65454. */
  65455. export class OneMinusBlock extends NodeMaterialBlock {
  65456. /**
  65457. * Creates a new OneMinusBlock
  65458. * @param name defines the block name
  65459. */
  65460. constructor(name: string);
  65461. /**
  65462. * Gets the current class name
  65463. * @returns the class name
  65464. */
  65465. getClassName(): string;
  65466. /**
  65467. * Gets the input component
  65468. */
  65469. get input(): NodeMaterialConnectionPoint;
  65470. /**
  65471. * Gets the output component
  65472. */
  65473. get output(): NodeMaterialConnectionPoint;
  65474. protected _buildBlock(state: NodeMaterialBuildState): this;
  65475. }
  65476. }
  65477. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  65478. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65479. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65480. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65481. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65482. /**
  65483. * Block used to get the view direction
  65484. */
  65485. export class ViewDirectionBlock extends NodeMaterialBlock {
  65486. /**
  65487. * Creates a new ViewDirectionBlock
  65488. * @param name defines the block name
  65489. */
  65490. constructor(name: string);
  65491. /**
  65492. * Gets the current class name
  65493. * @returns the class name
  65494. */
  65495. getClassName(): string;
  65496. /**
  65497. * Gets the world position component
  65498. */
  65499. get worldPosition(): NodeMaterialConnectionPoint;
  65500. /**
  65501. * Gets the camera position component
  65502. */
  65503. get cameraPosition(): NodeMaterialConnectionPoint;
  65504. /**
  65505. * Gets the output component
  65506. */
  65507. get output(): NodeMaterialConnectionPoint;
  65508. autoConfigure(material: NodeMaterial): void;
  65509. protected _buildBlock(state: NodeMaterialBuildState): this;
  65510. }
  65511. }
  65512. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  65513. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65514. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65515. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65516. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65517. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  65518. /**
  65519. * Block used to compute fresnel value
  65520. */
  65521. export class FresnelBlock extends NodeMaterialBlock {
  65522. /**
  65523. * Create a new FresnelBlock
  65524. * @param name defines the block name
  65525. */
  65526. constructor(name: string);
  65527. /**
  65528. * Gets the current class name
  65529. * @returns the class name
  65530. */
  65531. getClassName(): string;
  65532. /**
  65533. * Gets the world normal input component
  65534. */
  65535. get worldNormal(): NodeMaterialConnectionPoint;
  65536. /**
  65537. * Gets the view direction input component
  65538. */
  65539. get viewDirection(): NodeMaterialConnectionPoint;
  65540. /**
  65541. * Gets the bias input component
  65542. */
  65543. get bias(): NodeMaterialConnectionPoint;
  65544. /**
  65545. * Gets the camera (or eye) position component
  65546. */
  65547. get power(): NodeMaterialConnectionPoint;
  65548. /**
  65549. * Gets the fresnel output component
  65550. */
  65551. get fresnel(): NodeMaterialConnectionPoint;
  65552. autoConfigure(material: NodeMaterial): void;
  65553. protected _buildBlock(state: NodeMaterialBuildState): this;
  65554. }
  65555. }
  65556. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  65557. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65558. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65559. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65560. /**
  65561. * Block used to get the max of 2 values
  65562. */
  65563. export class MaxBlock extends NodeMaterialBlock {
  65564. /**
  65565. * Creates a new MaxBlock
  65566. * @param name defines the block name
  65567. */
  65568. constructor(name: string);
  65569. /**
  65570. * Gets the current class name
  65571. * @returns the class name
  65572. */
  65573. getClassName(): string;
  65574. /**
  65575. * Gets the left operand input component
  65576. */
  65577. get left(): NodeMaterialConnectionPoint;
  65578. /**
  65579. * Gets the right operand input component
  65580. */
  65581. get right(): NodeMaterialConnectionPoint;
  65582. /**
  65583. * Gets the output component
  65584. */
  65585. get output(): NodeMaterialConnectionPoint;
  65586. protected _buildBlock(state: NodeMaterialBuildState): this;
  65587. }
  65588. }
  65589. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  65590. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65591. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65592. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65593. /**
  65594. * Block used to get the min of 2 values
  65595. */
  65596. export class MinBlock extends NodeMaterialBlock {
  65597. /**
  65598. * Creates a new MinBlock
  65599. * @param name defines the block name
  65600. */
  65601. constructor(name: string);
  65602. /**
  65603. * Gets the current class name
  65604. * @returns the class name
  65605. */
  65606. getClassName(): string;
  65607. /**
  65608. * Gets the left operand input component
  65609. */
  65610. get left(): NodeMaterialConnectionPoint;
  65611. /**
  65612. * Gets the right operand input component
  65613. */
  65614. get right(): NodeMaterialConnectionPoint;
  65615. /**
  65616. * Gets the output component
  65617. */
  65618. get output(): NodeMaterialConnectionPoint;
  65619. protected _buildBlock(state: NodeMaterialBuildState): this;
  65620. }
  65621. }
  65622. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  65623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65626. /**
  65627. * Block used to get the distance between 2 values
  65628. */
  65629. export class DistanceBlock extends NodeMaterialBlock {
  65630. /**
  65631. * Creates a new DistanceBlock
  65632. * @param name defines the block name
  65633. */
  65634. constructor(name: string);
  65635. /**
  65636. * Gets the current class name
  65637. * @returns the class name
  65638. */
  65639. getClassName(): string;
  65640. /**
  65641. * Gets the left operand input component
  65642. */
  65643. get left(): NodeMaterialConnectionPoint;
  65644. /**
  65645. * Gets the right operand input component
  65646. */
  65647. get right(): NodeMaterialConnectionPoint;
  65648. /**
  65649. * Gets the output component
  65650. */
  65651. get output(): NodeMaterialConnectionPoint;
  65652. protected _buildBlock(state: NodeMaterialBuildState): this;
  65653. }
  65654. }
  65655. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  65656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65659. /**
  65660. * Block used to get the length of a vector
  65661. */
  65662. export class LengthBlock extends NodeMaterialBlock {
  65663. /**
  65664. * Creates a new LengthBlock
  65665. * @param name defines the block name
  65666. */
  65667. constructor(name: string);
  65668. /**
  65669. * Gets the current class name
  65670. * @returns the class name
  65671. */
  65672. getClassName(): string;
  65673. /**
  65674. * Gets the value input component
  65675. */
  65676. get value(): NodeMaterialConnectionPoint;
  65677. /**
  65678. * Gets the output component
  65679. */
  65680. get output(): NodeMaterialConnectionPoint;
  65681. protected _buildBlock(state: NodeMaterialBuildState): this;
  65682. }
  65683. }
  65684. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  65685. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65686. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65687. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65688. /**
  65689. * Block used to get negative version of a value (i.e. x * -1)
  65690. */
  65691. export class NegateBlock extends NodeMaterialBlock {
  65692. /**
  65693. * Creates a new NegateBlock
  65694. * @param name defines the block name
  65695. */
  65696. constructor(name: string);
  65697. /**
  65698. * Gets the current class name
  65699. * @returns the class name
  65700. */
  65701. getClassName(): string;
  65702. /**
  65703. * Gets the value input component
  65704. */
  65705. get value(): NodeMaterialConnectionPoint;
  65706. /**
  65707. * Gets the output component
  65708. */
  65709. get output(): NodeMaterialConnectionPoint;
  65710. protected _buildBlock(state: NodeMaterialBuildState): this;
  65711. }
  65712. }
  65713. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65714. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65715. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65716. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65717. /**
  65718. * Block used to get the value of the first parameter raised to the power of the second
  65719. */
  65720. export class PowBlock extends NodeMaterialBlock {
  65721. /**
  65722. * Creates a new PowBlock
  65723. * @param name defines the block name
  65724. */
  65725. constructor(name: string);
  65726. /**
  65727. * Gets the current class name
  65728. * @returns the class name
  65729. */
  65730. getClassName(): string;
  65731. /**
  65732. * Gets the value operand input component
  65733. */
  65734. get value(): NodeMaterialConnectionPoint;
  65735. /**
  65736. * Gets the power operand input component
  65737. */
  65738. get power(): NodeMaterialConnectionPoint;
  65739. /**
  65740. * Gets the output component
  65741. */
  65742. get output(): NodeMaterialConnectionPoint;
  65743. protected _buildBlock(state: NodeMaterialBuildState): this;
  65744. }
  65745. }
  65746. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65747. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65748. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65749. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65750. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65751. /**
  65752. * Block used to get a random number
  65753. */
  65754. export class RandomNumberBlock extends NodeMaterialBlock {
  65755. /**
  65756. * Creates a new RandomNumberBlock
  65757. * @param name defines the block name
  65758. */
  65759. constructor(name: string);
  65760. /**
  65761. * Gets the current class name
  65762. * @returns the class name
  65763. */
  65764. getClassName(): string;
  65765. /**
  65766. * Gets the seed input component
  65767. */
  65768. get seed(): NodeMaterialConnectionPoint;
  65769. /**
  65770. * Gets the output component
  65771. */
  65772. get output(): NodeMaterialConnectionPoint;
  65773. protected _buildBlock(state: NodeMaterialBuildState): this;
  65774. }
  65775. }
  65776. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65777. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65778. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65779. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65780. /**
  65781. * Block used to compute arc tangent of 2 values
  65782. */
  65783. export class ArcTan2Block extends NodeMaterialBlock {
  65784. /**
  65785. * Creates a new ArcTan2Block
  65786. * @param name defines the block name
  65787. */
  65788. constructor(name: string);
  65789. /**
  65790. * Gets the current class name
  65791. * @returns the class name
  65792. */
  65793. getClassName(): string;
  65794. /**
  65795. * Gets the x operand input component
  65796. */
  65797. get x(): NodeMaterialConnectionPoint;
  65798. /**
  65799. * Gets the y operand input component
  65800. */
  65801. get y(): NodeMaterialConnectionPoint;
  65802. /**
  65803. * Gets the output component
  65804. */
  65805. get output(): NodeMaterialConnectionPoint;
  65806. protected _buildBlock(state: NodeMaterialBuildState): this;
  65807. }
  65808. }
  65809. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65810. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65811. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65812. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65813. /**
  65814. * Block used to smooth step a value
  65815. */
  65816. export class SmoothStepBlock extends NodeMaterialBlock {
  65817. /**
  65818. * Creates a new SmoothStepBlock
  65819. * @param name defines the block name
  65820. */
  65821. constructor(name: string);
  65822. /**
  65823. * Gets the current class name
  65824. * @returns the class name
  65825. */
  65826. getClassName(): string;
  65827. /**
  65828. * Gets the value operand input component
  65829. */
  65830. get value(): NodeMaterialConnectionPoint;
  65831. /**
  65832. * Gets the first edge operand input component
  65833. */
  65834. get edge0(): NodeMaterialConnectionPoint;
  65835. /**
  65836. * Gets the second edge operand input component
  65837. */
  65838. get edge1(): NodeMaterialConnectionPoint;
  65839. /**
  65840. * Gets the output component
  65841. */
  65842. get output(): NodeMaterialConnectionPoint;
  65843. protected _buildBlock(state: NodeMaterialBuildState): this;
  65844. }
  65845. }
  65846. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65848. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65849. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65850. /**
  65851. * Block used to get the reciprocal (1 / x) of a value
  65852. */
  65853. export class ReciprocalBlock extends NodeMaterialBlock {
  65854. /**
  65855. * Creates a new ReciprocalBlock
  65856. * @param name defines the block name
  65857. */
  65858. constructor(name: string);
  65859. /**
  65860. * Gets the current class name
  65861. * @returns the class name
  65862. */
  65863. getClassName(): string;
  65864. /**
  65865. * Gets the input component
  65866. */
  65867. get input(): NodeMaterialConnectionPoint;
  65868. /**
  65869. * Gets the output component
  65870. */
  65871. get output(): NodeMaterialConnectionPoint;
  65872. protected _buildBlock(state: NodeMaterialBuildState): this;
  65873. }
  65874. }
  65875. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65876. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65877. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65878. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65879. /**
  65880. * Block used to replace a color by another one
  65881. */
  65882. export class ReplaceColorBlock extends NodeMaterialBlock {
  65883. /**
  65884. * Creates a new ReplaceColorBlock
  65885. * @param name defines the block name
  65886. */
  65887. constructor(name: string);
  65888. /**
  65889. * Gets the current class name
  65890. * @returns the class name
  65891. */
  65892. getClassName(): string;
  65893. /**
  65894. * Gets the value input component
  65895. */
  65896. get value(): NodeMaterialConnectionPoint;
  65897. /**
  65898. * Gets the reference input component
  65899. */
  65900. get reference(): NodeMaterialConnectionPoint;
  65901. /**
  65902. * Gets the distance input component
  65903. */
  65904. get distance(): NodeMaterialConnectionPoint;
  65905. /**
  65906. * Gets the replacement input component
  65907. */
  65908. get replacement(): NodeMaterialConnectionPoint;
  65909. /**
  65910. * Gets the output component
  65911. */
  65912. get output(): NodeMaterialConnectionPoint;
  65913. protected _buildBlock(state: NodeMaterialBuildState): this;
  65914. }
  65915. }
  65916. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65917. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65918. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65919. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65920. /**
  65921. * Block used to posterize a value
  65922. * @see https://en.wikipedia.org/wiki/Posterization
  65923. */
  65924. export class PosterizeBlock extends NodeMaterialBlock {
  65925. /**
  65926. * Creates a new PosterizeBlock
  65927. * @param name defines the block name
  65928. */
  65929. constructor(name: string);
  65930. /**
  65931. * Gets the current class name
  65932. * @returns the class name
  65933. */
  65934. getClassName(): string;
  65935. /**
  65936. * Gets the value input component
  65937. */
  65938. get value(): NodeMaterialConnectionPoint;
  65939. /**
  65940. * Gets the steps input component
  65941. */
  65942. get steps(): NodeMaterialConnectionPoint;
  65943. /**
  65944. * Gets the output component
  65945. */
  65946. get output(): NodeMaterialConnectionPoint;
  65947. protected _buildBlock(state: NodeMaterialBuildState): this;
  65948. }
  65949. }
  65950. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65951. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65952. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65953. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65954. import { Scene } from "babylonjs/scene";
  65955. /**
  65956. * Operations supported by the Wave block
  65957. */
  65958. export enum WaveBlockKind {
  65959. /** SawTooth */
  65960. SawTooth = 0,
  65961. /** Square */
  65962. Square = 1,
  65963. /** Triangle */
  65964. Triangle = 2
  65965. }
  65966. /**
  65967. * Block used to apply wave operation to floats
  65968. */
  65969. export class WaveBlock extends NodeMaterialBlock {
  65970. /**
  65971. * Gets or sets the kibnd of wave to be applied by the block
  65972. */
  65973. kind: WaveBlockKind;
  65974. /**
  65975. * Creates a new WaveBlock
  65976. * @param name defines the block name
  65977. */
  65978. constructor(name: string);
  65979. /**
  65980. * Gets the current class name
  65981. * @returns the class name
  65982. */
  65983. getClassName(): string;
  65984. /**
  65985. * Gets the input component
  65986. */
  65987. get input(): NodeMaterialConnectionPoint;
  65988. /**
  65989. * Gets the output component
  65990. */
  65991. get output(): NodeMaterialConnectionPoint;
  65992. protected _buildBlock(state: NodeMaterialBuildState): this;
  65993. serialize(): any;
  65994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65995. }
  65996. }
  65997. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66001. import { Color3 } from "babylonjs/Maths/math.color";
  66002. import { Scene } from "babylonjs/scene";
  66003. /**
  66004. * Class used to store a color step for the GradientBlock
  66005. */
  66006. export class GradientBlockColorStep {
  66007. /**
  66008. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66009. */
  66010. step: number;
  66011. /**
  66012. * Gets or sets the color associated with this step
  66013. */
  66014. color: Color3;
  66015. /**
  66016. * Creates a new GradientBlockColorStep
  66017. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66018. * @param color defines the color associated with this step
  66019. */
  66020. constructor(
  66021. /**
  66022. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66023. */
  66024. step: number,
  66025. /**
  66026. * Gets or sets the color associated with this step
  66027. */
  66028. color: Color3);
  66029. }
  66030. /**
  66031. * Block used to return a color from a gradient based on an input value between 0 and 1
  66032. */
  66033. export class GradientBlock extends NodeMaterialBlock {
  66034. /**
  66035. * Gets or sets the list of color steps
  66036. */
  66037. colorSteps: GradientBlockColorStep[];
  66038. /**
  66039. * Creates a new GradientBlock
  66040. * @param name defines the block name
  66041. */
  66042. constructor(name: string);
  66043. /**
  66044. * Gets the current class name
  66045. * @returns the class name
  66046. */
  66047. getClassName(): string;
  66048. /**
  66049. * Gets the gradient input component
  66050. */
  66051. get gradient(): NodeMaterialConnectionPoint;
  66052. /**
  66053. * Gets the output component
  66054. */
  66055. get output(): NodeMaterialConnectionPoint;
  66056. private _writeColorConstant;
  66057. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66058. serialize(): any;
  66059. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66060. protected _dumpPropertiesCode(): string;
  66061. }
  66062. }
  66063. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66064. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66065. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66066. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66067. /**
  66068. * Block used to normalize lerp between 2 values
  66069. */
  66070. export class NLerpBlock extends NodeMaterialBlock {
  66071. /**
  66072. * Creates a new NLerpBlock
  66073. * @param name defines the block name
  66074. */
  66075. constructor(name: string);
  66076. /**
  66077. * Gets the current class name
  66078. * @returns the class name
  66079. */
  66080. getClassName(): string;
  66081. /**
  66082. * Gets the left operand input component
  66083. */
  66084. get left(): NodeMaterialConnectionPoint;
  66085. /**
  66086. * Gets the right operand input component
  66087. */
  66088. get right(): NodeMaterialConnectionPoint;
  66089. /**
  66090. * Gets the gradient operand input component
  66091. */
  66092. get gradient(): NodeMaterialConnectionPoint;
  66093. /**
  66094. * Gets the output component
  66095. */
  66096. get output(): NodeMaterialConnectionPoint;
  66097. protected _buildBlock(state: NodeMaterialBuildState): this;
  66098. }
  66099. }
  66100. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66104. import { Scene } from "babylonjs/scene";
  66105. /**
  66106. * block used to Generate a Worley Noise 3D Noise Pattern
  66107. */
  66108. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66109. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66110. manhattanDistance: boolean;
  66111. /**
  66112. * Creates a new WorleyNoise3DBlock
  66113. * @param name defines the block name
  66114. */
  66115. constructor(name: string);
  66116. /**
  66117. * Gets the current class name
  66118. * @returns the class name
  66119. */
  66120. getClassName(): string;
  66121. /**
  66122. * Gets the seed input component
  66123. */
  66124. get seed(): NodeMaterialConnectionPoint;
  66125. /**
  66126. * Gets the jitter input component
  66127. */
  66128. get jitter(): NodeMaterialConnectionPoint;
  66129. /**
  66130. * Gets the output component
  66131. */
  66132. get output(): NodeMaterialConnectionPoint;
  66133. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66134. /**
  66135. * Exposes the properties to the UI?
  66136. */
  66137. protected _dumpPropertiesCode(): string;
  66138. /**
  66139. * Exposes the properties to the Seralize?
  66140. */
  66141. serialize(): any;
  66142. /**
  66143. * Exposes the properties to the deseralize?
  66144. */
  66145. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66146. }
  66147. }
  66148. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66149. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66150. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66151. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66152. /**
  66153. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66154. */
  66155. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66156. /**
  66157. * Creates a new SimplexPerlin3DBlock
  66158. * @param name defines the block name
  66159. */
  66160. constructor(name: string);
  66161. /**
  66162. * Gets the current class name
  66163. * @returns the class name
  66164. */
  66165. getClassName(): string;
  66166. /**
  66167. * Gets the seed operand input component
  66168. */
  66169. get seed(): NodeMaterialConnectionPoint;
  66170. /**
  66171. * Gets the output component
  66172. */
  66173. get output(): NodeMaterialConnectionPoint;
  66174. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66175. }
  66176. }
  66177. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66181. /**
  66182. * Block used to blend normals
  66183. */
  66184. export class NormalBlendBlock extends NodeMaterialBlock {
  66185. /**
  66186. * Creates a new NormalBlendBlock
  66187. * @param name defines the block name
  66188. */
  66189. constructor(name: string);
  66190. /**
  66191. * Gets the current class name
  66192. * @returns the class name
  66193. */
  66194. getClassName(): string;
  66195. /**
  66196. * Gets the first input component
  66197. */
  66198. get normalMap0(): NodeMaterialConnectionPoint;
  66199. /**
  66200. * Gets the second input component
  66201. */
  66202. get normalMap1(): NodeMaterialConnectionPoint;
  66203. /**
  66204. * Gets the output component
  66205. */
  66206. get output(): NodeMaterialConnectionPoint;
  66207. protected _buildBlock(state: NodeMaterialBuildState): this;
  66208. }
  66209. }
  66210. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66211. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66212. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66213. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66214. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66215. /**
  66216. * Block used to rotate a 2d vector by a given angle
  66217. */
  66218. export class Rotate2dBlock extends NodeMaterialBlock {
  66219. /**
  66220. * Creates a new Rotate2dBlock
  66221. * @param name defines the block name
  66222. */
  66223. constructor(name: string);
  66224. /**
  66225. * Gets the current class name
  66226. * @returns the class name
  66227. */
  66228. getClassName(): string;
  66229. /**
  66230. * Gets the input vector
  66231. */
  66232. get input(): NodeMaterialConnectionPoint;
  66233. /**
  66234. * Gets the input angle
  66235. */
  66236. get angle(): NodeMaterialConnectionPoint;
  66237. /**
  66238. * Gets the output component
  66239. */
  66240. get output(): NodeMaterialConnectionPoint;
  66241. autoConfigure(material: NodeMaterial): void;
  66242. protected _buildBlock(state: NodeMaterialBuildState): this;
  66243. }
  66244. }
  66245. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66249. /**
  66250. * Block used to get the reflected vector from a direction and a normal
  66251. */
  66252. export class ReflectBlock extends NodeMaterialBlock {
  66253. /**
  66254. * Creates a new ReflectBlock
  66255. * @param name defines the block name
  66256. */
  66257. constructor(name: string);
  66258. /**
  66259. * Gets the current class name
  66260. * @returns the class name
  66261. */
  66262. getClassName(): string;
  66263. /**
  66264. * Gets the incident component
  66265. */
  66266. get incident(): NodeMaterialConnectionPoint;
  66267. /**
  66268. * Gets the normal component
  66269. */
  66270. get normal(): NodeMaterialConnectionPoint;
  66271. /**
  66272. * Gets the output component
  66273. */
  66274. get output(): NodeMaterialConnectionPoint;
  66275. protected _buildBlock(state: NodeMaterialBuildState): this;
  66276. }
  66277. }
  66278. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66280. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66281. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66282. /**
  66283. * Block used to get the refracted vector from a direction and a normal
  66284. */
  66285. export class RefractBlock extends NodeMaterialBlock {
  66286. /**
  66287. * Creates a new RefractBlock
  66288. * @param name defines the block name
  66289. */
  66290. constructor(name: string);
  66291. /**
  66292. * Gets the current class name
  66293. * @returns the class name
  66294. */
  66295. getClassName(): string;
  66296. /**
  66297. * Gets the incident component
  66298. */
  66299. get incident(): NodeMaterialConnectionPoint;
  66300. /**
  66301. * Gets the normal component
  66302. */
  66303. get normal(): NodeMaterialConnectionPoint;
  66304. /**
  66305. * Gets the index of refraction component
  66306. */
  66307. get ior(): NodeMaterialConnectionPoint;
  66308. /**
  66309. * Gets the output component
  66310. */
  66311. get output(): NodeMaterialConnectionPoint;
  66312. protected _buildBlock(state: NodeMaterialBuildState): this;
  66313. }
  66314. }
  66315. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66316. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66317. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66318. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66319. /**
  66320. * Block used to desaturate a color
  66321. */
  66322. export class DesaturateBlock extends NodeMaterialBlock {
  66323. /**
  66324. * Creates a new DesaturateBlock
  66325. * @param name defines the block name
  66326. */
  66327. constructor(name: string);
  66328. /**
  66329. * Gets the current class name
  66330. * @returns the class name
  66331. */
  66332. getClassName(): string;
  66333. /**
  66334. * Gets the color operand input component
  66335. */
  66336. get color(): NodeMaterialConnectionPoint;
  66337. /**
  66338. * Gets the level operand input component
  66339. */
  66340. get level(): NodeMaterialConnectionPoint;
  66341. /**
  66342. * Gets the output component
  66343. */
  66344. get output(): NodeMaterialConnectionPoint;
  66345. protected _buildBlock(state: NodeMaterialBuildState): this;
  66346. }
  66347. }
  66348. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66349. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66350. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66351. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66352. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66353. import { Nullable } from "babylonjs/types";
  66354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66355. import { Scene } from "babylonjs/scene";
  66356. /**
  66357. * Block used to implement the ambient occlusion module of the PBR material
  66358. */
  66359. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  66360. /**
  66361. * Create a new AmbientOcclusionBlock
  66362. * @param name defines the block name
  66363. */
  66364. constructor(name: string);
  66365. /**
  66366. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  66367. */
  66368. useAmbientInGrayScale: boolean;
  66369. /**
  66370. * Initialize the block and prepare the context for build
  66371. * @param state defines the state that will be used for the build
  66372. */
  66373. initialize(state: NodeMaterialBuildState): void;
  66374. /**
  66375. * Gets the current class name
  66376. * @returns the class name
  66377. */
  66378. getClassName(): string;
  66379. /**
  66380. * Gets the texture input component
  66381. */
  66382. get texture(): NodeMaterialConnectionPoint;
  66383. /**
  66384. * Gets the texture intensity component
  66385. */
  66386. get intensity(): NodeMaterialConnectionPoint;
  66387. /**
  66388. * Gets the direct light intensity input component
  66389. */
  66390. get directLightIntensity(): NodeMaterialConnectionPoint;
  66391. /**
  66392. * Gets the ambient occlusion object output component
  66393. */
  66394. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66395. /**
  66396. * Gets the main code of the block (fragment side)
  66397. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  66398. * @returns the shader code
  66399. */
  66400. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  66401. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66402. protected _buildBlock(state: NodeMaterialBuildState): this;
  66403. protected _dumpPropertiesCode(): string;
  66404. serialize(): any;
  66405. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66406. }
  66407. }
  66408. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66409. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66410. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66411. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66412. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66414. import { Nullable } from "babylonjs/types";
  66415. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66416. import { Mesh } from "babylonjs/Meshes/mesh";
  66417. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66418. import { Effect } from "babylonjs/Materials/effect";
  66419. import { Scene } from "babylonjs/scene";
  66420. /**
  66421. * Block used to implement the reflection module of the PBR material
  66422. */
  66423. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66424. /** @hidden */
  66425. _defineLODReflectionAlpha: string;
  66426. /** @hidden */
  66427. _defineLinearSpecularReflection: string;
  66428. private _vEnvironmentIrradianceName;
  66429. /** @hidden */
  66430. _vReflectionMicrosurfaceInfosName: string;
  66431. /** @hidden */
  66432. _vReflectionInfosName: string;
  66433. /** @hidden */
  66434. _vReflectionFilteringInfoName: string;
  66435. private _scene;
  66436. /**
  66437. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66438. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66439. * It's less burden on the user side in the editor part.
  66440. */
  66441. /** @hidden */
  66442. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66443. /** @hidden */
  66444. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66445. /** @hidden */
  66446. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  66447. /**
  66448. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  66449. * diffuse part of the IBL.
  66450. */
  66451. useSphericalHarmonics: boolean;
  66452. /**
  66453. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  66454. */
  66455. forceIrradianceInFragment: boolean;
  66456. /**
  66457. * Create a new ReflectionBlock
  66458. * @param name defines the block name
  66459. */
  66460. constructor(name: string);
  66461. /**
  66462. * Gets the current class name
  66463. * @returns the class name
  66464. */
  66465. getClassName(): string;
  66466. /**
  66467. * Gets the position input component
  66468. */
  66469. get position(): NodeMaterialConnectionPoint;
  66470. /**
  66471. * Gets the world position input component
  66472. */
  66473. get worldPosition(): NodeMaterialConnectionPoint;
  66474. /**
  66475. * Gets the world normal input component
  66476. */
  66477. get worldNormal(): NodeMaterialConnectionPoint;
  66478. /**
  66479. * Gets the world input component
  66480. */
  66481. get world(): NodeMaterialConnectionPoint;
  66482. /**
  66483. * Gets the camera (or eye) position component
  66484. */
  66485. get cameraPosition(): NodeMaterialConnectionPoint;
  66486. /**
  66487. * Gets the view input component
  66488. */
  66489. get view(): NodeMaterialConnectionPoint;
  66490. /**
  66491. * Gets the color input component
  66492. */
  66493. get color(): NodeMaterialConnectionPoint;
  66494. /**
  66495. * Gets the reflection object output component
  66496. */
  66497. get reflection(): NodeMaterialConnectionPoint;
  66498. /**
  66499. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  66500. */
  66501. get hasTexture(): boolean;
  66502. /**
  66503. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  66504. */
  66505. get reflectionColor(): string;
  66506. protected _getTexture(): Nullable<BaseTexture>;
  66507. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66508. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66509. /**
  66510. * Gets the code to inject in the vertex shader
  66511. * @param state current state of the node material building
  66512. * @returns the shader code
  66513. */
  66514. handleVertexSide(state: NodeMaterialBuildState): string;
  66515. /**
  66516. * Gets the main code of the block (fragment side)
  66517. * @param state current state of the node material building
  66518. * @param normalVarName name of the existing variable corresponding to the normal
  66519. * @returns the shader code
  66520. */
  66521. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  66522. protected _buildBlock(state: NodeMaterialBuildState): this;
  66523. protected _dumpPropertiesCode(): string;
  66524. serialize(): any;
  66525. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66526. }
  66527. }
  66528. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  66529. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66530. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66531. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66532. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66534. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66535. import { Scene } from "babylonjs/scene";
  66536. import { Nullable } from "babylonjs/types";
  66537. /**
  66538. * Block used to implement the sheen module of the PBR material
  66539. */
  66540. export class SheenBlock extends NodeMaterialBlock {
  66541. /**
  66542. * Create a new SheenBlock
  66543. * @param name defines the block name
  66544. */
  66545. constructor(name: string);
  66546. /**
  66547. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  66548. * It allows the strength of the sheen effect to not depend on the base color of the material,
  66549. * making it easier to setup and tweak the effect
  66550. */
  66551. albedoScaling: boolean;
  66552. /**
  66553. * Defines if the sheen is linked to the sheen color.
  66554. */
  66555. linkSheenWithAlbedo: boolean;
  66556. /**
  66557. * Initialize the block and prepare the context for build
  66558. * @param state defines the state that will be used for the build
  66559. */
  66560. initialize(state: NodeMaterialBuildState): void;
  66561. /**
  66562. * Gets the current class name
  66563. * @returns the class name
  66564. */
  66565. getClassName(): string;
  66566. /**
  66567. * Gets the intensity input component
  66568. */
  66569. get intensity(): NodeMaterialConnectionPoint;
  66570. /**
  66571. * Gets the color input component
  66572. */
  66573. get color(): NodeMaterialConnectionPoint;
  66574. /**
  66575. * Gets the roughness input component
  66576. */
  66577. get roughness(): NodeMaterialConnectionPoint;
  66578. /**
  66579. * Gets the sheen object output component
  66580. */
  66581. get sheen(): NodeMaterialConnectionPoint;
  66582. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66583. /**
  66584. * Gets the main code of the block (fragment side)
  66585. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66586. * @returns the shader code
  66587. */
  66588. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  66589. protected _buildBlock(state: NodeMaterialBuildState): this;
  66590. protected _dumpPropertiesCode(): string;
  66591. serialize(): any;
  66592. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66593. }
  66594. }
  66595. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  66596. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66597. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66600. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66601. import { Scene } from "babylonjs/scene";
  66602. import { Nullable } from "babylonjs/types";
  66603. import { Mesh } from "babylonjs/Meshes/mesh";
  66604. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66605. import { Effect } from "babylonjs/Materials/effect";
  66606. /**
  66607. * Block used to implement the reflectivity module of the PBR material
  66608. */
  66609. export class ReflectivityBlock extends NodeMaterialBlock {
  66610. private _metallicReflectanceColor;
  66611. private _metallicF0Factor;
  66612. /** @hidden */
  66613. _vMetallicReflectanceFactorsName: string;
  66614. /**
  66615. * The property below is set by the main PBR block prior to calling methods of this class.
  66616. */
  66617. /** @hidden */
  66618. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  66619. /**
  66620. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  66621. */
  66622. useAmbientOcclusionFromMetallicTextureRed: boolean;
  66623. /**
  66624. * Specifies if the metallic texture contains the metallness information in its blue channel.
  66625. */
  66626. useMetallnessFromMetallicTextureBlue: boolean;
  66627. /**
  66628. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  66629. */
  66630. useRoughnessFromMetallicTextureAlpha: boolean;
  66631. /**
  66632. * Specifies if the metallic texture contains the roughness information in its green channel.
  66633. */
  66634. useRoughnessFromMetallicTextureGreen: boolean;
  66635. /**
  66636. * Create a new ReflectivityBlock
  66637. * @param name defines the block name
  66638. */
  66639. constructor(name: string);
  66640. /**
  66641. * Initialize the block and prepare the context for build
  66642. * @param state defines the state that will be used for the build
  66643. */
  66644. initialize(state: NodeMaterialBuildState): void;
  66645. /**
  66646. * Gets the current class name
  66647. * @returns the class name
  66648. */
  66649. getClassName(): string;
  66650. /**
  66651. * Gets the metallic input component
  66652. */
  66653. get metallic(): NodeMaterialConnectionPoint;
  66654. /**
  66655. * Gets the roughness input component
  66656. */
  66657. get roughness(): NodeMaterialConnectionPoint;
  66658. /**
  66659. * Gets the texture input component
  66660. */
  66661. get texture(): NodeMaterialConnectionPoint;
  66662. /**
  66663. * Gets the reflectivity object output component
  66664. */
  66665. get reflectivity(): NodeMaterialConnectionPoint;
  66666. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66667. /**
  66668. * Gets the main code of the block (fragment side)
  66669. * @param state current state of the node material building
  66670. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  66671. * @returns the shader code
  66672. */
  66673. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  66674. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66675. protected _buildBlock(state: NodeMaterialBuildState): this;
  66676. protected _dumpPropertiesCode(): string;
  66677. serialize(): any;
  66678. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66679. }
  66680. }
  66681. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  66682. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66683. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66684. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66685. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66687. /**
  66688. * Block used to implement the anisotropy module of the PBR material
  66689. */
  66690. export class AnisotropyBlock extends NodeMaterialBlock {
  66691. /**
  66692. * The two properties below are set by the main PBR block prior to calling methods of this class.
  66693. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66694. * It's less burden on the user side in the editor part.
  66695. */
  66696. /** @hidden */
  66697. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66698. /** @hidden */
  66699. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66700. /**
  66701. * Create a new AnisotropyBlock
  66702. * @param name defines the block name
  66703. */
  66704. constructor(name: string);
  66705. /**
  66706. * Initialize the block and prepare the context for build
  66707. * @param state defines the state that will be used for the build
  66708. */
  66709. initialize(state: NodeMaterialBuildState): void;
  66710. /**
  66711. * Gets the current class name
  66712. * @returns the class name
  66713. */
  66714. getClassName(): string;
  66715. /**
  66716. * Gets the intensity input component
  66717. */
  66718. get intensity(): NodeMaterialConnectionPoint;
  66719. /**
  66720. * Gets the direction input component
  66721. */
  66722. get direction(): NodeMaterialConnectionPoint;
  66723. /**
  66724. * Gets the texture input component
  66725. */
  66726. get texture(): NodeMaterialConnectionPoint;
  66727. /**
  66728. * Gets the uv input component
  66729. */
  66730. get uv(): NodeMaterialConnectionPoint;
  66731. /**
  66732. * Gets the worldTangent input component
  66733. */
  66734. get worldTangent(): NodeMaterialConnectionPoint;
  66735. /**
  66736. * Gets the anisotropy object output component
  66737. */
  66738. get anisotropy(): NodeMaterialConnectionPoint;
  66739. private _generateTBNSpace;
  66740. /**
  66741. * Gets the main code of the block (fragment side)
  66742. * @param state current state of the node material building
  66743. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66744. * @returns the shader code
  66745. */
  66746. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66747. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66748. protected _buildBlock(state: NodeMaterialBuildState): this;
  66749. }
  66750. }
  66751. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66752. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66753. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66754. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66755. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66757. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66758. import { Nullable } from "babylonjs/types";
  66759. import { Mesh } from "babylonjs/Meshes/mesh";
  66760. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66761. import { Effect } from "babylonjs/Materials/effect";
  66762. /**
  66763. * Block used to implement the clear coat module of the PBR material
  66764. */
  66765. export class ClearCoatBlock extends NodeMaterialBlock {
  66766. private _scene;
  66767. /**
  66768. * Create a new ClearCoatBlock
  66769. * @param name defines the block name
  66770. */
  66771. constructor(name: string);
  66772. /**
  66773. * Initialize the block and prepare the context for build
  66774. * @param state defines the state that will be used for the build
  66775. */
  66776. initialize(state: NodeMaterialBuildState): void;
  66777. /**
  66778. * Gets the current class name
  66779. * @returns the class name
  66780. */
  66781. getClassName(): string;
  66782. /**
  66783. * Gets the intensity input component
  66784. */
  66785. get intensity(): NodeMaterialConnectionPoint;
  66786. /**
  66787. * Gets the roughness input component
  66788. */
  66789. get roughness(): NodeMaterialConnectionPoint;
  66790. /**
  66791. * Gets the ior input component
  66792. */
  66793. get ior(): NodeMaterialConnectionPoint;
  66794. /**
  66795. * Gets the texture input component
  66796. */
  66797. get texture(): NodeMaterialConnectionPoint;
  66798. /**
  66799. * Gets the bump texture input component
  66800. */
  66801. get bumpTexture(): NodeMaterialConnectionPoint;
  66802. /**
  66803. * Gets the uv input component
  66804. */
  66805. get uv(): NodeMaterialConnectionPoint;
  66806. /**
  66807. * Gets the tint color input component
  66808. */
  66809. get tintColor(): NodeMaterialConnectionPoint;
  66810. /**
  66811. * Gets the tint "at distance" input component
  66812. */
  66813. get tintAtDistance(): NodeMaterialConnectionPoint;
  66814. /**
  66815. * Gets the tint thickness input component
  66816. */
  66817. get tintThickness(): NodeMaterialConnectionPoint;
  66818. /**
  66819. * Gets the world tangent input component
  66820. */
  66821. get worldTangent(): NodeMaterialConnectionPoint;
  66822. /**
  66823. * Gets the clear coat object output component
  66824. */
  66825. get clearcoat(): NodeMaterialConnectionPoint;
  66826. autoConfigure(material: NodeMaterial): void;
  66827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66828. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66829. private _generateTBNSpace;
  66830. /**
  66831. * Gets the main code of the block (fragment side)
  66832. * @param state current state of the node material building
  66833. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66834. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66835. * @param worldPosVarName name of the variable holding the world position
  66836. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66837. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66838. * @param worldNormalVarName name of the variable holding the world normal
  66839. * @returns the shader code
  66840. */
  66841. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66842. protected _buildBlock(state: NodeMaterialBuildState): this;
  66843. }
  66844. }
  66845. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66846. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66847. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66848. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66849. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66851. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66852. import { Nullable } from "babylonjs/types";
  66853. /**
  66854. * Block used to implement the sub surface module of the PBR material
  66855. */
  66856. export class SubSurfaceBlock extends NodeMaterialBlock {
  66857. /**
  66858. * Create a new SubSurfaceBlock
  66859. * @param name defines the block name
  66860. */
  66861. constructor(name: string);
  66862. /**
  66863. * Stores the intensity of the different subsurface effects in the thickness texture.
  66864. * * the green channel is the translucency intensity.
  66865. * * the blue channel is the scattering intensity.
  66866. * * the alpha channel is the refraction intensity.
  66867. */
  66868. useMaskFromThicknessTexture: boolean;
  66869. /**
  66870. * Initialize the block and prepare the context for build
  66871. * @param state defines the state that will be used for the build
  66872. */
  66873. initialize(state: NodeMaterialBuildState): void;
  66874. /**
  66875. * Gets the current class name
  66876. * @returns the class name
  66877. */
  66878. getClassName(): string;
  66879. /**
  66880. * Gets the min thickness input component
  66881. */
  66882. get minThickness(): NodeMaterialConnectionPoint;
  66883. /**
  66884. * Gets the max thickness input component
  66885. */
  66886. get maxThickness(): NodeMaterialConnectionPoint;
  66887. /**
  66888. * Gets the thickness texture component
  66889. */
  66890. get thicknessTexture(): NodeMaterialConnectionPoint;
  66891. /**
  66892. * Gets the tint color input component
  66893. */
  66894. get tintColor(): NodeMaterialConnectionPoint;
  66895. /**
  66896. * Gets the translucency intensity input component
  66897. */
  66898. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66899. /**
  66900. * Gets the translucency diffusion distance input component
  66901. */
  66902. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66903. /**
  66904. * Gets the refraction object parameters
  66905. */
  66906. get refraction(): NodeMaterialConnectionPoint;
  66907. /**
  66908. * Gets the sub surface object output component
  66909. */
  66910. get subsurface(): NodeMaterialConnectionPoint;
  66911. autoConfigure(material: NodeMaterial): void;
  66912. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66913. /**
  66914. * Gets the main code of the block (fragment side)
  66915. * @param state current state of the node material building
  66916. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66917. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66918. * @param worldPosVarName name of the variable holding the world position
  66919. * @returns the shader code
  66920. */
  66921. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66922. protected _buildBlock(state: NodeMaterialBuildState): this;
  66923. }
  66924. }
  66925. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66926. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66927. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66928. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66929. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66930. import { Light } from "babylonjs/Lights/light";
  66931. import { Nullable } from "babylonjs/types";
  66932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66933. import { Effect } from "babylonjs/Materials/effect";
  66934. import { Mesh } from "babylonjs/Meshes/mesh";
  66935. import { Scene } from "babylonjs/scene";
  66936. /**
  66937. * Block used to implement the PBR metallic/roughness model
  66938. */
  66939. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66940. /**
  66941. * Gets or sets the light associated with this block
  66942. */
  66943. light: Nullable<Light>;
  66944. private _lightId;
  66945. private _scene;
  66946. private _environmentBRDFTexture;
  66947. private _environmentBrdfSamplerName;
  66948. private _vNormalWName;
  66949. private _invertNormalName;
  66950. /**
  66951. * Create a new ReflectionBlock
  66952. * @param name defines the block name
  66953. */
  66954. constructor(name: string);
  66955. /**
  66956. * Intensity of the direct lights e.g. the four lights available in your scene.
  66957. * This impacts both the direct diffuse and specular highlights.
  66958. */
  66959. directIntensity: number;
  66960. /**
  66961. * Intensity of the environment e.g. how much the environment will light the object
  66962. * either through harmonics for rough material or through the refelction for shiny ones.
  66963. */
  66964. environmentIntensity: number;
  66965. /**
  66966. * This is a special control allowing the reduction of the specular highlights coming from the
  66967. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66968. */
  66969. specularIntensity: number;
  66970. /**
  66971. * Defines the falloff type used in this material.
  66972. * It by default is Physical.
  66973. */
  66974. lightFalloff: number;
  66975. /**
  66976. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66977. */
  66978. useAlphaFromAlbedoTexture: boolean;
  66979. /**
  66980. * Specifies that alpha test should be used
  66981. */
  66982. useAlphaTest: boolean;
  66983. /**
  66984. * Defines the alpha limits in alpha test mode.
  66985. */
  66986. alphaTestCutoff: number;
  66987. /**
  66988. * Specifies that alpha blending should be used
  66989. */
  66990. useAlphaBlending: boolean;
  66991. /**
  66992. * Defines if the alpha value should be determined via the rgb values.
  66993. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66994. */
  66995. opacityRGB: boolean;
  66996. /**
  66997. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66998. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66999. */
  67000. useRadianceOverAlpha: boolean;
  67001. /**
  67002. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67003. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67004. */
  67005. useSpecularOverAlpha: boolean;
  67006. /**
  67007. * Enables specular anti aliasing in the PBR shader.
  67008. * It will both interacts on the Geometry for analytical and IBL lighting.
  67009. * It also prefilter the roughness map based on the bump values.
  67010. */
  67011. enableSpecularAntiAliasing: boolean;
  67012. /**
  67013. * Enables realtime filtering on the texture.
  67014. */
  67015. realTimeFiltering: boolean;
  67016. /**
  67017. * Quality switch for realtime filtering
  67018. */
  67019. realTimeFilteringQuality: number;
  67020. /**
  67021. * Defines if the material uses energy conservation.
  67022. */
  67023. useEnergyConservation: boolean;
  67024. /**
  67025. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67026. * too much the area relying on ambient texture to define their ambient occlusion.
  67027. */
  67028. useRadianceOcclusion: boolean;
  67029. /**
  67030. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67031. * makes the reflect vector face the model (under horizon).
  67032. */
  67033. useHorizonOcclusion: boolean;
  67034. /**
  67035. * If set to true, no lighting calculations will be applied.
  67036. */
  67037. unlit: boolean;
  67038. /**
  67039. * Force normal to face away from face.
  67040. */
  67041. forceNormalForward: boolean;
  67042. /**
  67043. * Defines the material debug mode.
  67044. * It helps seeing only some components of the material while troubleshooting.
  67045. */
  67046. debugMode: number;
  67047. /**
  67048. * Specify from where on screen the debug mode should start.
  67049. * The value goes from -1 (full screen) to 1 (not visible)
  67050. * It helps with side by side comparison against the final render
  67051. * This defaults to 0
  67052. */
  67053. debugLimit: number;
  67054. /**
  67055. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67056. * You can use the factor to better multiply the final value.
  67057. */
  67058. debugFactor: number;
  67059. /**
  67060. * Initialize the block and prepare the context for build
  67061. * @param state defines the state that will be used for the build
  67062. */
  67063. initialize(state: NodeMaterialBuildState): void;
  67064. /**
  67065. * Gets the current class name
  67066. * @returns the class name
  67067. */
  67068. getClassName(): string;
  67069. /**
  67070. * Gets the world position input component
  67071. */
  67072. get worldPosition(): NodeMaterialConnectionPoint;
  67073. /**
  67074. * Gets the world normal input component
  67075. */
  67076. get worldNormal(): NodeMaterialConnectionPoint;
  67077. /**
  67078. * Gets the perturbed normal input component
  67079. */
  67080. get perturbedNormal(): NodeMaterialConnectionPoint;
  67081. /**
  67082. * Gets the camera position input component
  67083. */
  67084. get cameraPosition(): NodeMaterialConnectionPoint;
  67085. /**
  67086. * Gets the base color input component
  67087. */
  67088. get baseColor(): NodeMaterialConnectionPoint;
  67089. /**
  67090. * Gets the opacity texture input component
  67091. */
  67092. get opacityTexture(): NodeMaterialConnectionPoint;
  67093. /**
  67094. * Gets the ambient color input component
  67095. */
  67096. get ambientColor(): NodeMaterialConnectionPoint;
  67097. /**
  67098. * Gets the reflectivity object parameters
  67099. */
  67100. get reflectivity(): NodeMaterialConnectionPoint;
  67101. /**
  67102. * Gets the ambient occlusion object parameters
  67103. */
  67104. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67105. /**
  67106. * Gets the reflection object parameters
  67107. */
  67108. get reflection(): NodeMaterialConnectionPoint;
  67109. /**
  67110. * Gets the sheen object parameters
  67111. */
  67112. get sheen(): NodeMaterialConnectionPoint;
  67113. /**
  67114. * Gets the clear coat object parameters
  67115. */
  67116. get clearcoat(): NodeMaterialConnectionPoint;
  67117. /**
  67118. * Gets the sub surface object parameters
  67119. */
  67120. get subsurface(): NodeMaterialConnectionPoint;
  67121. /**
  67122. * Gets the anisotropy object parameters
  67123. */
  67124. get anisotropy(): NodeMaterialConnectionPoint;
  67125. /**
  67126. * Gets the ambient output component
  67127. */
  67128. get ambient(): NodeMaterialConnectionPoint;
  67129. /**
  67130. * Gets the diffuse output component
  67131. */
  67132. get diffuse(): NodeMaterialConnectionPoint;
  67133. /**
  67134. * Gets the specular output component
  67135. */
  67136. get specular(): NodeMaterialConnectionPoint;
  67137. /**
  67138. * Gets the sheen output component
  67139. */
  67140. get sheenDir(): NodeMaterialConnectionPoint;
  67141. /**
  67142. * Gets the clear coat output component
  67143. */
  67144. get clearcoatDir(): NodeMaterialConnectionPoint;
  67145. /**
  67146. * Gets the indirect diffuse output component
  67147. */
  67148. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67149. /**
  67150. * Gets the indirect specular output component
  67151. */
  67152. get specularIndirect(): NodeMaterialConnectionPoint;
  67153. /**
  67154. * Gets the indirect sheen output component
  67155. */
  67156. get sheenIndirect(): NodeMaterialConnectionPoint;
  67157. /**
  67158. * Gets the indirect clear coat output component
  67159. */
  67160. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67161. /**
  67162. * Gets the refraction output component
  67163. */
  67164. get refraction(): NodeMaterialConnectionPoint;
  67165. /**
  67166. * Gets the global lighting output component
  67167. */
  67168. get lighting(): NodeMaterialConnectionPoint;
  67169. /**
  67170. * Gets the shadow output component
  67171. */
  67172. get shadow(): NodeMaterialConnectionPoint;
  67173. /**
  67174. * Gets the alpha output component
  67175. */
  67176. get alpha(): NodeMaterialConnectionPoint;
  67177. autoConfigure(material: NodeMaterial): void;
  67178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67179. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67180. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67181. private _injectVertexCode;
  67182. /**
  67183. * Gets the code corresponding to the albedo/opacity module
  67184. * @returns the shader code
  67185. */
  67186. getAlbedoOpacityCode(): string;
  67187. protected _buildBlock(state: NodeMaterialBuildState): this;
  67188. protected _dumpPropertiesCode(): string;
  67189. serialize(): any;
  67190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67191. }
  67192. }
  67193. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67194. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67195. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67196. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67197. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67198. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67199. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67200. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67201. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67202. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67203. }
  67204. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67205. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67206. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67207. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67208. }
  67209. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67213. /**
  67214. * Block used to compute value of one parameter modulo another
  67215. */
  67216. export class ModBlock extends NodeMaterialBlock {
  67217. /**
  67218. * Creates a new ModBlock
  67219. * @param name defines the block name
  67220. */
  67221. constructor(name: string);
  67222. /**
  67223. * Gets the current class name
  67224. * @returns the class name
  67225. */
  67226. getClassName(): string;
  67227. /**
  67228. * Gets the left operand input component
  67229. */
  67230. get left(): NodeMaterialConnectionPoint;
  67231. /**
  67232. * Gets the right operand input component
  67233. */
  67234. get right(): NodeMaterialConnectionPoint;
  67235. /**
  67236. * Gets the output component
  67237. */
  67238. get output(): NodeMaterialConnectionPoint;
  67239. protected _buildBlock(state: NodeMaterialBuildState): this;
  67240. }
  67241. }
  67242. declare module "babylonjs/Materials/Node/Blocks/index" {
  67243. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67244. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67245. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67246. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67247. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67248. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67249. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67250. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67251. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67252. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67253. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67254. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67255. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67256. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67257. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67258. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67259. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67260. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67261. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67262. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67263. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67264. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67265. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67266. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67267. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67268. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67269. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67270. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67271. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67272. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67273. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67274. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67275. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67276. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67277. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67278. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67279. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67280. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67281. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67282. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67283. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67284. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67285. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67286. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67287. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67288. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67289. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67290. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67291. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67292. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67293. }
  67294. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67295. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67296. }
  67297. declare module "babylonjs/Materials/Node/index" {
  67298. export * from "babylonjs/Materials/Node/Enums/index";
  67299. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67300. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67301. export * from "babylonjs/Materials/Node/nodeMaterial";
  67302. export * from "babylonjs/Materials/Node/Blocks/index";
  67303. export * from "babylonjs/Materials/Node/Optimizers/index";
  67304. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67305. }
  67306. declare module "babylonjs/Materials/index" {
  67307. export * from "babylonjs/Materials/Background/index";
  67308. export * from "babylonjs/Materials/colorCurves";
  67309. export * from "babylonjs/Materials/iEffectFallbacks";
  67310. export * from "babylonjs/Materials/effectFallbacks";
  67311. export * from "babylonjs/Materials/effect";
  67312. export * from "babylonjs/Materials/fresnelParameters";
  67313. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67314. export * from "babylonjs/Materials/material";
  67315. export * from "babylonjs/Materials/materialDefines";
  67316. export * from "babylonjs/Materials/materialHelper";
  67317. export * from "babylonjs/Materials/multiMaterial";
  67318. export * from "babylonjs/Materials/PBR/index";
  67319. export * from "babylonjs/Materials/pushMaterial";
  67320. export * from "babylonjs/Materials/shaderMaterial";
  67321. export * from "babylonjs/Materials/standardMaterial";
  67322. export * from "babylonjs/Materials/Textures/index";
  67323. export * from "babylonjs/Materials/uniformBuffer";
  67324. export * from "babylonjs/Materials/materialFlags";
  67325. export * from "babylonjs/Materials/Node/index";
  67326. export * from "babylonjs/Materials/effectRenderer";
  67327. export * from "babylonjs/Materials/shadowDepthWrapper";
  67328. }
  67329. declare module "babylonjs/Maths/index" {
  67330. export * from "babylonjs/Maths/math.scalar";
  67331. export * from "babylonjs/Maths/math";
  67332. export * from "babylonjs/Maths/sphericalPolynomial";
  67333. }
  67334. declare module "babylonjs/Misc/workerPool" {
  67335. import { IDisposable } from "babylonjs/scene";
  67336. /**
  67337. * Helper class to push actions to a pool of workers.
  67338. */
  67339. export class WorkerPool implements IDisposable {
  67340. private _workerInfos;
  67341. private _pendingActions;
  67342. /**
  67343. * Constructor
  67344. * @param workers Array of workers to use for actions
  67345. */
  67346. constructor(workers: Array<Worker>);
  67347. /**
  67348. * Terminates all workers and clears any pending actions.
  67349. */
  67350. dispose(): void;
  67351. /**
  67352. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67353. * pended until a worker has completed its action.
  67354. * @param action The action to perform. Call onComplete when the action is complete.
  67355. */
  67356. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67357. private _execute;
  67358. }
  67359. }
  67360. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  67361. import { IDisposable } from "babylonjs/scene";
  67362. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67363. /**
  67364. * Configuration for Draco compression
  67365. */
  67366. export interface IDracoCompressionConfiguration {
  67367. /**
  67368. * Configuration for the decoder.
  67369. */
  67370. decoder: {
  67371. /**
  67372. * The url to the WebAssembly module.
  67373. */
  67374. wasmUrl?: string;
  67375. /**
  67376. * The url to the WebAssembly binary.
  67377. */
  67378. wasmBinaryUrl?: string;
  67379. /**
  67380. * The url to the fallback JavaScript module.
  67381. */
  67382. fallbackUrl?: string;
  67383. };
  67384. }
  67385. /**
  67386. * Draco compression (https://google.github.io/draco/)
  67387. *
  67388. * This class wraps the Draco module.
  67389. *
  67390. * **Encoder**
  67391. *
  67392. * The encoder is not currently implemented.
  67393. *
  67394. * **Decoder**
  67395. *
  67396. * 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.
  67397. *
  67398. * To update the configuration, use the following code:
  67399. * ```javascript
  67400. * DracoCompression.Configuration = {
  67401. * decoder: {
  67402. * wasmUrl: "<url to the WebAssembly library>",
  67403. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67404. * fallbackUrl: "<url to the fallback JavaScript library>",
  67405. * }
  67406. * };
  67407. * ```
  67408. *
  67409. * 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.
  67410. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67411. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67412. *
  67413. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67414. * ```javascript
  67415. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67416. * ```
  67417. *
  67418. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67419. */
  67420. export class DracoCompression implements IDisposable {
  67421. private _workerPoolPromise?;
  67422. private _decoderModulePromise?;
  67423. /**
  67424. * The configuration. Defaults to the following urls:
  67425. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67426. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67427. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67428. */
  67429. static Configuration: IDracoCompressionConfiguration;
  67430. /**
  67431. * Returns true if the decoder configuration is available.
  67432. */
  67433. static get DecoderAvailable(): boolean;
  67434. /**
  67435. * Default number of workers to create when creating the draco compression object.
  67436. */
  67437. static DefaultNumWorkers: number;
  67438. private static GetDefaultNumWorkers;
  67439. private static _Default;
  67440. /**
  67441. * Default instance for the draco compression object.
  67442. */
  67443. static get Default(): DracoCompression;
  67444. /**
  67445. * Constructor
  67446. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  67447. */
  67448. constructor(numWorkers?: number);
  67449. /**
  67450. * Stop all async operations and release resources.
  67451. */
  67452. dispose(): void;
  67453. /**
  67454. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  67455. * @returns a promise that resolves when ready
  67456. */
  67457. whenReadyAsync(): Promise<void>;
  67458. /**
  67459. * Decode Draco compressed mesh data to vertex data.
  67460. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  67461. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  67462. * @returns A promise that resolves with the decoded vertex data
  67463. */
  67464. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  67465. [kind: string]: number;
  67466. }): Promise<VertexData>;
  67467. }
  67468. }
  67469. declare module "babylonjs/Meshes/Compression/index" {
  67470. export * from "babylonjs/Meshes/Compression/dracoCompression";
  67471. }
  67472. declare module "babylonjs/Meshes/csg" {
  67473. import { Nullable } from "babylonjs/types";
  67474. import { Scene } from "babylonjs/scene";
  67475. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67476. import { Mesh } from "babylonjs/Meshes/mesh";
  67477. import { Material } from "babylonjs/Materials/material";
  67478. /**
  67479. * Class for building Constructive Solid Geometry
  67480. */
  67481. export class CSG {
  67482. private polygons;
  67483. /**
  67484. * The world matrix
  67485. */
  67486. matrix: Matrix;
  67487. /**
  67488. * Stores the position
  67489. */
  67490. position: Vector3;
  67491. /**
  67492. * Stores the rotation
  67493. */
  67494. rotation: Vector3;
  67495. /**
  67496. * Stores the rotation quaternion
  67497. */
  67498. rotationQuaternion: Nullable<Quaternion>;
  67499. /**
  67500. * Stores the scaling vector
  67501. */
  67502. scaling: Vector3;
  67503. /**
  67504. * Convert the Mesh to CSG
  67505. * @param mesh The Mesh to convert to CSG
  67506. * @returns A new CSG from the Mesh
  67507. */
  67508. static FromMesh(mesh: Mesh): CSG;
  67509. /**
  67510. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  67511. * @param polygons Polygons used to construct a CSG solid
  67512. */
  67513. private static FromPolygons;
  67514. /**
  67515. * Clones, or makes a deep copy, of the CSG
  67516. * @returns A new CSG
  67517. */
  67518. clone(): CSG;
  67519. /**
  67520. * Unions this CSG with another CSG
  67521. * @param csg The CSG to union against this CSG
  67522. * @returns The unioned CSG
  67523. */
  67524. union(csg: CSG): CSG;
  67525. /**
  67526. * Unions this CSG with another CSG in place
  67527. * @param csg The CSG to union against this CSG
  67528. */
  67529. unionInPlace(csg: CSG): void;
  67530. /**
  67531. * Subtracts this CSG with another CSG
  67532. * @param csg The CSG to subtract against this CSG
  67533. * @returns A new CSG
  67534. */
  67535. subtract(csg: CSG): CSG;
  67536. /**
  67537. * Subtracts this CSG with another CSG in place
  67538. * @param csg The CSG to subtact against this CSG
  67539. */
  67540. subtractInPlace(csg: CSG): void;
  67541. /**
  67542. * Intersect this CSG with another CSG
  67543. * @param csg The CSG to intersect against this CSG
  67544. * @returns A new CSG
  67545. */
  67546. intersect(csg: CSG): CSG;
  67547. /**
  67548. * Intersects this CSG with another CSG in place
  67549. * @param csg The CSG to intersect against this CSG
  67550. */
  67551. intersectInPlace(csg: CSG): void;
  67552. /**
  67553. * Return a new CSG solid with solid and empty space switched. This solid is
  67554. * not modified.
  67555. * @returns A new CSG solid with solid and empty space switched
  67556. */
  67557. inverse(): CSG;
  67558. /**
  67559. * Inverses the CSG in place
  67560. */
  67561. inverseInPlace(): void;
  67562. /**
  67563. * This is used to keep meshes transformations so they can be restored
  67564. * when we build back a Babylon Mesh
  67565. * NB : All CSG operations are performed in world coordinates
  67566. * @param csg The CSG to copy the transform attributes from
  67567. * @returns This CSG
  67568. */
  67569. copyTransformAttributes(csg: CSG): CSG;
  67570. /**
  67571. * Build Raw mesh from CSG
  67572. * Coordinates here are in world space
  67573. * @param name The name of the mesh geometry
  67574. * @param scene The Scene
  67575. * @param keepSubMeshes Specifies if the submeshes should be kept
  67576. * @returns A new Mesh
  67577. */
  67578. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67579. /**
  67580. * Build Mesh from CSG taking material and transforms into account
  67581. * @param name The name of the Mesh
  67582. * @param material The material of the Mesh
  67583. * @param scene The Scene
  67584. * @param keepSubMeshes Specifies if submeshes should be kept
  67585. * @returns The new Mesh
  67586. */
  67587. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67588. }
  67589. }
  67590. declare module "babylonjs/Meshes/trailMesh" {
  67591. import { Mesh } from "babylonjs/Meshes/mesh";
  67592. import { Scene } from "babylonjs/scene";
  67593. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67594. /**
  67595. * Class used to create a trail following a mesh
  67596. */
  67597. export class TrailMesh extends Mesh {
  67598. private _generator;
  67599. private _autoStart;
  67600. private _running;
  67601. private _diameter;
  67602. private _length;
  67603. private _sectionPolygonPointsCount;
  67604. private _sectionVectors;
  67605. private _sectionNormalVectors;
  67606. private _beforeRenderObserver;
  67607. /**
  67608. * @constructor
  67609. * @param name The value used by scene.getMeshByName() to do a lookup.
  67610. * @param generator The mesh or transform node to generate a trail.
  67611. * @param scene The scene to add this mesh to.
  67612. * @param diameter Diameter of trailing mesh. Default is 1.
  67613. * @param length Length of trailing mesh. Default is 60.
  67614. * @param autoStart Automatically start trailing mesh. Default true.
  67615. */
  67616. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  67617. /**
  67618. * "TrailMesh"
  67619. * @returns "TrailMesh"
  67620. */
  67621. getClassName(): string;
  67622. private _createMesh;
  67623. /**
  67624. * Start trailing mesh.
  67625. */
  67626. start(): void;
  67627. /**
  67628. * Stop trailing mesh.
  67629. */
  67630. stop(): void;
  67631. /**
  67632. * Update trailing mesh geometry.
  67633. */
  67634. update(): void;
  67635. /**
  67636. * Returns a new TrailMesh object.
  67637. * @param name is a string, the name given to the new mesh
  67638. * @param newGenerator use new generator object for cloned trail mesh
  67639. * @returns a new mesh
  67640. */
  67641. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  67642. /**
  67643. * Serializes this trail mesh
  67644. * @param serializationObject object to write serialization to
  67645. */
  67646. serialize(serializationObject: any): void;
  67647. /**
  67648. * Parses a serialized trail mesh
  67649. * @param parsedMesh the serialized mesh
  67650. * @param scene the scene to create the trail mesh in
  67651. * @returns the created trail mesh
  67652. */
  67653. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  67654. }
  67655. }
  67656. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  67657. import { Nullable } from "babylonjs/types";
  67658. import { Scene } from "babylonjs/scene";
  67659. import { Vector4 } from "babylonjs/Maths/math.vector";
  67660. import { Color4 } from "babylonjs/Maths/math.color";
  67661. import { Mesh } from "babylonjs/Meshes/mesh";
  67662. /**
  67663. * Class containing static functions to help procedurally build meshes
  67664. */
  67665. export class TiledBoxBuilder {
  67666. /**
  67667. * Creates a box mesh
  67668. * 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)
  67669. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67671. * * 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
  67672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67673. * @param name defines the name of the mesh
  67674. * @param options defines the options used to create the mesh
  67675. * @param scene defines the hosting scene
  67676. * @returns the box mesh
  67677. */
  67678. static CreateTiledBox(name: string, options: {
  67679. pattern?: number;
  67680. width?: number;
  67681. height?: number;
  67682. depth?: number;
  67683. tileSize?: number;
  67684. tileWidth?: number;
  67685. tileHeight?: number;
  67686. alignHorizontal?: number;
  67687. alignVertical?: number;
  67688. faceUV?: Vector4[];
  67689. faceColors?: Color4[];
  67690. sideOrientation?: number;
  67691. updatable?: boolean;
  67692. }, scene?: Nullable<Scene>): Mesh;
  67693. }
  67694. }
  67695. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  67696. import { Vector4 } from "babylonjs/Maths/math.vector";
  67697. import { Mesh } from "babylonjs/Meshes/mesh";
  67698. /**
  67699. * Class containing static functions to help procedurally build meshes
  67700. */
  67701. export class TorusKnotBuilder {
  67702. /**
  67703. * Creates a torus knot mesh
  67704. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67705. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67706. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67707. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67709. * * 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
  67710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67711. * @param name defines the name of the mesh
  67712. * @param options defines the options used to create the mesh
  67713. * @param scene defines the hosting scene
  67714. * @returns the torus knot mesh
  67715. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67716. */
  67717. static CreateTorusKnot(name: string, options: {
  67718. radius?: number;
  67719. tube?: number;
  67720. radialSegments?: number;
  67721. tubularSegments?: number;
  67722. p?: number;
  67723. q?: number;
  67724. updatable?: boolean;
  67725. sideOrientation?: number;
  67726. frontUVs?: Vector4;
  67727. backUVs?: Vector4;
  67728. }, scene: any): Mesh;
  67729. }
  67730. }
  67731. declare module "babylonjs/Meshes/polygonMesh" {
  67732. import { Scene } from "babylonjs/scene";
  67733. import { Vector2 } from "babylonjs/Maths/math.vector";
  67734. import { Mesh } from "babylonjs/Meshes/mesh";
  67735. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67736. import { Path2 } from "babylonjs/Maths/math.path";
  67737. /**
  67738. * Polygon
  67739. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  67740. */
  67741. export class Polygon {
  67742. /**
  67743. * Creates a rectangle
  67744. * @param xmin bottom X coord
  67745. * @param ymin bottom Y coord
  67746. * @param xmax top X coord
  67747. * @param ymax top Y coord
  67748. * @returns points that make the resulting rectation
  67749. */
  67750. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67751. /**
  67752. * Creates a circle
  67753. * @param radius radius of circle
  67754. * @param cx scale in x
  67755. * @param cy scale in y
  67756. * @param numberOfSides number of sides that make up the circle
  67757. * @returns points that make the resulting circle
  67758. */
  67759. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67760. /**
  67761. * Creates a polygon from input string
  67762. * @param input Input polygon data
  67763. * @returns the parsed points
  67764. */
  67765. static Parse(input: string): Vector2[];
  67766. /**
  67767. * Starts building a polygon from x and y coordinates
  67768. * @param x x coordinate
  67769. * @param y y coordinate
  67770. * @returns the started path2
  67771. */
  67772. static StartingAt(x: number, y: number): Path2;
  67773. }
  67774. /**
  67775. * Builds a polygon
  67776. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67777. */
  67778. export class PolygonMeshBuilder {
  67779. private _points;
  67780. private _outlinepoints;
  67781. private _holes;
  67782. private _name;
  67783. private _scene;
  67784. private _epoints;
  67785. private _eholes;
  67786. private _addToepoint;
  67787. /**
  67788. * Babylon reference to the earcut plugin.
  67789. */
  67790. bjsEarcut: any;
  67791. /**
  67792. * Creates a PolygonMeshBuilder
  67793. * @param name name of the builder
  67794. * @param contours Path of the polygon
  67795. * @param scene scene to add to when creating the mesh
  67796. * @param earcutInjection can be used to inject your own earcut reference
  67797. */
  67798. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67799. /**
  67800. * Adds a whole within the polygon
  67801. * @param hole Array of points defining the hole
  67802. * @returns this
  67803. */
  67804. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67805. /**
  67806. * Creates the polygon
  67807. * @param updatable If the mesh should be updatable
  67808. * @param depth The depth of the mesh created
  67809. * @returns the created mesh
  67810. */
  67811. build(updatable?: boolean, depth?: number): Mesh;
  67812. /**
  67813. * Creates the polygon
  67814. * @param depth The depth of the mesh created
  67815. * @returns the created VertexData
  67816. */
  67817. buildVertexData(depth?: number): VertexData;
  67818. /**
  67819. * Adds a side to the polygon
  67820. * @param positions points that make the polygon
  67821. * @param normals normals of the polygon
  67822. * @param uvs uvs of the polygon
  67823. * @param indices indices of the polygon
  67824. * @param bounds bounds of the polygon
  67825. * @param points points of the polygon
  67826. * @param depth depth of the polygon
  67827. * @param flip flip of the polygon
  67828. */
  67829. private addSide;
  67830. }
  67831. }
  67832. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67833. import { Scene } from "babylonjs/scene";
  67834. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67835. import { Color4 } from "babylonjs/Maths/math.color";
  67836. import { Mesh } from "babylonjs/Meshes/mesh";
  67837. import { Nullable } from "babylonjs/types";
  67838. /**
  67839. * Class containing static functions to help procedurally build meshes
  67840. */
  67841. export class PolygonBuilder {
  67842. /**
  67843. * Creates a polygon mesh
  67844. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67845. * * 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
  67846. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67848. * * 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)
  67849. * * Remember you can only change the shape positions, not their number when updating a polygon
  67850. * @param name defines the name of the mesh
  67851. * @param options defines the options used to create the mesh
  67852. * @param scene defines the hosting scene
  67853. * @param earcutInjection can be used to inject your own earcut reference
  67854. * @returns the polygon mesh
  67855. */
  67856. static CreatePolygon(name: string, options: {
  67857. shape: Vector3[];
  67858. holes?: Vector3[][];
  67859. depth?: number;
  67860. faceUV?: Vector4[];
  67861. faceColors?: Color4[];
  67862. updatable?: boolean;
  67863. sideOrientation?: number;
  67864. frontUVs?: Vector4;
  67865. backUVs?: Vector4;
  67866. wrap?: boolean;
  67867. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67868. /**
  67869. * Creates an extruded polygon mesh, with depth in the Y direction.
  67870. * * 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)
  67871. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67872. * @param name defines the name of the mesh
  67873. * @param options defines the options used to create the mesh
  67874. * @param scene defines the hosting scene
  67875. * @param earcutInjection can be used to inject your own earcut reference
  67876. * @returns the polygon mesh
  67877. */
  67878. static ExtrudePolygon(name: string, options: {
  67879. shape: Vector3[];
  67880. holes?: Vector3[][];
  67881. depth?: number;
  67882. faceUV?: Vector4[];
  67883. faceColors?: Color4[];
  67884. updatable?: boolean;
  67885. sideOrientation?: number;
  67886. frontUVs?: Vector4;
  67887. backUVs?: Vector4;
  67888. wrap?: boolean;
  67889. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67890. }
  67891. }
  67892. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67893. import { Scene } from "babylonjs/scene";
  67894. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67895. import { Mesh } from "babylonjs/Meshes/mesh";
  67896. import { Nullable } from "babylonjs/types";
  67897. /**
  67898. * Class containing static functions to help procedurally build meshes
  67899. */
  67900. export class LatheBuilder {
  67901. /**
  67902. * Creates lathe mesh.
  67903. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67904. * * 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
  67905. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67906. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67907. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67908. * * 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
  67909. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67910. * * 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
  67911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67912. * * 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
  67913. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67915. * @param name defines the name of the mesh
  67916. * @param options defines the options used to create the mesh
  67917. * @param scene defines the hosting scene
  67918. * @returns the lathe mesh
  67919. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67920. */
  67921. static CreateLathe(name: string, options: {
  67922. shape: Vector3[];
  67923. radius?: number;
  67924. tessellation?: number;
  67925. clip?: number;
  67926. arc?: number;
  67927. closed?: boolean;
  67928. updatable?: boolean;
  67929. sideOrientation?: number;
  67930. frontUVs?: Vector4;
  67931. backUVs?: Vector4;
  67932. cap?: number;
  67933. invertUV?: boolean;
  67934. }, scene?: Nullable<Scene>): Mesh;
  67935. }
  67936. }
  67937. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67938. import { Nullable } from "babylonjs/types";
  67939. import { Scene } from "babylonjs/scene";
  67940. import { Vector4 } from "babylonjs/Maths/math.vector";
  67941. import { Mesh } from "babylonjs/Meshes/mesh";
  67942. /**
  67943. * Class containing static functions to help procedurally build meshes
  67944. */
  67945. export class TiledPlaneBuilder {
  67946. /**
  67947. * Creates a tiled plane mesh
  67948. * * The parameter `pattern` will, depending on value, do nothing or
  67949. * * * flip (reflect about central vertical) alternate tiles across and up
  67950. * * * flip every tile on alternate rows
  67951. * * * rotate (180 degs) alternate tiles across and up
  67952. * * * rotate every tile on alternate rows
  67953. * * * flip and rotate alternate tiles across and up
  67954. * * * flip and rotate every tile on alternate rows
  67955. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67956. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67957. * * 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
  67958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67959. * * 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)
  67960. * * 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)
  67961. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67962. * @param name defines the name of the mesh
  67963. * @param options defines the options used to create the mesh
  67964. * @param scene defines the hosting scene
  67965. * @returns the box mesh
  67966. */
  67967. static CreateTiledPlane(name: string, options: {
  67968. pattern?: number;
  67969. tileSize?: number;
  67970. tileWidth?: number;
  67971. tileHeight?: number;
  67972. size?: number;
  67973. width?: number;
  67974. height?: number;
  67975. alignHorizontal?: number;
  67976. alignVertical?: number;
  67977. sideOrientation?: number;
  67978. frontUVs?: Vector4;
  67979. backUVs?: Vector4;
  67980. updatable?: boolean;
  67981. }, scene?: Nullable<Scene>): Mesh;
  67982. }
  67983. }
  67984. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67985. import { Nullable } from "babylonjs/types";
  67986. import { Scene } from "babylonjs/scene";
  67987. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67988. import { Mesh } from "babylonjs/Meshes/mesh";
  67989. /**
  67990. * Class containing static functions to help procedurally build meshes
  67991. */
  67992. export class TubeBuilder {
  67993. /**
  67994. * Creates a tube mesh.
  67995. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67996. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67997. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67998. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67999. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68000. * * 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)
  68001. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68002. * * 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
  68003. * * 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
  68004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68005. * * 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
  68006. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68008. * @param name defines the name of the mesh
  68009. * @param options defines the options used to create the mesh
  68010. * @param scene defines the hosting scene
  68011. * @returns the tube mesh
  68012. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68013. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68014. */
  68015. static CreateTube(name: string, options: {
  68016. path: Vector3[];
  68017. radius?: number;
  68018. tessellation?: number;
  68019. radiusFunction?: {
  68020. (i: number, distance: number): number;
  68021. };
  68022. cap?: number;
  68023. arc?: number;
  68024. updatable?: boolean;
  68025. sideOrientation?: number;
  68026. frontUVs?: Vector4;
  68027. backUVs?: Vector4;
  68028. instance?: Mesh;
  68029. invertUV?: boolean;
  68030. }, scene?: Nullable<Scene>): Mesh;
  68031. }
  68032. }
  68033. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68034. import { Scene } from "babylonjs/scene";
  68035. import { Vector4 } from "babylonjs/Maths/math.vector";
  68036. import { Mesh } from "babylonjs/Meshes/mesh";
  68037. import { Nullable } from "babylonjs/types";
  68038. /**
  68039. * Class containing static functions to help procedurally build meshes
  68040. */
  68041. export class IcoSphereBuilder {
  68042. /**
  68043. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68044. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68045. * * 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`)
  68046. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68047. * * 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
  68048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68049. * * 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
  68050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68051. * @param name defines the name of the mesh
  68052. * @param options defines the options used to create the mesh
  68053. * @param scene defines the hosting scene
  68054. * @returns the icosahedron mesh
  68055. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68056. */
  68057. static CreateIcoSphere(name: string, options: {
  68058. radius?: number;
  68059. radiusX?: number;
  68060. radiusY?: number;
  68061. radiusZ?: number;
  68062. flat?: boolean;
  68063. subdivisions?: number;
  68064. sideOrientation?: number;
  68065. frontUVs?: Vector4;
  68066. backUVs?: Vector4;
  68067. updatable?: boolean;
  68068. }, scene?: Nullable<Scene>): Mesh;
  68069. }
  68070. }
  68071. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68072. import { Vector3 } from "babylonjs/Maths/math.vector";
  68073. import { Mesh } from "babylonjs/Meshes/mesh";
  68074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68075. /**
  68076. * Class containing static functions to help procedurally build meshes
  68077. */
  68078. export class DecalBuilder {
  68079. /**
  68080. * Creates a decal mesh.
  68081. * 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
  68082. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68083. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68084. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68085. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68086. * @param name defines the name of the mesh
  68087. * @param sourceMesh defines the mesh where the decal must be applied
  68088. * @param options defines the options used to create the mesh
  68089. * @param scene defines the hosting scene
  68090. * @returns the decal mesh
  68091. * @see https://doc.babylonjs.com/how_to/decals
  68092. */
  68093. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68094. position?: Vector3;
  68095. normal?: Vector3;
  68096. size?: Vector3;
  68097. angle?: number;
  68098. }): Mesh;
  68099. }
  68100. }
  68101. declare module "babylonjs/Meshes/meshBuilder" {
  68102. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68103. import { Nullable } from "babylonjs/types";
  68104. import { Scene } from "babylonjs/scene";
  68105. import { Mesh } from "babylonjs/Meshes/mesh";
  68106. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68107. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68109. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68110. import { Plane } from "babylonjs/Maths/math.plane";
  68111. /**
  68112. * Class containing static functions to help procedurally build meshes
  68113. */
  68114. export class MeshBuilder {
  68115. /**
  68116. * Creates a box mesh
  68117. * * The parameter `size` sets the size (float) of each box side (default 1)
  68118. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68119. * * 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)
  68120. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68122. * * 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
  68123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68124. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68125. * @param name defines the name of the mesh
  68126. * @param options defines the options used to create the mesh
  68127. * @param scene defines the hosting scene
  68128. * @returns the box mesh
  68129. */
  68130. static CreateBox(name: string, options: {
  68131. size?: number;
  68132. width?: number;
  68133. height?: number;
  68134. depth?: number;
  68135. faceUV?: Vector4[];
  68136. faceColors?: Color4[];
  68137. sideOrientation?: number;
  68138. frontUVs?: Vector4;
  68139. backUVs?: Vector4;
  68140. wrap?: boolean;
  68141. topBaseAt?: number;
  68142. bottomBaseAt?: number;
  68143. updatable?: boolean;
  68144. }, scene?: Nullable<Scene>): Mesh;
  68145. /**
  68146. * Creates a tiled box mesh
  68147. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68149. * @param name defines the name of the mesh
  68150. * @param options defines the options used to create the mesh
  68151. * @param scene defines the hosting scene
  68152. * @returns the tiled box mesh
  68153. */
  68154. static CreateTiledBox(name: string, options: {
  68155. pattern?: number;
  68156. size?: number;
  68157. width?: number;
  68158. height?: number;
  68159. depth: number;
  68160. tileSize?: number;
  68161. tileWidth?: number;
  68162. tileHeight?: number;
  68163. faceUV?: Vector4[];
  68164. faceColors?: Color4[];
  68165. alignHorizontal?: number;
  68166. alignVertical?: number;
  68167. sideOrientation?: number;
  68168. updatable?: boolean;
  68169. }, scene?: Nullable<Scene>): Mesh;
  68170. /**
  68171. * Creates a sphere mesh
  68172. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68173. * * 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`)
  68174. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68175. * * 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
  68176. * * 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)
  68177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68178. * * 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
  68179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68180. * @param name defines the name of the mesh
  68181. * @param options defines the options used to create the mesh
  68182. * @param scene defines the hosting scene
  68183. * @returns the sphere mesh
  68184. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68185. */
  68186. static CreateSphere(name: string, options: {
  68187. segments?: number;
  68188. diameter?: number;
  68189. diameterX?: number;
  68190. diameterY?: number;
  68191. diameterZ?: number;
  68192. arc?: number;
  68193. slice?: number;
  68194. sideOrientation?: number;
  68195. frontUVs?: Vector4;
  68196. backUVs?: Vector4;
  68197. updatable?: boolean;
  68198. }, scene?: Nullable<Scene>): Mesh;
  68199. /**
  68200. * Creates a plane polygonal mesh. By default, this is a disc
  68201. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68202. * * 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
  68203. * * 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
  68204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68205. * * 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
  68206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68207. * @param name defines the name of the mesh
  68208. * @param options defines the options used to create the mesh
  68209. * @param scene defines the hosting scene
  68210. * @returns the plane polygonal mesh
  68211. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68212. */
  68213. static CreateDisc(name: string, options: {
  68214. radius?: number;
  68215. tessellation?: number;
  68216. arc?: number;
  68217. updatable?: boolean;
  68218. sideOrientation?: number;
  68219. frontUVs?: Vector4;
  68220. backUVs?: Vector4;
  68221. }, scene?: Nullable<Scene>): Mesh;
  68222. /**
  68223. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68224. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68225. * * 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`)
  68226. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68227. * * 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
  68228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68229. * * 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
  68230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68231. * @param name defines the name of the mesh
  68232. * @param options defines the options used to create the mesh
  68233. * @param scene defines the hosting scene
  68234. * @returns the icosahedron mesh
  68235. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68236. */
  68237. static CreateIcoSphere(name: string, options: {
  68238. radius?: number;
  68239. radiusX?: number;
  68240. radiusY?: number;
  68241. radiusZ?: number;
  68242. flat?: boolean;
  68243. subdivisions?: number;
  68244. sideOrientation?: number;
  68245. frontUVs?: Vector4;
  68246. backUVs?: Vector4;
  68247. updatable?: boolean;
  68248. }, scene?: Nullable<Scene>): Mesh;
  68249. /**
  68250. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68251. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68252. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68253. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68254. * * 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
  68255. * * 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
  68256. * * 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
  68257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68258. * * 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
  68259. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68260. * * 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
  68261. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68262. * * 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
  68263. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68265. * @param name defines the name of the mesh
  68266. * @param options defines the options used to create the mesh
  68267. * @param scene defines the hosting scene
  68268. * @returns the ribbon mesh
  68269. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68270. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68271. */
  68272. static CreateRibbon(name: string, options: {
  68273. pathArray: Vector3[][];
  68274. closeArray?: boolean;
  68275. closePath?: boolean;
  68276. offset?: number;
  68277. updatable?: boolean;
  68278. sideOrientation?: number;
  68279. frontUVs?: Vector4;
  68280. backUVs?: Vector4;
  68281. instance?: Mesh;
  68282. invertUV?: boolean;
  68283. uvs?: Vector2[];
  68284. colors?: Color4[];
  68285. }, scene?: Nullable<Scene>): Mesh;
  68286. /**
  68287. * Creates a cylinder or a cone mesh
  68288. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68289. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68290. * * 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.
  68291. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68292. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68293. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68294. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68295. * * 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).
  68296. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68297. * * 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).
  68298. * * 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
  68299. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68300. * * 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
  68301. * * 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.
  68302. * * If `enclose` is false, a ring surface is one element.
  68303. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68304. * * 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
  68305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68306. * * 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
  68307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68308. * @param name defines the name of the mesh
  68309. * @param options defines the options used to create the mesh
  68310. * @param scene defines the hosting scene
  68311. * @returns the cylinder mesh
  68312. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68313. */
  68314. static CreateCylinder(name: string, options: {
  68315. height?: number;
  68316. diameterTop?: number;
  68317. diameterBottom?: number;
  68318. diameter?: number;
  68319. tessellation?: number;
  68320. subdivisions?: number;
  68321. arc?: number;
  68322. faceColors?: Color4[];
  68323. faceUV?: Vector4[];
  68324. updatable?: boolean;
  68325. hasRings?: boolean;
  68326. enclose?: boolean;
  68327. cap?: number;
  68328. sideOrientation?: number;
  68329. frontUVs?: Vector4;
  68330. backUVs?: Vector4;
  68331. }, scene?: Nullable<Scene>): Mesh;
  68332. /**
  68333. * Creates a torus mesh
  68334. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68335. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68336. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68338. * * 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
  68339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68340. * @param name defines the name of the mesh
  68341. * @param options defines the options used to create the mesh
  68342. * @param scene defines the hosting scene
  68343. * @returns the torus mesh
  68344. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68345. */
  68346. static CreateTorus(name: string, options: {
  68347. diameter?: number;
  68348. thickness?: number;
  68349. tessellation?: number;
  68350. updatable?: boolean;
  68351. sideOrientation?: number;
  68352. frontUVs?: Vector4;
  68353. backUVs?: Vector4;
  68354. }, scene?: Nullable<Scene>): Mesh;
  68355. /**
  68356. * Creates a torus knot mesh
  68357. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68358. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68359. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68360. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68362. * * 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
  68363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68364. * @param name defines the name of the mesh
  68365. * @param options defines the options used to create the mesh
  68366. * @param scene defines the hosting scene
  68367. * @returns the torus knot mesh
  68368. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68369. */
  68370. static CreateTorusKnot(name: string, options: {
  68371. radius?: number;
  68372. tube?: number;
  68373. radialSegments?: number;
  68374. tubularSegments?: number;
  68375. p?: number;
  68376. q?: number;
  68377. updatable?: boolean;
  68378. sideOrientation?: number;
  68379. frontUVs?: Vector4;
  68380. backUVs?: Vector4;
  68381. }, scene?: Nullable<Scene>): Mesh;
  68382. /**
  68383. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  68384. * * 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
  68385. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  68386. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  68387. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  68388. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  68389. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  68390. * * 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
  68391. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  68392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68393. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  68394. * @param name defines the name of the new line system
  68395. * @param options defines the options used to create the line system
  68396. * @param scene defines the hosting scene
  68397. * @returns a new line system mesh
  68398. */
  68399. static CreateLineSystem(name: string, options: {
  68400. lines: Vector3[][];
  68401. updatable?: boolean;
  68402. instance?: Nullable<LinesMesh>;
  68403. colors?: Nullable<Color4[][]>;
  68404. useVertexAlpha?: boolean;
  68405. }, scene: Nullable<Scene>): LinesMesh;
  68406. /**
  68407. * Creates a line mesh
  68408. * 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
  68409. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68410. * * The parameter `points` is an array successive Vector3
  68411. * * 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
  68412. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68413. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68414. * * When updating an instance, remember that only point positions can change, not the number of points
  68415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68417. * @param name defines the name of the new line system
  68418. * @param options defines the options used to create the line system
  68419. * @param scene defines the hosting scene
  68420. * @returns a new line mesh
  68421. */
  68422. static CreateLines(name: string, options: {
  68423. points: Vector3[];
  68424. updatable?: boolean;
  68425. instance?: Nullable<LinesMesh>;
  68426. colors?: Color4[];
  68427. useVertexAlpha?: boolean;
  68428. }, scene?: Nullable<Scene>): LinesMesh;
  68429. /**
  68430. * Creates a dashed line mesh
  68431. * * 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
  68432. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68433. * * The parameter `points` is an array successive Vector3
  68434. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68435. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68436. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68437. * * 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
  68438. * * When updating an instance, remember that only point positions can change, not the number of points
  68439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68440. * @param name defines the name of the mesh
  68441. * @param options defines the options used to create the mesh
  68442. * @param scene defines the hosting scene
  68443. * @returns the dashed line mesh
  68444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  68445. */
  68446. static CreateDashedLines(name: string, options: {
  68447. points: Vector3[];
  68448. dashSize?: number;
  68449. gapSize?: number;
  68450. dashNb?: number;
  68451. updatable?: boolean;
  68452. instance?: LinesMesh;
  68453. }, scene?: Nullable<Scene>): LinesMesh;
  68454. /**
  68455. * 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.
  68456. * * 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.
  68457. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68458. * * 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.
  68459. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  68460. * * 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
  68461. * * 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
  68462. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  68463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68464. * * 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
  68465. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  68466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68467. * @param name defines the name of the mesh
  68468. * @param options defines the options used to create the mesh
  68469. * @param scene defines the hosting scene
  68470. * @returns the extruded shape mesh
  68471. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68473. */
  68474. static ExtrudeShape(name: string, options: {
  68475. shape: Vector3[];
  68476. path: Vector3[];
  68477. scale?: number;
  68478. rotation?: number;
  68479. cap?: number;
  68480. updatable?: boolean;
  68481. sideOrientation?: number;
  68482. frontUVs?: Vector4;
  68483. backUVs?: Vector4;
  68484. instance?: Mesh;
  68485. invertUV?: boolean;
  68486. }, scene?: Nullable<Scene>): Mesh;
  68487. /**
  68488. * Creates an custom extruded shape mesh.
  68489. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  68490. * * 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.
  68491. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68492. * * 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
  68493. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  68494. * * 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
  68495. * * It must returns a float value that will be the scale value applied to the shape on each path point
  68496. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  68497. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  68498. * * 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
  68499. * * 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
  68500. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  68501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68502. * * 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
  68503. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68505. * @param name defines the name of the mesh
  68506. * @param options defines the options used to create the mesh
  68507. * @param scene defines the hosting scene
  68508. * @returns the custom extruded shape mesh
  68509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  68510. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68511. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68512. */
  68513. static ExtrudeShapeCustom(name: string, options: {
  68514. shape: Vector3[];
  68515. path: Vector3[];
  68516. scaleFunction?: any;
  68517. rotationFunction?: any;
  68518. ribbonCloseArray?: boolean;
  68519. ribbonClosePath?: boolean;
  68520. cap?: number;
  68521. updatable?: boolean;
  68522. sideOrientation?: number;
  68523. frontUVs?: Vector4;
  68524. backUVs?: Vector4;
  68525. instance?: Mesh;
  68526. invertUV?: boolean;
  68527. }, scene?: Nullable<Scene>): Mesh;
  68528. /**
  68529. * Creates lathe mesh.
  68530. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68531. * * 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
  68532. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68533. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68534. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68535. * * 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
  68536. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68537. * * 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
  68538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68539. * * 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
  68540. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68542. * @param name defines the name of the mesh
  68543. * @param options defines the options used to create the mesh
  68544. * @param scene defines the hosting scene
  68545. * @returns the lathe mesh
  68546. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68547. */
  68548. static CreateLathe(name: string, options: {
  68549. shape: Vector3[];
  68550. radius?: number;
  68551. tessellation?: number;
  68552. clip?: number;
  68553. arc?: number;
  68554. closed?: boolean;
  68555. updatable?: boolean;
  68556. sideOrientation?: number;
  68557. frontUVs?: Vector4;
  68558. backUVs?: Vector4;
  68559. cap?: number;
  68560. invertUV?: boolean;
  68561. }, scene?: Nullable<Scene>): Mesh;
  68562. /**
  68563. * Creates a tiled plane mesh
  68564. * * You can set a limited pattern arrangement with the tiles
  68565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68566. * * 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
  68567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68568. * @param name defines the name of the mesh
  68569. * @param options defines the options used to create the mesh
  68570. * @param scene defines the hosting scene
  68571. * @returns the plane mesh
  68572. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68573. */
  68574. static CreateTiledPlane(name: string, options: {
  68575. pattern?: number;
  68576. tileSize?: number;
  68577. tileWidth?: number;
  68578. tileHeight?: number;
  68579. size?: number;
  68580. width?: number;
  68581. height?: number;
  68582. alignHorizontal?: number;
  68583. alignVertical?: number;
  68584. sideOrientation?: number;
  68585. frontUVs?: Vector4;
  68586. backUVs?: Vector4;
  68587. updatable?: boolean;
  68588. }, scene?: Nullable<Scene>): Mesh;
  68589. /**
  68590. * Creates a plane mesh
  68591. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  68592. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  68593. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  68594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68595. * * 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
  68596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68597. * @param name defines the name of the mesh
  68598. * @param options defines the options used to create the mesh
  68599. * @param scene defines the hosting scene
  68600. * @returns the plane mesh
  68601. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68602. */
  68603. static CreatePlane(name: string, options: {
  68604. size?: number;
  68605. width?: number;
  68606. height?: number;
  68607. sideOrientation?: number;
  68608. frontUVs?: Vector4;
  68609. backUVs?: Vector4;
  68610. updatable?: boolean;
  68611. sourcePlane?: Plane;
  68612. }, scene?: Nullable<Scene>): Mesh;
  68613. /**
  68614. * Creates a ground mesh
  68615. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  68616. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  68617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68618. * @param name defines the name of the mesh
  68619. * @param options defines the options used to create the mesh
  68620. * @param scene defines the hosting scene
  68621. * @returns the ground mesh
  68622. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  68623. */
  68624. static CreateGround(name: string, options: {
  68625. width?: number;
  68626. height?: number;
  68627. subdivisions?: number;
  68628. subdivisionsX?: number;
  68629. subdivisionsY?: number;
  68630. updatable?: boolean;
  68631. }, scene?: Nullable<Scene>): Mesh;
  68632. /**
  68633. * Creates a tiled ground mesh
  68634. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  68635. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  68636. * * 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
  68637. * * 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
  68638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68639. * @param name defines the name of the mesh
  68640. * @param options defines the options used to create the mesh
  68641. * @param scene defines the hosting scene
  68642. * @returns the tiled ground mesh
  68643. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  68644. */
  68645. static CreateTiledGround(name: string, options: {
  68646. xmin: number;
  68647. zmin: number;
  68648. xmax: number;
  68649. zmax: number;
  68650. subdivisions?: {
  68651. w: number;
  68652. h: number;
  68653. };
  68654. precision?: {
  68655. w: number;
  68656. h: number;
  68657. };
  68658. updatable?: boolean;
  68659. }, scene?: Nullable<Scene>): Mesh;
  68660. /**
  68661. * Creates a ground mesh from a height map
  68662. * * The parameter `url` sets the URL of the height map image resource.
  68663. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  68664. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  68665. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  68666. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  68667. * * 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.
  68668. * * 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).
  68669. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  68670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68671. * @param name defines the name of the mesh
  68672. * @param url defines the url to the height map
  68673. * @param options defines the options used to create the mesh
  68674. * @param scene defines the hosting scene
  68675. * @returns the ground mesh
  68676. * @see https://doc.babylonjs.com/babylon101/height_map
  68677. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  68678. */
  68679. static CreateGroundFromHeightMap(name: string, url: string, options: {
  68680. width?: number;
  68681. height?: number;
  68682. subdivisions?: number;
  68683. minHeight?: number;
  68684. maxHeight?: number;
  68685. colorFilter?: Color3;
  68686. alphaFilter?: number;
  68687. updatable?: boolean;
  68688. onReady?: (mesh: GroundMesh) => void;
  68689. }, scene?: Nullable<Scene>): GroundMesh;
  68690. /**
  68691. * Creates a polygon mesh
  68692. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68693. * * 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
  68694. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68696. * * 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)
  68697. * * Remember you can only change the shape positions, not their number when updating a polygon
  68698. * @param name defines the name of the mesh
  68699. * @param options defines the options used to create the mesh
  68700. * @param scene defines the hosting scene
  68701. * @param earcutInjection can be used to inject your own earcut reference
  68702. * @returns the polygon mesh
  68703. */
  68704. static CreatePolygon(name: string, options: {
  68705. shape: Vector3[];
  68706. holes?: Vector3[][];
  68707. depth?: number;
  68708. faceUV?: Vector4[];
  68709. faceColors?: Color4[];
  68710. updatable?: boolean;
  68711. sideOrientation?: number;
  68712. frontUVs?: Vector4;
  68713. backUVs?: Vector4;
  68714. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68715. /**
  68716. * Creates an extruded polygon mesh, with depth in the Y direction.
  68717. * * 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)
  68718. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68719. * @param name defines the name of the mesh
  68720. * @param options defines the options used to create the mesh
  68721. * @param scene defines the hosting scene
  68722. * @param earcutInjection can be used to inject your own earcut reference
  68723. * @returns the polygon mesh
  68724. */
  68725. static ExtrudePolygon(name: string, options: {
  68726. shape: Vector3[];
  68727. holes?: Vector3[][];
  68728. depth?: number;
  68729. faceUV?: Vector4[];
  68730. faceColors?: Color4[];
  68731. updatable?: boolean;
  68732. sideOrientation?: number;
  68733. frontUVs?: Vector4;
  68734. backUVs?: Vector4;
  68735. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68736. /**
  68737. * Creates a tube mesh.
  68738. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68739. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68740. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68741. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68742. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68743. * * 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)
  68744. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68745. * * 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
  68746. * * 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
  68747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68748. * * 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
  68749. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68751. * @param name defines the name of the mesh
  68752. * @param options defines the options used to create the mesh
  68753. * @param scene defines the hosting scene
  68754. * @returns the tube mesh
  68755. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68756. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68757. */
  68758. static CreateTube(name: string, options: {
  68759. path: Vector3[];
  68760. radius?: number;
  68761. tessellation?: number;
  68762. radiusFunction?: {
  68763. (i: number, distance: number): number;
  68764. };
  68765. cap?: number;
  68766. arc?: number;
  68767. updatable?: boolean;
  68768. sideOrientation?: number;
  68769. frontUVs?: Vector4;
  68770. backUVs?: Vector4;
  68771. instance?: Mesh;
  68772. invertUV?: boolean;
  68773. }, scene?: Nullable<Scene>): Mesh;
  68774. /**
  68775. * Creates a polyhedron mesh
  68776. * * 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
  68777. * * The parameter `size` (positive float, default 1) sets the polygon size
  68778. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68779. * * 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`
  68780. * * 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
  68781. * * 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)`)
  68782. * * 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
  68783. * * 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
  68784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68785. * * 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
  68786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68787. * @param name defines the name of the mesh
  68788. * @param options defines the options used to create the mesh
  68789. * @param scene defines the hosting scene
  68790. * @returns the polyhedron mesh
  68791. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68792. */
  68793. static CreatePolyhedron(name: string, options: {
  68794. type?: number;
  68795. size?: number;
  68796. sizeX?: number;
  68797. sizeY?: number;
  68798. sizeZ?: number;
  68799. custom?: any;
  68800. faceUV?: Vector4[];
  68801. faceColors?: Color4[];
  68802. flat?: boolean;
  68803. updatable?: boolean;
  68804. sideOrientation?: number;
  68805. frontUVs?: Vector4;
  68806. backUVs?: Vector4;
  68807. }, scene?: Nullable<Scene>): Mesh;
  68808. /**
  68809. * Creates a decal mesh.
  68810. * 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
  68811. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68812. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68813. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68814. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68815. * @param name defines the name of the mesh
  68816. * @param sourceMesh defines the mesh where the decal must be applied
  68817. * @param options defines the options used to create the mesh
  68818. * @param scene defines the hosting scene
  68819. * @returns the decal mesh
  68820. * @see https://doc.babylonjs.com/how_to/decals
  68821. */
  68822. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68823. position?: Vector3;
  68824. normal?: Vector3;
  68825. size?: Vector3;
  68826. angle?: number;
  68827. }): Mesh;
  68828. }
  68829. }
  68830. declare module "babylonjs/Meshes/meshSimplification" {
  68831. import { Mesh } from "babylonjs/Meshes/mesh";
  68832. /**
  68833. * A simplifier interface for future simplification implementations
  68834. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68835. */
  68836. export interface ISimplifier {
  68837. /**
  68838. * Simplification of a given mesh according to the given settings.
  68839. * Since this requires computation, it is assumed that the function runs async.
  68840. * @param settings The settings of the simplification, including quality and distance
  68841. * @param successCallback A callback that will be called after the mesh was simplified.
  68842. * @param errorCallback in case of an error, this callback will be called. optional.
  68843. */
  68844. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68845. }
  68846. /**
  68847. * Expected simplification settings.
  68848. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68849. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68850. */
  68851. export interface ISimplificationSettings {
  68852. /**
  68853. * Gets or sets the expected quality
  68854. */
  68855. quality: number;
  68856. /**
  68857. * Gets or sets the distance when this optimized version should be used
  68858. */
  68859. distance: number;
  68860. /**
  68861. * Gets an already optimized mesh
  68862. */
  68863. optimizeMesh?: boolean;
  68864. }
  68865. /**
  68866. * Class used to specify simplification options
  68867. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68868. */
  68869. export class SimplificationSettings implements ISimplificationSettings {
  68870. /** expected quality */
  68871. quality: number;
  68872. /** distance when this optimized version should be used */
  68873. distance: number;
  68874. /** already optimized mesh */
  68875. optimizeMesh?: boolean | undefined;
  68876. /**
  68877. * Creates a SimplificationSettings
  68878. * @param quality expected quality
  68879. * @param distance distance when this optimized version should be used
  68880. * @param optimizeMesh already optimized mesh
  68881. */
  68882. constructor(
  68883. /** expected quality */
  68884. quality: number,
  68885. /** distance when this optimized version should be used */
  68886. distance: number,
  68887. /** already optimized mesh */
  68888. optimizeMesh?: boolean | undefined);
  68889. }
  68890. /**
  68891. * Interface used to define a simplification task
  68892. */
  68893. export interface ISimplificationTask {
  68894. /**
  68895. * Array of settings
  68896. */
  68897. settings: Array<ISimplificationSettings>;
  68898. /**
  68899. * Simplification type
  68900. */
  68901. simplificationType: SimplificationType;
  68902. /**
  68903. * Mesh to simplify
  68904. */
  68905. mesh: Mesh;
  68906. /**
  68907. * Callback called on success
  68908. */
  68909. successCallback?: () => void;
  68910. /**
  68911. * Defines if parallel processing can be used
  68912. */
  68913. parallelProcessing: boolean;
  68914. }
  68915. /**
  68916. * Queue used to order the simplification tasks
  68917. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68918. */
  68919. export class SimplificationQueue {
  68920. private _simplificationArray;
  68921. /**
  68922. * Gets a boolean indicating that the process is still running
  68923. */
  68924. running: boolean;
  68925. /**
  68926. * Creates a new queue
  68927. */
  68928. constructor();
  68929. /**
  68930. * Adds a new simplification task
  68931. * @param task defines a task to add
  68932. */
  68933. addTask(task: ISimplificationTask): void;
  68934. /**
  68935. * Execute next task
  68936. */
  68937. executeNext(): void;
  68938. /**
  68939. * Execute a simplification task
  68940. * @param task defines the task to run
  68941. */
  68942. runSimplification(task: ISimplificationTask): void;
  68943. private getSimplifier;
  68944. }
  68945. /**
  68946. * The implemented types of simplification
  68947. * At the moment only Quadratic Error Decimation is implemented
  68948. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68949. */
  68950. export enum SimplificationType {
  68951. /** Quadratic error decimation */
  68952. QUADRATIC = 0
  68953. }
  68954. /**
  68955. * An implementation of the Quadratic Error simplification algorithm.
  68956. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68957. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68958. * @author RaananW
  68959. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68960. */
  68961. export class QuadraticErrorSimplification implements ISimplifier {
  68962. private _mesh;
  68963. private triangles;
  68964. private vertices;
  68965. private references;
  68966. private _reconstructedMesh;
  68967. /** Gets or sets the number pf sync interations */
  68968. syncIterations: number;
  68969. /** Gets or sets the aggressiveness of the simplifier */
  68970. aggressiveness: number;
  68971. /** Gets or sets the number of allowed iterations for decimation */
  68972. decimationIterations: number;
  68973. /** Gets or sets the espilon to use for bounding box computation */
  68974. boundingBoxEpsilon: number;
  68975. /**
  68976. * Creates a new QuadraticErrorSimplification
  68977. * @param _mesh defines the target mesh
  68978. */
  68979. constructor(_mesh: Mesh);
  68980. /**
  68981. * Simplification of a given mesh according to the given settings.
  68982. * Since this requires computation, it is assumed that the function runs async.
  68983. * @param settings The settings of the simplification, including quality and distance
  68984. * @param successCallback A callback that will be called after the mesh was simplified.
  68985. */
  68986. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68987. private runDecimation;
  68988. private initWithMesh;
  68989. private init;
  68990. private reconstructMesh;
  68991. private initDecimatedMesh;
  68992. private isFlipped;
  68993. private updateTriangles;
  68994. private identifyBorder;
  68995. private updateMesh;
  68996. private vertexError;
  68997. private calculateError;
  68998. }
  68999. }
  69000. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69001. import { Scene } from "babylonjs/scene";
  69002. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69003. import { ISceneComponent } from "babylonjs/sceneComponent";
  69004. module "babylonjs/scene" {
  69005. interface Scene {
  69006. /** @hidden (Backing field) */
  69007. _simplificationQueue: SimplificationQueue;
  69008. /**
  69009. * Gets or sets the simplification queue attached to the scene
  69010. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69011. */
  69012. simplificationQueue: SimplificationQueue;
  69013. }
  69014. }
  69015. module "babylonjs/Meshes/mesh" {
  69016. interface Mesh {
  69017. /**
  69018. * Simplify the mesh according to the given array of settings.
  69019. * Function will return immediately and will simplify async
  69020. * @param settings a collection of simplification settings
  69021. * @param parallelProcessing should all levels calculate parallel or one after the other
  69022. * @param simplificationType the type of simplification to run
  69023. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69024. * @returns the current mesh
  69025. */
  69026. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69027. }
  69028. }
  69029. /**
  69030. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69031. * created in a scene
  69032. */
  69033. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69034. /**
  69035. * The component name helpfull to identify the component in the list of scene components.
  69036. */
  69037. readonly name: string;
  69038. /**
  69039. * The scene the component belongs to.
  69040. */
  69041. scene: Scene;
  69042. /**
  69043. * Creates a new instance of the component for the given scene
  69044. * @param scene Defines the scene to register the component in
  69045. */
  69046. constructor(scene: Scene);
  69047. /**
  69048. * Registers the component in a given scene
  69049. */
  69050. register(): void;
  69051. /**
  69052. * Rebuilds the elements related to this component in case of
  69053. * context lost for instance.
  69054. */
  69055. rebuild(): void;
  69056. /**
  69057. * Disposes the component and the associated ressources
  69058. */
  69059. dispose(): void;
  69060. private _beforeCameraUpdate;
  69061. }
  69062. }
  69063. declare module "babylonjs/Meshes/Builders/index" {
  69064. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69065. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69066. export * from "babylonjs/Meshes/Builders/discBuilder";
  69067. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69068. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69069. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69070. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69071. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69072. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69073. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69074. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69075. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69076. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69077. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69078. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69079. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69080. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69081. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69082. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69083. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69084. }
  69085. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69086. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69087. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69088. import { Matrix } from "babylonjs/Maths/math.vector";
  69089. module "babylonjs/Meshes/mesh" {
  69090. interface Mesh {
  69091. /**
  69092. * Creates a new thin instance
  69093. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69094. * @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
  69095. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69096. */
  69097. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69098. /**
  69099. * Adds the transformation (matrix) of the current mesh as a thin instance
  69100. * @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
  69101. * @returns the thin instance index number
  69102. */
  69103. thinInstanceAddSelf(refresh: boolean): number;
  69104. /**
  69105. * Registers a custom attribute to be used with thin instances
  69106. * @param kind name of the attribute
  69107. * @param stride size in floats of the attribute
  69108. */
  69109. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69110. /**
  69111. * Sets the matrix of a thin instance
  69112. * @param index index of the thin instance
  69113. * @param matrix matrix to set
  69114. * @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
  69115. */
  69116. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69117. /**
  69118. * Sets the value of a custom attribute for a thin instance
  69119. * @param kind name of the attribute
  69120. * @param index index of the thin instance
  69121. * @param value value to set
  69122. * @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
  69123. */
  69124. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69125. /**
  69126. * 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.
  69127. */
  69128. thinInstanceCount: number;
  69129. /**
  69130. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69131. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69132. * @param buffer buffer to set
  69133. * @param stride size in floats of each value of the buffer
  69134. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69135. */
  69136. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69137. /**
  69138. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69139. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69140. */
  69141. thinInstanceBufferUpdated(kind: string): void;
  69142. /**
  69143. * Refreshes the bounding info, taking into account all the thin instances defined
  69144. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69145. */
  69146. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69147. /** @hidden */
  69148. _thinInstanceInitializeUserStorage(): void;
  69149. /** @hidden */
  69150. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69151. /** @hidden */
  69152. _userThinInstanceBuffersStorage: {
  69153. data: {
  69154. [key: string]: Float32Array;
  69155. };
  69156. sizes: {
  69157. [key: string]: number;
  69158. };
  69159. vertexBuffers: {
  69160. [key: string]: Nullable<VertexBuffer>;
  69161. };
  69162. strides: {
  69163. [key: string]: number;
  69164. };
  69165. };
  69166. }
  69167. }
  69168. }
  69169. declare module "babylonjs/Meshes/index" {
  69170. export * from "babylonjs/Meshes/abstractMesh";
  69171. export * from "babylonjs/Meshes/buffer";
  69172. export * from "babylonjs/Meshes/Compression/index";
  69173. export * from "babylonjs/Meshes/csg";
  69174. export * from "babylonjs/Meshes/geometry";
  69175. export * from "babylonjs/Meshes/groundMesh";
  69176. export * from "babylonjs/Meshes/trailMesh";
  69177. export * from "babylonjs/Meshes/instancedMesh";
  69178. export * from "babylonjs/Meshes/linesMesh";
  69179. export * from "babylonjs/Meshes/mesh";
  69180. export * from "babylonjs/Meshes/mesh.vertexData";
  69181. export * from "babylonjs/Meshes/meshBuilder";
  69182. export * from "babylonjs/Meshes/meshSimplification";
  69183. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69184. export * from "babylonjs/Meshes/polygonMesh";
  69185. export * from "babylonjs/Meshes/subMesh";
  69186. export * from "babylonjs/Meshes/meshLODLevel";
  69187. export * from "babylonjs/Meshes/transformNode";
  69188. export * from "babylonjs/Meshes/Builders/index";
  69189. export * from "babylonjs/Meshes/dataBuffer";
  69190. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69191. import "babylonjs/Meshes/thinInstanceMesh";
  69192. export * from "babylonjs/Meshes/thinInstanceMesh";
  69193. }
  69194. declare module "babylonjs/Morph/index" {
  69195. export * from "babylonjs/Morph/morphTarget";
  69196. export * from "babylonjs/Morph/morphTargetManager";
  69197. }
  69198. declare module "babylonjs/Navigation/INavigationEngine" {
  69199. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69200. import { Vector3 } from "babylonjs/Maths/math";
  69201. import { Mesh } from "babylonjs/Meshes/mesh";
  69202. import { Scene } from "babylonjs/scene";
  69203. /**
  69204. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69205. */
  69206. export interface INavigationEnginePlugin {
  69207. /**
  69208. * plugin name
  69209. */
  69210. name: string;
  69211. /**
  69212. * Creates a navigation mesh
  69213. * @param meshes array of all the geometry used to compute the navigatio mesh
  69214. * @param parameters bunch of parameters used to filter geometry
  69215. */
  69216. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69217. /**
  69218. * Create a navigation mesh debug mesh
  69219. * @param scene is where the mesh will be added
  69220. * @returns debug display mesh
  69221. */
  69222. createDebugNavMesh(scene: Scene): Mesh;
  69223. /**
  69224. * Get a navigation mesh constrained position, closest to the parameter position
  69225. * @param position world position
  69226. * @returns the closest point to position constrained by the navigation mesh
  69227. */
  69228. getClosestPoint(position: Vector3): Vector3;
  69229. /**
  69230. * Get a navigation mesh constrained position, closest to the parameter position
  69231. * @param position world position
  69232. * @param result output the closest point to position constrained by the navigation mesh
  69233. */
  69234. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69235. /**
  69236. * Get a navigation mesh constrained position, within a particular radius
  69237. * @param position world position
  69238. * @param maxRadius the maximum distance to the constrained world position
  69239. * @returns the closest point to position constrained by the navigation mesh
  69240. */
  69241. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69242. /**
  69243. * Get a navigation mesh constrained position, within a particular radius
  69244. * @param position world position
  69245. * @param maxRadius the maximum distance to the constrained world position
  69246. * @param result output the closest point to position constrained by the navigation mesh
  69247. */
  69248. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69249. /**
  69250. * Compute the final position from a segment made of destination-position
  69251. * @param position world position
  69252. * @param destination world position
  69253. * @returns the resulting point along the navmesh
  69254. */
  69255. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69256. /**
  69257. * Compute the final position from a segment made of destination-position
  69258. * @param position world position
  69259. * @param destination world position
  69260. * @param result output the resulting point along the navmesh
  69261. */
  69262. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69263. /**
  69264. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69265. * @param start world position
  69266. * @param end world position
  69267. * @returns array containing world position composing the path
  69268. */
  69269. computePath(start: Vector3, end: Vector3): Vector3[];
  69270. /**
  69271. * If this plugin is supported
  69272. * @returns true if plugin is supported
  69273. */
  69274. isSupported(): boolean;
  69275. /**
  69276. * Create a new Crowd so you can add agents
  69277. * @param maxAgents the maximum agent count in the crowd
  69278. * @param maxAgentRadius the maximum radius an agent can have
  69279. * @param scene to attach the crowd to
  69280. * @returns the crowd you can add agents to
  69281. */
  69282. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69283. /**
  69284. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69285. * The queries will try to find a solution within those bounds
  69286. * default is (1,1,1)
  69287. * @param extent x,y,z value that define the extent around the queries point of reference
  69288. */
  69289. setDefaultQueryExtent(extent: Vector3): void;
  69290. /**
  69291. * Get the Bounding box extent specified by setDefaultQueryExtent
  69292. * @returns the box extent values
  69293. */
  69294. getDefaultQueryExtent(): Vector3;
  69295. /**
  69296. * build the navmesh from a previously saved state using getNavmeshData
  69297. * @param data the Uint8Array returned by getNavmeshData
  69298. */
  69299. buildFromNavmeshData(data: Uint8Array): void;
  69300. /**
  69301. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69302. * @returns data the Uint8Array that can be saved and reused
  69303. */
  69304. getNavmeshData(): Uint8Array;
  69305. /**
  69306. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69307. * @param result output the box extent values
  69308. */
  69309. getDefaultQueryExtentToRef(result: Vector3): void;
  69310. /**
  69311. * Release all resources
  69312. */
  69313. dispose(): void;
  69314. }
  69315. /**
  69316. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69317. */
  69318. export interface ICrowd {
  69319. /**
  69320. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69321. * You can attach anything to that node. The node position is updated in the scene update tick.
  69322. * @param pos world position that will be constrained by the navigation mesh
  69323. * @param parameters agent parameters
  69324. * @param transform hooked to the agent that will be update by the scene
  69325. * @returns agent index
  69326. */
  69327. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69328. /**
  69329. * Returns the agent position in world space
  69330. * @param index agent index returned by addAgent
  69331. * @returns world space position
  69332. */
  69333. getAgentPosition(index: number): Vector3;
  69334. /**
  69335. * Gets the agent position result in world space
  69336. * @param index agent index returned by addAgent
  69337. * @param result output world space position
  69338. */
  69339. getAgentPositionToRef(index: number, result: Vector3): void;
  69340. /**
  69341. * Gets the agent velocity in world space
  69342. * @param index agent index returned by addAgent
  69343. * @returns world space velocity
  69344. */
  69345. getAgentVelocity(index: number): Vector3;
  69346. /**
  69347. * Gets the agent velocity result in world space
  69348. * @param index agent index returned by addAgent
  69349. * @param result output world space velocity
  69350. */
  69351. getAgentVelocityToRef(index: number, result: Vector3): void;
  69352. /**
  69353. * remove a particular agent previously created
  69354. * @param index agent index returned by addAgent
  69355. */
  69356. removeAgent(index: number): void;
  69357. /**
  69358. * get the list of all agents attached to this crowd
  69359. * @returns list of agent indices
  69360. */
  69361. getAgents(): number[];
  69362. /**
  69363. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69364. * @param deltaTime in seconds
  69365. */
  69366. update(deltaTime: number): void;
  69367. /**
  69368. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69369. * @param index agent index returned by addAgent
  69370. * @param destination targeted world position
  69371. */
  69372. agentGoto(index: number, destination: Vector3): void;
  69373. /**
  69374. * Teleport the agent to a new position
  69375. * @param index agent index returned by addAgent
  69376. * @param destination targeted world position
  69377. */
  69378. agentTeleport(index: number, destination: Vector3): void;
  69379. /**
  69380. * Update agent parameters
  69381. * @param index agent index returned by addAgent
  69382. * @param parameters agent parameters
  69383. */
  69384. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69385. /**
  69386. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69387. * The queries will try to find a solution within those bounds
  69388. * default is (1,1,1)
  69389. * @param extent x,y,z value that define the extent around the queries point of reference
  69390. */
  69391. setDefaultQueryExtent(extent: Vector3): void;
  69392. /**
  69393. * Get the Bounding box extent specified by setDefaultQueryExtent
  69394. * @returns the box extent values
  69395. */
  69396. getDefaultQueryExtent(): Vector3;
  69397. /**
  69398. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69399. * @param result output the box extent values
  69400. */
  69401. getDefaultQueryExtentToRef(result: Vector3): void;
  69402. /**
  69403. * Release all resources
  69404. */
  69405. dispose(): void;
  69406. }
  69407. /**
  69408. * Configures an agent
  69409. */
  69410. export interface IAgentParameters {
  69411. /**
  69412. * Agent radius. [Limit: >= 0]
  69413. */
  69414. radius: number;
  69415. /**
  69416. * Agent height. [Limit: > 0]
  69417. */
  69418. height: number;
  69419. /**
  69420. * Maximum allowed acceleration. [Limit: >= 0]
  69421. */
  69422. maxAcceleration: number;
  69423. /**
  69424. * Maximum allowed speed. [Limit: >= 0]
  69425. */
  69426. maxSpeed: number;
  69427. /**
  69428. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69429. */
  69430. collisionQueryRange: number;
  69431. /**
  69432. * The path visibility optimization range. [Limit: > 0]
  69433. */
  69434. pathOptimizationRange: number;
  69435. /**
  69436. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69437. */
  69438. separationWeight: number;
  69439. }
  69440. /**
  69441. * Configures the navigation mesh creation
  69442. */
  69443. export interface INavMeshParameters {
  69444. /**
  69445. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  69446. */
  69447. cs: number;
  69448. /**
  69449. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  69450. */
  69451. ch: number;
  69452. /**
  69453. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  69454. */
  69455. walkableSlopeAngle: number;
  69456. /**
  69457. * Minimum floor to 'ceiling' height that will still allow the floor area to
  69458. * be considered walkable. [Limit: >= 3] [Units: vx]
  69459. */
  69460. walkableHeight: number;
  69461. /**
  69462. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  69463. */
  69464. walkableClimb: number;
  69465. /**
  69466. * The distance to erode/shrink the walkable area of the heightfield away from
  69467. * obstructions. [Limit: >=0] [Units: vx]
  69468. */
  69469. walkableRadius: number;
  69470. /**
  69471. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  69472. */
  69473. maxEdgeLen: number;
  69474. /**
  69475. * The maximum distance a simplfied contour's border edges should deviate
  69476. * the original raw contour. [Limit: >=0] [Units: vx]
  69477. */
  69478. maxSimplificationError: number;
  69479. /**
  69480. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  69481. */
  69482. minRegionArea: number;
  69483. /**
  69484. * Any regions with a span count smaller than this value will, if possible,
  69485. * be merged with larger regions. [Limit: >=0] [Units: vx]
  69486. */
  69487. mergeRegionArea: number;
  69488. /**
  69489. * The maximum number of vertices allowed for polygons generated during the
  69490. * contour to polygon conversion process. [Limit: >= 3]
  69491. */
  69492. maxVertsPerPoly: number;
  69493. /**
  69494. * Sets the sampling distance to use when generating the detail mesh.
  69495. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  69496. */
  69497. detailSampleDist: number;
  69498. /**
  69499. * The maximum distance the detail mesh surface should deviate from heightfield
  69500. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  69501. */
  69502. detailSampleMaxError: number;
  69503. }
  69504. }
  69505. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  69506. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  69507. import { Mesh } from "babylonjs/Meshes/mesh";
  69508. import { Scene } from "babylonjs/scene";
  69509. import { Vector3 } from "babylonjs/Maths/math";
  69510. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69511. /**
  69512. * RecastJS navigation plugin
  69513. */
  69514. export class RecastJSPlugin implements INavigationEnginePlugin {
  69515. /**
  69516. * Reference to the Recast library
  69517. */
  69518. bjsRECAST: any;
  69519. /**
  69520. * plugin name
  69521. */
  69522. name: string;
  69523. /**
  69524. * the first navmesh created. We might extend this to support multiple navmeshes
  69525. */
  69526. navMesh: any;
  69527. /**
  69528. * Initializes the recastJS plugin
  69529. * @param recastInjection can be used to inject your own recast reference
  69530. */
  69531. constructor(recastInjection?: any);
  69532. /**
  69533. * Creates a navigation mesh
  69534. * @param meshes array of all the geometry used to compute the navigatio mesh
  69535. * @param parameters bunch of parameters used to filter geometry
  69536. */
  69537. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69538. /**
  69539. * Create a navigation mesh debug mesh
  69540. * @param scene is where the mesh will be added
  69541. * @returns debug display mesh
  69542. */
  69543. createDebugNavMesh(scene: Scene): Mesh;
  69544. /**
  69545. * Get a navigation mesh constrained position, closest to the parameter position
  69546. * @param position world position
  69547. * @returns the closest point to position constrained by the navigation mesh
  69548. */
  69549. getClosestPoint(position: Vector3): Vector3;
  69550. /**
  69551. * Get a navigation mesh constrained position, closest to the parameter position
  69552. * @param position world position
  69553. * @param result output the closest point to position constrained by the navigation mesh
  69554. */
  69555. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69556. /**
  69557. * Get a navigation mesh constrained position, within a particular radius
  69558. * @param position world position
  69559. * @param maxRadius the maximum distance to the constrained world position
  69560. * @returns the closest point to position constrained by the navigation mesh
  69561. */
  69562. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69563. /**
  69564. * Get a navigation mesh constrained position, within a particular radius
  69565. * @param position world position
  69566. * @param maxRadius the maximum distance to the constrained world position
  69567. * @param result output the closest point to position constrained by the navigation mesh
  69568. */
  69569. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69570. /**
  69571. * Compute the final position from a segment made of destination-position
  69572. * @param position world position
  69573. * @param destination world position
  69574. * @returns the resulting point along the navmesh
  69575. */
  69576. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69577. /**
  69578. * Compute the final position from a segment made of destination-position
  69579. * @param position world position
  69580. * @param destination world position
  69581. * @param result output the resulting point along the navmesh
  69582. */
  69583. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69584. /**
  69585. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69586. * @param start world position
  69587. * @param end world position
  69588. * @returns array containing world position composing the path
  69589. */
  69590. computePath(start: Vector3, end: Vector3): Vector3[];
  69591. /**
  69592. * Create a new Crowd so you can add agents
  69593. * @param maxAgents the maximum agent count in the crowd
  69594. * @param maxAgentRadius the maximum radius an agent can have
  69595. * @param scene to attach the crowd to
  69596. * @returns the crowd you can add agents to
  69597. */
  69598. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69599. /**
  69600. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69601. * The queries will try to find a solution within those bounds
  69602. * default is (1,1,1)
  69603. * @param extent x,y,z value that define the extent around the queries point of reference
  69604. */
  69605. setDefaultQueryExtent(extent: Vector3): void;
  69606. /**
  69607. * Get the Bounding box extent specified by setDefaultQueryExtent
  69608. * @returns the box extent values
  69609. */
  69610. getDefaultQueryExtent(): Vector3;
  69611. /**
  69612. * build the navmesh from a previously saved state using getNavmeshData
  69613. * @param data the Uint8Array returned by getNavmeshData
  69614. */
  69615. buildFromNavmeshData(data: Uint8Array): void;
  69616. /**
  69617. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69618. * @returns data the Uint8Array that can be saved and reused
  69619. */
  69620. getNavmeshData(): Uint8Array;
  69621. /**
  69622. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69623. * @param result output the box extent values
  69624. */
  69625. getDefaultQueryExtentToRef(result: Vector3): void;
  69626. /**
  69627. * Disposes
  69628. */
  69629. dispose(): void;
  69630. /**
  69631. * If this plugin is supported
  69632. * @returns true if plugin is supported
  69633. */
  69634. isSupported(): boolean;
  69635. }
  69636. /**
  69637. * Recast detour crowd implementation
  69638. */
  69639. export class RecastJSCrowd implements ICrowd {
  69640. /**
  69641. * Recast/detour plugin
  69642. */
  69643. bjsRECASTPlugin: RecastJSPlugin;
  69644. /**
  69645. * Link to the detour crowd
  69646. */
  69647. recastCrowd: any;
  69648. /**
  69649. * One transform per agent
  69650. */
  69651. transforms: TransformNode[];
  69652. /**
  69653. * All agents created
  69654. */
  69655. agents: number[];
  69656. /**
  69657. * Link to the scene is kept to unregister the crowd from the scene
  69658. */
  69659. private _scene;
  69660. /**
  69661. * Observer for crowd updates
  69662. */
  69663. private _onBeforeAnimationsObserver;
  69664. /**
  69665. * Constructor
  69666. * @param plugin recastJS plugin
  69667. * @param maxAgents the maximum agent count in the crowd
  69668. * @param maxAgentRadius the maximum radius an agent can have
  69669. * @param scene to attach the crowd to
  69670. * @returns the crowd you can add agents to
  69671. */
  69672. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  69673. /**
  69674. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69675. * You can attach anything to that node. The node position is updated in the scene update tick.
  69676. * @param pos world position that will be constrained by the navigation mesh
  69677. * @param parameters agent parameters
  69678. * @param transform hooked to the agent that will be update by the scene
  69679. * @returns agent index
  69680. */
  69681. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69682. /**
  69683. * Returns the agent position in world space
  69684. * @param index agent index returned by addAgent
  69685. * @returns world space position
  69686. */
  69687. getAgentPosition(index: number): Vector3;
  69688. /**
  69689. * Returns the agent position result in world space
  69690. * @param index agent index returned by addAgent
  69691. * @param result output world space position
  69692. */
  69693. getAgentPositionToRef(index: number, result: Vector3): void;
  69694. /**
  69695. * Returns the agent velocity in world space
  69696. * @param index agent index returned by addAgent
  69697. * @returns world space velocity
  69698. */
  69699. getAgentVelocity(index: number): Vector3;
  69700. /**
  69701. * Returns the agent velocity result in world space
  69702. * @param index agent index returned by addAgent
  69703. * @param result output world space velocity
  69704. */
  69705. getAgentVelocityToRef(index: number, result: Vector3): void;
  69706. /**
  69707. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69708. * @param index agent index returned by addAgent
  69709. * @param destination targeted world position
  69710. */
  69711. agentGoto(index: number, destination: Vector3): void;
  69712. /**
  69713. * Teleport the agent to a new position
  69714. * @param index agent index returned by addAgent
  69715. * @param destination targeted world position
  69716. */
  69717. agentTeleport(index: number, destination: Vector3): void;
  69718. /**
  69719. * Update agent parameters
  69720. * @param index agent index returned by addAgent
  69721. * @param parameters agent parameters
  69722. */
  69723. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69724. /**
  69725. * remove a particular agent previously created
  69726. * @param index agent index returned by addAgent
  69727. */
  69728. removeAgent(index: number): void;
  69729. /**
  69730. * get the list of all agents attached to this crowd
  69731. * @returns list of agent indices
  69732. */
  69733. getAgents(): number[];
  69734. /**
  69735. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69736. * @param deltaTime in seconds
  69737. */
  69738. update(deltaTime: number): void;
  69739. /**
  69740. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69741. * The queries will try to find a solution within those bounds
  69742. * default is (1,1,1)
  69743. * @param extent x,y,z value that define the extent around the queries point of reference
  69744. */
  69745. setDefaultQueryExtent(extent: Vector3): void;
  69746. /**
  69747. * Get the Bounding box extent specified by setDefaultQueryExtent
  69748. * @returns the box extent values
  69749. */
  69750. getDefaultQueryExtent(): Vector3;
  69751. /**
  69752. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69753. * @param result output the box extent values
  69754. */
  69755. getDefaultQueryExtentToRef(result: Vector3): void;
  69756. /**
  69757. * Release all resources
  69758. */
  69759. dispose(): void;
  69760. }
  69761. }
  69762. declare module "babylonjs/Navigation/Plugins/index" {
  69763. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69764. }
  69765. declare module "babylonjs/Navigation/index" {
  69766. export * from "babylonjs/Navigation/INavigationEngine";
  69767. export * from "babylonjs/Navigation/Plugins/index";
  69768. }
  69769. declare module "babylonjs/Offline/database" {
  69770. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69771. /**
  69772. * Class used to enable access to IndexedDB
  69773. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69774. */
  69775. export class Database implements IOfflineProvider {
  69776. private _callbackManifestChecked;
  69777. private _currentSceneUrl;
  69778. private _db;
  69779. private _enableSceneOffline;
  69780. private _enableTexturesOffline;
  69781. private _manifestVersionFound;
  69782. private _mustUpdateRessources;
  69783. private _hasReachedQuota;
  69784. private _isSupported;
  69785. private _idbFactory;
  69786. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69787. private static IsUASupportingBlobStorage;
  69788. /**
  69789. * Gets a boolean indicating if Database storate is enabled (off by default)
  69790. */
  69791. static IDBStorageEnabled: boolean;
  69792. /**
  69793. * Gets a boolean indicating if scene must be saved in the database
  69794. */
  69795. get enableSceneOffline(): boolean;
  69796. /**
  69797. * Gets a boolean indicating if textures must be saved in the database
  69798. */
  69799. get enableTexturesOffline(): boolean;
  69800. /**
  69801. * Creates a new Database
  69802. * @param urlToScene defines the url to load the scene
  69803. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69804. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69805. */
  69806. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69807. private static _ParseURL;
  69808. private static _ReturnFullUrlLocation;
  69809. private _checkManifestFile;
  69810. /**
  69811. * Open the database and make it available
  69812. * @param successCallback defines the callback to call on success
  69813. * @param errorCallback defines the callback to call on error
  69814. */
  69815. open(successCallback: () => void, errorCallback: () => void): void;
  69816. /**
  69817. * Loads an image from the database
  69818. * @param url defines the url to load from
  69819. * @param image defines the target DOM image
  69820. */
  69821. loadImage(url: string, image: HTMLImageElement): void;
  69822. private _loadImageFromDBAsync;
  69823. private _saveImageIntoDBAsync;
  69824. private _checkVersionFromDB;
  69825. private _loadVersionFromDBAsync;
  69826. private _saveVersionIntoDBAsync;
  69827. /**
  69828. * Loads a file from database
  69829. * @param url defines the URL to load from
  69830. * @param sceneLoaded defines a callback to call on success
  69831. * @param progressCallBack defines a callback to call when progress changed
  69832. * @param errorCallback defines a callback to call on error
  69833. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69834. */
  69835. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69836. private _loadFileAsync;
  69837. private _saveFileAsync;
  69838. /**
  69839. * Validates if xhr data is correct
  69840. * @param xhr defines the request to validate
  69841. * @param dataType defines the expected data type
  69842. * @returns true if data is correct
  69843. */
  69844. private static _ValidateXHRData;
  69845. }
  69846. }
  69847. declare module "babylonjs/Offline/index" {
  69848. export * from "babylonjs/Offline/database";
  69849. export * from "babylonjs/Offline/IOfflineProvider";
  69850. }
  69851. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69852. /** @hidden */
  69853. export var gpuUpdateParticlesPixelShader: {
  69854. name: string;
  69855. shader: string;
  69856. };
  69857. }
  69858. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69859. /** @hidden */
  69860. export var gpuUpdateParticlesVertexShader: {
  69861. name: string;
  69862. shader: string;
  69863. };
  69864. }
  69865. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69866. /** @hidden */
  69867. export var clipPlaneFragmentDeclaration2: {
  69868. name: string;
  69869. shader: string;
  69870. };
  69871. }
  69872. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69873. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69874. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69875. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69876. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69877. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69878. /** @hidden */
  69879. export var gpuRenderParticlesPixelShader: {
  69880. name: string;
  69881. shader: string;
  69882. };
  69883. }
  69884. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69885. /** @hidden */
  69886. export var clipPlaneVertexDeclaration2: {
  69887. name: string;
  69888. shader: string;
  69889. };
  69890. }
  69891. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69892. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69893. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69894. /** @hidden */
  69895. export var gpuRenderParticlesVertexShader: {
  69896. name: string;
  69897. shader: string;
  69898. };
  69899. }
  69900. declare module "babylonjs/Particles/gpuParticleSystem" {
  69901. import { Nullable } from "babylonjs/types";
  69902. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69903. import { Observable } from "babylonjs/Misc/observable";
  69904. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69905. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69906. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69907. import { Scene, IDisposable } from "babylonjs/scene";
  69908. import { Effect } from "babylonjs/Materials/effect";
  69909. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69910. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69911. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69912. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69913. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69914. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69915. /**
  69916. * This represents a GPU particle system in Babylon
  69917. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69918. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69919. */
  69920. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69921. /**
  69922. * The layer mask we are rendering the particles through.
  69923. */
  69924. layerMask: number;
  69925. private _capacity;
  69926. private _activeCount;
  69927. private _currentActiveCount;
  69928. private _accumulatedCount;
  69929. private _renderEffect;
  69930. private _updateEffect;
  69931. private _buffer0;
  69932. private _buffer1;
  69933. private _spriteBuffer;
  69934. private _updateVAO;
  69935. private _renderVAO;
  69936. private _targetIndex;
  69937. private _sourceBuffer;
  69938. private _targetBuffer;
  69939. private _engine;
  69940. private _currentRenderId;
  69941. private _started;
  69942. private _stopped;
  69943. private _timeDelta;
  69944. private _randomTexture;
  69945. private _randomTexture2;
  69946. private _attributesStrideSize;
  69947. private _updateEffectOptions;
  69948. private _randomTextureSize;
  69949. private _actualFrame;
  69950. private _customEffect;
  69951. private readonly _rawTextureWidth;
  69952. /**
  69953. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69954. */
  69955. static get IsSupported(): boolean;
  69956. /**
  69957. * An event triggered when the system is disposed.
  69958. */
  69959. onDisposeObservable: Observable<IParticleSystem>;
  69960. /**
  69961. * Gets the maximum number of particles active at the same time.
  69962. * @returns The max number of active particles.
  69963. */
  69964. getCapacity(): number;
  69965. /**
  69966. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69967. * to override the particles.
  69968. */
  69969. forceDepthWrite: boolean;
  69970. /**
  69971. * Gets or set the number of active particles
  69972. */
  69973. get activeParticleCount(): number;
  69974. set activeParticleCount(value: number);
  69975. private _preWarmDone;
  69976. /**
  69977. * Specifies if the particles are updated in emitter local space or world space.
  69978. */
  69979. isLocal: boolean;
  69980. /**
  69981. * Is this system ready to be used/rendered
  69982. * @return true if the system is ready
  69983. */
  69984. isReady(): boolean;
  69985. /**
  69986. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69987. * @returns True if it has been started, otherwise false.
  69988. */
  69989. isStarted(): boolean;
  69990. /**
  69991. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69992. * @returns True if it has been stopped, otherwise false.
  69993. */
  69994. isStopped(): boolean;
  69995. /**
  69996. * Gets a boolean indicating that the system is stopping
  69997. * @returns true if the system is currently stopping
  69998. */
  69999. isStopping(): boolean;
  70000. /**
  70001. * Gets the number of particles active at the same time.
  70002. * @returns The number of active particles.
  70003. */
  70004. getActiveCount(): number;
  70005. /**
  70006. * Starts the particle system and begins to emit
  70007. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70008. */
  70009. start(delay?: number): void;
  70010. /**
  70011. * Stops the particle system.
  70012. */
  70013. stop(): void;
  70014. /**
  70015. * Remove all active particles
  70016. */
  70017. reset(): void;
  70018. /**
  70019. * Returns the string "GPUParticleSystem"
  70020. * @returns a string containing the class name
  70021. */
  70022. getClassName(): string;
  70023. /**
  70024. * Gets the custom effect used to render the particles
  70025. * @param blendMode Blend mode for which the effect should be retrieved
  70026. * @returns The effect
  70027. */
  70028. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70029. /**
  70030. * Sets the custom effect used to render the particles
  70031. * @param effect The effect to set
  70032. * @param blendMode Blend mode for which the effect should be set
  70033. */
  70034. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70035. /** @hidden */
  70036. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70037. /**
  70038. * Observable that will be called just before the particles are drawn
  70039. */
  70040. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70041. /**
  70042. * Gets the name of the particle vertex shader
  70043. */
  70044. get vertexShaderName(): string;
  70045. private _colorGradientsTexture;
  70046. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70047. /**
  70048. * Adds a new color gradient
  70049. * @param gradient defines the gradient to use (between 0 and 1)
  70050. * @param color1 defines the color to affect to the specified gradient
  70051. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70052. * @returns the current particle system
  70053. */
  70054. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70055. private _refreshColorGradient;
  70056. /** Force the system to rebuild all gradients that need to be resync */
  70057. forceRefreshGradients(): void;
  70058. /**
  70059. * Remove a specific color gradient
  70060. * @param gradient defines the gradient to remove
  70061. * @returns the current particle system
  70062. */
  70063. removeColorGradient(gradient: number): GPUParticleSystem;
  70064. private _angularSpeedGradientsTexture;
  70065. private _sizeGradientsTexture;
  70066. private _velocityGradientsTexture;
  70067. private _limitVelocityGradientsTexture;
  70068. private _dragGradientsTexture;
  70069. private _addFactorGradient;
  70070. /**
  70071. * Adds a new size gradient
  70072. * @param gradient defines the gradient to use (between 0 and 1)
  70073. * @param factor defines the size factor to affect to the specified gradient
  70074. * @returns the current particle system
  70075. */
  70076. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70077. /**
  70078. * Remove a specific size gradient
  70079. * @param gradient defines the gradient to remove
  70080. * @returns the current particle system
  70081. */
  70082. removeSizeGradient(gradient: number): GPUParticleSystem;
  70083. private _refreshFactorGradient;
  70084. /**
  70085. * Adds a new angular speed gradient
  70086. * @param gradient defines the gradient to use (between 0 and 1)
  70087. * @param factor defines the angular speed to affect to the specified gradient
  70088. * @returns the current particle system
  70089. */
  70090. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70091. /**
  70092. * Remove a specific angular speed gradient
  70093. * @param gradient defines the gradient to remove
  70094. * @returns the current particle system
  70095. */
  70096. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70097. /**
  70098. * Adds a new velocity gradient
  70099. * @param gradient defines the gradient to use (between 0 and 1)
  70100. * @param factor defines the velocity to affect to the specified gradient
  70101. * @returns the current particle system
  70102. */
  70103. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70104. /**
  70105. * Remove a specific velocity gradient
  70106. * @param gradient defines the gradient to remove
  70107. * @returns the current particle system
  70108. */
  70109. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70110. /**
  70111. * Adds a new limit velocity gradient
  70112. * @param gradient defines the gradient to use (between 0 and 1)
  70113. * @param factor defines the limit velocity value to affect to the specified gradient
  70114. * @returns the current particle system
  70115. */
  70116. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70117. /**
  70118. * Remove a specific limit velocity gradient
  70119. * @param gradient defines the gradient to remove
  70120. * @returns the current particle system
  70121. */
  70122. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70123. /**
  70124. * Adds a new drag gradient
  70125. * @param gradient defines the gradient to use (between 0 and 1)
  70126. * @param factor defines the drag value to affect to the specified gradient
  70127. * @returns the current particle system
  70128. */
  70129. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70130. /**
  70131. * Remove a specific drag gradient
  70132. * @param gradient defines the gradient to remove
  70133. * @returns the current particle system
  70134. */
  70135. removeDragGradient(gradient: number): GPUParticleSystem;
  70136. /**
  70137. * Not supported by GPUParticleSystem
  70138. * @param gradient defines the gradient to use (between 0 and 1)
  70139. * @param factor defines the emit rate value to affect to the specified gradient
  70140. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70141. * @returns the current particle system
  70142. */
  70143. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70144. /**
  70145. * Not supported by GPUParticleSystem
  70146. * @param gradient defines the gradient to remove
  70147. * @returns the current particle system
  70148. */
  70149. removeEmitRateGradient(gradient: number): IParticleSystem;
  70150. /**
  70151. * Not supported by GPUParticleSystem
  70152. * @param gradient defines the gradient to use (between 0 and 1)
  70153. * @param factor defines the start size value to affect to the specified gradient
  70154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70155. * @returns the current particle system
  70156. */
  70157. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70158. /**
  70159. * Not supported by GPUParticleSystem
  70160. * @param gradient defines the gradient to remove
  70161. * @returns the current particle system
  70162. */
  70163. removeStartSizeGradient(gradient: number): IParticleSystem;
  70164. /**
  70165. * Not supported by GPUParticleSystem
  70166. * @param gradient defines the gradient to use (between 0 and 1)
  70167. * @param min defines the color remap minimal range
  70168. * @param max defines the color remap maximal range
  70169. * @returns the current particle system
  70170. */
  70171. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70172. /**
  70173. * Not supported by GPUParticleSystem
  70174. * @param gradient defines the gradient to remove
  70175. * @returns the current particle system
  70176. */
  70177. removeColorRemapGradient(): IParticleSystem;
  70178. /**
  70179. * Not supported by GPUParticleSystem
  70180. * @param gradient defines the gradient to use (between 0 and 1)
  70181. * @param min defines the alpha remap minimal range
  70182. * @param max defines the alpha remap maximal range
  70183. * @returns the current particle system
  70184. */
  70185. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70186. /**
  70187. * Not supported by GPUParticleSystem
  70188. * @param gradient defines the gradient to remove
  70189. * @returns the current particle system
  70190. */
  70191. removeAlphaRemapGradient(): IParticleSystem;
  70192. /**
  70193. * Not supported by GPUParticleSystem
  70194. * @param gradient defines the gradient to use (between 0 and 1)
  70195. * @param color defines the color to affect to the specified gradient
  70196. * @returns the current particle system
  70197. */
  70198. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70199. /**
  70200. * Not supported by GPUParticleSystem
  70201. * @param gradient defines the gradient to remove
  70202. * @returns the current particle system
  70203. */
  70204. removeRampGradient(): IParticleSystem;
  70205. /**
  70206. * Not supported by GPUParticleSystem
  70207. * @returns the list of ramp gradients
  70208. */
  70209. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70210. /**
  70211. * Not supported by GPUParticleSystem
  70212. * Gets or sets a boolean indicating that ramp gradients must be used
  70213. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70214. */
  70215. get useRampGradients(): boolean;
  70216. set useRampGradients(value: boolean);
  70217. /**
  70218. * Not supported by GPUParticleSystem
  70219. * @param gradient defines the gradient to use (between 0 and 1)
  70220. * @param factor defines the life time factor to affect to the specified gradient
  70221. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70222. * @returns the current particle system
  70223. */
  70224. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70225. /**
  70226. * Not supported by GPUParticleSystem
  70227. * @param gradient defines the gradient to remove
  70228. * @returns the current particle system
  70229. */
  70230. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70231. /**
  70232. * Instantiates a GPU particle system.
  70233. * 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.
  70234. * @param name The name of the particle system
  70235. * @param options The options used to create the system
  70236. * @param scene The scene the particle system belongs to
  70237. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70238. * @param customEffect a custom effect used to change the way particles are rendered by default
  70239. */
  70240. constructor(name: string, options: Partial<{
  70241. capacity: number;
  70242. randomTextureSize: number;
  70243. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70244. protected _reset(): void;
  70245. private _createUpdateVAO;
  70246. private _createRenderVAO;
  70247. private _initialize;
  70248. /** @hidden */
  70249. _recreateUpdateEffect(): void;
  70250. private _getEffect;
  70251. /**
  70252. * Fill the defines array according to the current settings of the particle system
  70253. * @param defines Array to be updated
  70254. * @param blendMode blend mode to take into account when updating the array
  70255. */
  70256. fillDefines(defines: Array<string>, blendMode?: number): void;
  70257. /**
  70258. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70259. * @param uniforms Uniforms array to fill
  70260. * @param attributes Attributes array to fill
  70261. * @param samplers Samplers array to fill
  70262. */
  70263. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70264. /** @hidden */
  70265. _recreateRenderEffect(): Effect;
  70266. /**
  70267. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70268. * @param preWarm defines if we are in the pre-warmimg phase
  70269. */
  70270. animate(preWarm?: boolean): void;
  70271. private _createFactorGradientTexture;
  70272. private _createSizeGradientTexture;
  70273. private _createAngularSpeedGradientTexture;
  70274. private _createVelocityGradientTexture;
  70275. private _createLimitVelocityGradientTexture;
  70276. private _createDragGradientTexture;
  70277. private _createColorGradientTexture;
  70278. /**
  70279. * Renders the particle system in its current state
  70280. * @param preWarm defines if the system should only update the particles but not render them
  70281. * @returns the current number of particles
  70282. */
  70283. render(preWarm?: boolean): number;
  70284. /**
  70285. * Rebuilds the particle system
  70286. */
  70287. rebuild(): void;
  70288. private _releaseBuffers;
  70289. private _releaseVAOs;
  70290. /**
  70291. * Disposes the particle system and free the associated resources
  70292. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70293. */
  70294. dispose(disposeTexture?: boolean): void;
  70295. /**
  70296. * Clones the particle system.
  70297. * @param name The name of the cloned object
  70298. * @param newEmitter The new emitter to use
  70299. * @returns the cloned particle system
  70300. */
  70301. clone(name: string, newEmitter: any): GPUParticleSystem;
  70302. /**
  70303. * Serializes the particle system to a JSON object
  70304. * @param serializeTexture defines if the texture must be serialized as well
  70305. * @returns the JSON object
  70306. */
  70307. serialize(serializeTexture?: boolean): any;
  70308. /**
  70309. * Parses a JSON object to create a GPU particle system.
  70310. * @param parsedParticleSystem The JSON object to parse
  70311. * @param scene The scene to create the particle system in
  70312. * @param rootUrl The root url to use to load external dependencies like texture
  70313. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70314. * @returns the parsed GPU particle system
  70315. */
  70316. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70317. }
  70318. }
  70319. declare module "babylonjs/Particles/particleSystemSet" {
  70320. import { Nullable } from "babylonjs/types";
  70321. import { Color3 } from "babylonjs/Maths/math.color";
  70322. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70324. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70325. import { Scene, IDisposable } from "babylonjs/scene";
  70326. /**
  70327. * Represents a set of particle systems working together to create a specific effect
  70328. */
  70329. export class ParticleSystemSet implements IDisposable {
  70330. /**
  70331. * Gets or sets base Assets URL
  70332. */
  70333. static BaseAssetsUrl: string;
  70334. private _emitterCreationOptions;
  70335. private _emitterNode;
  70336. /**
  70337. * Gets the particle system list
  70338. */
  70339. systems: IParticleSystem[];
  70340. /**
  70341. * Gets the emitter node used with this set
  70342. */
  70343. get emitterNode(): Nullable<TransformNode>;
  70344. /**
  70345. * Creates a new emitter mesh as a sphere
  70346. * @param options defines the options used to create the sphere
  70347. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70348. * @param scene defines the hosting scene
  70349. */
  70350. setEmitterAsSphere(options: {
  70351. diameter: number;
  70352. segments: number;
  70353. color: Color3;
  70354. }, renderingGroupId: number, scene: Scene): void;
  70355. /**
  70356. * Starts all particle systems of the set
  70357. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70358. */
  70359. start(emitter?: AbstractMesh): void;
  70360. /**
  70361. * Release all associated resources
  70362. */
  70363. dispose(): void;
  70364. /**
  70365. * Serialize the set into a JSON compatible object
  70366. * @param serializeTexture defines if the texture must be serialized as well
  70367. * @returns a JSON compatible representation of the set
  70368. */
  70369. serialize(serializeTexture?: boolean): any;
  70370. /**
  70371. * Parse a new ParticleSystemSet from a serialized source
  70372. * @param data defines a JSON compatible representation of the set
  70373. * @param scene defines the hosting scene
  70374. * @param gpu defines if we want GPU particles or CPU particles
  70375. * @returns a new ParticleSystemSet
  70376. */
  70377. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  70378. }
  70379. }
  70380. declare module "babylonjs/Particles/particleHelper" {
  70381. import { Nullable } from "babylonjs/types";
  70382. import { Scene } from "babylonjs/scene";
  70383. import { Vector3 } from "babylonjs/Maths/math.vector";
  70384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70385. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70386. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  70387. /**
  70388. * This class is made for on one-liner static method to help creating particle system set.
  70389. */
  70390. export class ParticleHelper {
  70391. /**
  70392. * Gets or sets base Assets URL
  70393. */
  70394. static BaseAssetsUrl: string;
  70395. /** Define the Url to load snippets */
  70396. static SnippetUrl: string;
  70397. /**
  70398. * Create a default particle system that you can tweak
  70399. * @param emitter defines the emitter to use
  70400. * @param capacity defines the system capacity (default is 500 particles)
  70401. * @param scene defines the hosting scene
  70402. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70403. * @returns the new Particle system
  70404. */
  70405. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70406. /**
  70407. * This is the main static method (one-liner) of this helper to create different particle systems
  70408. * @param type This string represents the type to the particle system to create
  70409. * @param scene The scene where the particle system should live
  70410. * @param gpu If the system will use gpu
  70411. * @returns the ParticleSystemSet created
  70412. */
  70413. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70414. /**
  70415. * Static function used to export a particle system to a ParticleSystemSet variable.
  70416. * Please note that the emitter shape is not exported
  70417. * @param systems defines the particle systems to export
  70418. * @returns the created particle system set
  70419. */
  70420. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70421. /**
  70422. * Creates a particle system from a snippet saved in a remote file
  70423. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70424. * @param url defines the url to load from
  70425. * @param scene defines the hosting scene
  70426. * @param gpu If the system will use gpu
  70427. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70428. * @returns a promise that will resolve to the new particle system
  70429. */
  70430. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70431. /**
  70432. * Creates a particle system from a snippet saved by the particle system editor
  70433. * @param snippetId defines the snippet to load
  70434. * @param scene defines the hosting scene
  70435. * @param gpu If the system will use gpu
  70436. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70437. * @returns a promise that will resolve to the new particle system
  70438. */
  70439. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70440. }
  70441. }
  70442. declare module "babylonjs/Particles/particleSystemComponent" {
  70443. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70444. import { Effect } from "babylonjs/Materials/effect";
  70445. import "babylonjs/Shaders/particles.vertex";
  70446. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70447. module "babylonjs/Engines/engine" {
  70448. interface Engine {
  70449. /**
  70450. * Create an effect to use with particle systems.
  70451. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  70452. * the particle system for which you want to create a custom effect in the last parameter
  70453. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  70454. * @param uniformsNames defines a list of attribute names
  70455. * @param samplers defines an array of string used to represent textures
  70456. * @param defines defines the string containing the defines to use to compile the shaders
  70457. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  70458. * @param onCompiled defines a function to call when the effect creation is successful
  70459. * @param onError defines a function to call when the effect creation has failed
  70460. * @param particleSystem the particle system you want to create the effect for
  70461. * @returns the new Effect
  70462. */
  70463. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  70464. }
  70465. }
  70466. module "babylonjs/Meshes/mesh" {
  70467. interface Mesh {
  70468. /**
  70469. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  70470. * @returns an array of IParticleSystem
  70471. */
  70472. getEmittedParticleSystems(): IParticleSystem[];
  70473. /**
  70474. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  70475. * @returns an array of IParticleSystem
  70476. */
  70477. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  70478. }
  70479. }
  70480. }
  70481. declare module "babylonjs/Particles/pointsCloudSystem" {
  70482. import { Color4 } from "babylonjs/Maths/math";
  70483. import { Mesh } from "babylonjs/Meshes/mesh";
  70484. import { Scene, IDisposable } from "babylonjs/scene";
  70485. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  70486. /** Defines the 4 color options */
  70487. export enum PointColor {
  70488. /** color value */
  70489. Color = 2,
  70490. /** uv value */
  70491. UV = 1,
  70492. /** random value */
  70493. Random = 0,
  70494. /** stated value */
  70495. Stated = 3
  70496. }
  70497. /**
  70498. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  70499. * 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.
  70500. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  70501. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  70502. *
  70503. * Full documentation here : TO BE ENTERED
  70504. */
  70505. export class PointsCloudSystem implements IDisposable {
  70506. /**
  70507. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  70508. * Example : var p = SPS.particles[i];
  70509. */
  70510. particles: CloudPoint[];
  70511. /**
  70512. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  70513. */
  70514. nbParticles: number;
  70515. /**
  70516. * This a counter for your own usage. It's not set by any SPS functions.
  70517. */
  70518. counter: number;
  70519. /**
  70520. * The PCS name. This name is also given to the underlying mesh.
  70521. */
  70522. name: string;
  70523. /**
  70524. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  70525. */
  70526. mesh: Mesh;
  70527. /**
  70528. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  70529. * Please read :
  70530. */
  70531. vars: any;
  70532. /**
  70533. * @hidden
  70534. */
  70535. _size: number;
  70536. private _scene;
  70537. private _promises;
  70538. private _positions;
  70539. private _indices;
  70540. private _normals;
  70541. private _colors;
  70542. private _uvs;
  70543. private _indices32;
  70544. private _positions32;
  70545. private _colors32;
  70546. private _uvs32;
  70547. private _updatable;
  70548. private _isVisibilityBoxLocked;
  70549. private _alwaysVisible;
  70550. private _groups;
  70551. private _groupCounter;
  70552. private _computeParticleColor;
  70553. private _computeParticleTexture;
  70554. private _computeParticleRotation;
  70555. private _computeBoundingBox;
  70556. private _isReady;
  70557. /**
  70558. * Creates a PCS (Points Cloud System) object
  70559. * @param name (String) is the PCS name, this will be the underlying mesh name
  70560. * @param pointSize (number) is the size for each point
  70561. * @param scene (Scene) is the scene in which the PCS is added
  70562. * @param options defines the options of the PCS e.g.
  70563. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  70564. */
  70565. constructor(name: string, pointSize: number, scene: Scene, options?: {
  70566. updatable?: boolean;
  70567. });
  70568. /**
  70569. * Builds the PCS underlying mesh. Returns a standard Mesh.
  70570. * If no points were added to the PCS, the returned mesh is just a single point.
  70571. * @returns a promise for the created mesh
  70572. */
  70573. buildMeshAsync(): Promise<Mesh>;
  70574. /**
  70575. * @hidden
  70576. */
  70577. private _buildMesh;
  70578. private _addParticle;
  70579. private _randomUnitVector;
  70580. private _getColorIndicesForCoord;
  70581. private _setPointsColorOrUV;
  70582. private _colorFromTexture;
  70583. private _calculateDensity;
  70584. /**
  70585. * Adds points to the PCS in random positions within a unit sphere
  70586. * @param nb (positive integer) the number of particles to be created from this model
  70587. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  70588. * @returns the number of groups in the system
  70589. */
  70590. addPoints(nb: number, pointFunction?: any): number;
  70591. /**
  70592. * Adds points to the PCS from the surface of the model shape
  70593. * @param mesh is any Mesh object that will be used as a surface model for the points
  70594. * @param nb (positive integer) the number of particles to be created from this model
  70595. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70596. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70597. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70598. * @returns the number of groups in the system
  70599. */
  70600. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70601. /**
  70602. * Adds points to the PCS inside the model shape
  70603. * @param mesh is any Mesh object that will be used as a surface model for the points
  70604. * @param nb (positive integer) the number of particles to be created from this model
  70605. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70606. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70607. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70608. * @returns the number of groups in the system
  70609. */
  70610. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70611. /**
  70612. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  70613. * This method calls `updateParticle()` for each particle of the SPS.
  70614. * For an animated SPS, it is usually called within the render loop.
  70615. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  70616. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  70617. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  70618. * @returns the PCS.
  70619. */
  70620. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  70621. /**
  70622. * Disposes the PCS.
  70623. */
  70624. dispose(): void;
  70625. /**
  70626. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  70627. * doc :
  70628. * @returns the PCS.
  70629. */
  70630. refreshVisibleSize(): PointsCloudSystem;
  70631. /**
  70632. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  70633. * @param size the size (float) of the visibility box
  70634. * note : this doesn't lock the PCS mesh bounding box.
  70635. * doc :
  70636. */
  70637. setVisibilityBox(size: number): void;
  70638. /**
  70639. * Gets whether the PCS is always visible or not
  70640. * doc :
  70641. */
  70642. get isAlwaysVisible(): boolean;
  70643. /**
  70644. * Sets the PCS as always visible or not
  70645. * doc :
  70646. */
  70647. set isAlwaysVisible(val: boolean);
  70648. /**
  70649. * Tells to `setParticles()` to compute the particle rotations or not
  70650. * Default value : false. The PCS is faster when it's set to false
  70651. * Note : particle rotations are only applied to parent particles
  70652. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  70653. */
  70654. set computeParticleRotation(val: boolean);
  70655. /**
  70656. * Tells to `setParticles()` to compute the particle colors or not.
  70657. * Default value : true. The PCS is faster when it's set to false.
  70658. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70659. */
  70660. set computeParticleColor(val: boolean);
  70661. set computeParticleTexture(val: boolean);
  70662. /**
  70663. * Gets if `setParticles()` computes the particle colors or not.
  70664. * Default value : false. The PCS is faster when it's set to false.
  70665. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70666. */
  70667. get computeParticleColor(): boolean;
  70668. /**
  70669. * Gets if `setParticles()` computes the particle textures or not.
  70670. * Default value : false. The PCS is faster when it's set to false.
  70671. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  70672. */
  70673. get computeParticleTexture(): boolean;
  70674. /**
  70675. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  70676. */
  70677. set computeBoundingBox(val: boolean);
  70678. /**
  70679. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  70680. */
  70681. get computeBoundingBox(): boolean;
  70682. /**
  70683. * This function does nothing. It may be overwritten to set all the particle first values.
  70684. * The PCS doesn't call this function, you may have to call it by your own.
  70685. * doc :
  70686. */
  70687. initParticles(): void;
  70688. /**
  70689. * This function does nothing. It may be overwritten to recycle a particle
  70690. * The PCS doesn't call this function, you can to call it
  70691. * doc :
  70692. * @param particle The particle to recycle
  70693. * @returns the recycled particle
  70694. */
  70695. recycleParticle(particle: CloudPoint): CloudPoint;
  70696. /**
  70697. * Updates a particle : this function should be overwritten by the user.
  70698. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  70699. * doc :
  70700. * @example : just set a particle position or velocity and recycle conditions
  70701. * @param particle The particle to update
  70702. * @returns the updated particle
  70703. */
  70704. updateParticle(particle: CloudPoint): CloudPoint;
  70705. /**
  70706. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  70707. * This does nothing and may be overwritten by the user.
  70708. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70709. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70710. * @param update the boolean update value actually passed to setParticles()
  70711. */
  70712. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70713. /**
  70714. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  70715. * This will be passed three parameters.
  70716. * This does nothing and may be overwritten by the user.
  70717. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70718. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70719. * @param update the boolean update value actually passed to setParticles()
  70720. */
  70721. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70722. }
  70723. }
  70724. declare module "babylonjs/Particles/cloudPoint" {
  70725. import { Nullable } from "babylonjs/types";
  70726. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  70727. import { Mesh } from "babylonjs/Meshes/mesh";
  70728. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  70729. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  70730. /**
  70731. * Represents one particle of a points cloud system.
  70732. */
  70733. export class CloudPoint {
  70734. /**
  70735. * particle global index
  70736. */
  70737. idx: number;
  70738. /**
  70739. * The color of the particle
  70740. */
  70741. color: Nullable<Color4>;
  70742. /**
  70743. * The world space position of the particle.
  70744. */
  70745. position: Vector3;
  70746. /**
  70747. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  70748. */
  70749. rotation: Vector3;
  70750. /**
  70751. * The world space rotation quaternion of the particle.
  70752. */
  70753. rotationQuaternion: Nullable<Quaternion>;
  70754. /**
  70755. * The uv of the particle.
  70756. */
  70757. uv: Nullable<Vector2>;
  70758. /**
  70759. * The current speed of the particle.
  70760. */
  70761. velocity: Vector3;
  70762. /**
  70763. * The pivot point in the particle local space.
  70764. */
  70765. pivot: Vector3;
  70766. /**
  70767. * Must the particle be translated from its pivot point in its local space ?
  70768. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70769. * Default : false
  70770. */
  70771. translateFromPivot: boolean;
  70772. /**
  70773. * Index of this particle in the global "positions" array (Internal use)
  70774. * @hidden
  70775. */
  70776. _pos: number;
  70777. /**
  70778. * @hidden Index of this particle in the global "indices" array (Internal use)
  70779. */
  70780. _ind: number;
  70781. /**
  70782. * Group this particle belongs to
  70783. */
  70784. _group: PointsGroup;
  70785. /**
  70786. * Group id of this particle
  70787. */
  70788. groupId: number;
  70789. /**
  70790. * Index of the particle in its group id (Internal use)
  70791. */
  70792. idxInGroup: number;
  70793. /**
  70794. * @hidden Particle BoundingInfo object (Internal use)
  70795. */
  70796. _boundingInfo: BoundingInfo;
  70797. /**
  70798. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70799. */
  70800. _pcs: PointsCloudSystem;
  70801. /**
  70802. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70803. */
  70804. _stillInvisible: boolean;
  70805. /**
  70806. * @hidden Last computed particle rotation matrix
  70807. */
  70808. _rotationMatrix: number[];
  70809. /**
  70810. * Parent particle Id, if any.
  70811. * Default null.
  70812. */
  70813. parentId: Nullable<number>;
  70814. /**
  70815. * @hidden Internal global position in the PCS.
  70816. */
  70817. _globalPosition: Vector3;
  70818. /**
  70819. * Creates a Point Cloud object.
  70820. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70821. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70822. * @param group (PointsGroup) is the group the particle belongs to
  70823. * @param groupId (integer) is the group identifier in the PCS.
  70824. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70825. * @param pcs defines the PCS it is associated to
  70826. */
  70827. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70828. /**
  70829. * get point size
  70830. */
  70831. get size(): Vector3;
  70832. /**
  70833. * Set point size
  70834. */
  70835. set size(scale: Vector3);
  70836. /**
  70837. * Legacy support, changed quaternion to rotationQuaternion
  70838. */
  70839. get quaternion(): Nullable<Quaternion>;
  70840. /**
  70841. * Legacy support, changed quaternion to rotationQuaternion
  70842. */
  70843. set quaternion(q: Nullable<Quaternion>);
  70844. /**
  70845. * Returns a boolean. True if the particle intersects a mesh, else false
  70846. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70847. * @param target is the object (point or mesh) what the intersection is computed against
  70848. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70849. * @returns true if it intersects
  70850. */
  70851. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70852. /**
  70853. * get the rotation matrix of the particle
  70854. * @hidden
  70855. */
  70856. getRotationMatrix(m: Matrix): void;
  70857. }
  70858. /**
  70859. * Represents a group of points in a points cloud system
  70860. * * PCS internal tool, don't use it manually.
  70861. */
  70862. export class PointsGroup {
  70863. /**
  70864. * The group id
  70865. * @hidden
  70866. */
  70867. groupID: number;
  70868. /**
  70869. * image data for group (internal use)
  70870. * @hidden
  70871. */
  70872. _groupImageData: Nullable<ArrayBufferView>;
  70873. /**
  70874. * Image Width (internal use)
  70875. * @hidden
  70876. */
  70877. _groupImgWidth: number;
  70878. /**
  70879. * Image Height (internal use)
  70880. * @hidden
  70881. */
  70882. _groupImgHeight: number;
  70883. /**
  70884. * Custom position function (internal use)
  70885. * @hidden
  70886. */
  70887. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70888. /**
  70889. * density per facet for surface points
  70890. * @hidden
  70891. */
  70892. _groupDensity: number[];
  70893. /**
  70894. * Only when points are colored by texture carries pointer to texture list array
  70895. * @hidden
  70896. */
  70897. _textureNb: number;
  70898. /**
  70899. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70900. * PCS internal tool, don't use it manually.
  70901. * @hidden
  70902. */
  70903. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70904. }
  70905. }
  70906. declare module "babylonjs/Particles/index" {
  70907. export * from "babylonjs/Particles/baseParticleSystem";
  70908. export * from "babylonjs/Particles/EmitterTypes/index";
  70909. export * from "babylonjs/Particles/gpuParticleSystem";
  70910. export * from "babylonjs/Particles/IParticleSystem";
  70911. export * from "babylonjs/Particles/particle";
  70912. export * from "babylonjs/Particles/particleHelper";
  70913. export * from "babylonjs/Particles/particleSystem";
  70914. import "babylonjs/Particles/particleSystemComponent";
  70915. export * from "babylonjs/Particles/particleSystemComponent";
  70916. export * from "babylonjs/Particles/particleSystemSet";
  70917. export * from "babylonjs/Particles/solidParticle";
  70918. export * from "babylonjs/Particles/solidParticleSystem";
  70919. export * from "babylonjs/Particles/cloudPoint";
  70920. export * from "babylonjs/Particles/pointsCloudSystem";
  70921. export * from "babylonjs/Particles/subEmitter";
  70922. }
  70923. declare module "babylonjs/Physics/physicsEngineComponent" {
  70924. import { Nullable } from "babylonjs/types";
  70925. import { Observable, Observer } from "babylonjs/Misc/observable";
  70926. import { Vector3 } from "babylonjs/Maths/math.vector";
  70927. import { Mesh } from "babylonjs/Meshes/mesh";
  70928. import { ISceneComponent } from "babylonjs/sceneComponent";
  70929. import { Scene } from "babylonjs/scene";
  70930. import { Node } from "babylonjs/node";
  70931. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70932. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70933. module "babylonjs/scene" {
  70934. interface Scene {
  70935. /** @hidden (Backing field) */
  70936. _physicsEngine: Nullable<IPhysicsEngine>;
  70937. /** @hidden */
  70938. _physicsTimeAccumulator: number;
  70939. /**
  70940. * Gets the current physics engine
  70941. * @returns a IPhysicsEngine or null if none attached
  70942. */
  70943. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70944. /**
  70945. * Enables physics to the current scene
  70946. * @param gravity defines the scene's gravity for the physics engine
  70947. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70948. * @return a boolean indicating if the physics engine was initialized
  70949. */
  70950. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70951. /**
  70952. * Disables and disposes the physics engine associated with the scene
  70953. */
  70954. disablePhysicsEngine(): void;
  70955. /**
  70956. * Gets a boolean indicating if there is an active physics engine
  70957. * @returns a boolean indicating if there is an active physics engine
  70958. */
  70959. isPhysicsEnabled(): boolean;
  70960. /**
  70961. * Deletes a physics compound impostor
  70962. * @param compound defines the compound to delete
  70963. */
  70964. deleteCompoundImpostor(compound: any): void;
  70965. /**
  70966. * An event triggered when physic simulation is about to be run
  70967. */
  70968. onBeforePhysicsObservable: Observable<Scene>;
  70969. /**
  70970. * An event triggered when physic simulation has been done
  70971. */
  70972. onAfterPhysicsObservable: Observable<Scene>;
  70973. }
  70974. }
  70975. module "babylonjs/Meshes/abstractMesh" {
  70976. interface AbstractMesh {
  70977. /** @hidden */
  70978. _physicsImpostor: Nullable<PhysicsImpostor>;
  70979. /**
  70980. * Gets or sets impostor used for physic simulation
  70981. * @see https://doc.babylonjs.com/features/physics_engine
  70982. */
  70983. physicsImpostor: Nullable<PhysicsImpostor>;
  70984. /**
  70985. * Gets the current physics impostor
  70986. * @see https://doc.babylonjs.com/features/physics_engine
  70987. * @returns a physics impostor or null
  70988. */
  70989. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70990. /** Apply a physic impulse to the mesh
  70991. * @param force defines the force to apply
  70992. * @param contactPoint defines where to apply the force
  70993. * @returns the current mesh
  70994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  70995. */
  70996. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70997. /**
  70998. * Creates a physic joint between two meshes
  70999. * @param otherMesh defines the other mesh to use
  71000. * @param pivot1 defines the pivot to use on this mesh
  71001. * @param pivot2 defines the pivot to use on the other mesh
  71002. * @param options defines additional options (can be plugin dependent)
  71003. * @returns the current mesh
  71004. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71005. */
  71006. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71007. /** @hidden */
  71008. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71009. }
  71010. }
  71011. /**
  71012. * Defines the physics engine scene component responsible to manage a physics engine
  71013. */
  71014. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71015. /**
  71016. * The component name helpful to identify the component in the list of scene components.
  71017. */
  71018. readonly name: string;
  71019. /**
  71020. * The scene the component belongs to.
  71021. */
  71022. scene: Scene;
  71023. /**
  71024. * Creates a new instance of the component for the given scene
  71025. * @param scene Defines the scene to register the component in
  71026. */
  71027. constructor(scene: Scene);
  71028. /**
  71029. * Registers the component in a given scene
  71030. */
  71031. register(): void;
  71032. /**
  71033. * Rebuilds the elements related to this component in case of
  71034. * context lost for instance.
  71035. */
  71036. rebuild(): void;
  71037. /**
  71038. * Disposes the component and the associated ressources
  71039. */
  71040. dispose(): void;
  71041. }
  71042. }
  71043. declare module "babylonjs/Physics/physicsHelper" {
  71044. import { Nullable } from "babylonjs/types";
  71045. import { Vector3 } from "babylonjs/Maths/math.vector";
  71046. import { Mesh } from "babylonjs/Meshes/mesh";
  71047. import { Scene } from "babylonjs/scene";
  71048. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71049. /**
  71050. * A helper for physics simulations
  71051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71052. */
  71053. export class PhysicsHelper {
  71054. private _scene;
  71055. private _physicsEngine;
  71056. /**
  71057. * Initializes the Physics helper
  71058. * @param scene Babylon.js scene
  71059. */
  71060. constructor(scene: Scene);
  71061. /**
  71062. * Applies a radial explosion impulse
  71063. * @param origin the origin of the explosion
  71064. * @param radiusOrEventOptions the radius or the options of radial explosion
  71065. * @param strength the explosion strength
  71066. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71067. * @returns A physics radial explosion event, or null
  71068. */
  71069. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71070. /**
  71071. * Applies a radial explosion force
  71072. * @param origin the origin of the explosion
  71073. * @param radiusOrEventOptions the radius or the options of radial explosion
  71074. * @param strength the explosion strength
  71075. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71076. * @returns A physics radial explosion event, or null
  71077. */
  71078. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71079. /**
  71080. * Creates a gravitational field
  71081. * @param origin the origin of the explosion
  71082. * @param radiusOrEventOptions the radius or the options of radial explosion
  71083. * @param strength the explosion strength
  71084. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71085. * @returns A physics gravitational field event, or null
  71086. */
  71087. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71088. /**
  71089. * Creates a physics updraft event
  71090. * @param origin the origin of the updraft
  71091. * @param radiusOrEventOptions the radius or the options of the updraft
  71092. * @param strength the strength of the updraft
  71093. * @param height the height of the updraft
  71094. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71095. * @returns A physics updraft event, or null
  71096. */
  71097. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71098. /**
  71099. * Creates a physics vortex event
  71100. * @param origin the of the vortex
  71101. * @param radiusOrEventOptions the radius or the options of the vortex
  71102. * @param strength the strength of the vortex
  71103. * @param height the height of the vortex
  71104. * @returns a Physics vortex event, or null
  71105. * A physics vortex event or null
  71106. */
  71107. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71108. }
  71109. /**
  71110. * Represents a physics radial explosion event
  71111. */
  71112. class PhysicsRadialExplosionEvent {
  71113. private _scene;
  71114. private _options;
  71115. private _sphere;
  71116. private _dataFetched;
  71117. /**
  71118. * Initializes a radial explosioin event
  71119. * @param _scene BabylonJS scene
  71120. * @param _options The options for the vortex event
  71121. */
  71122. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71123. /**
  71124. * Returns the data related to the radial explosion event (sphere).
  71125. * @returns The radial explosion event data
  71126. */
  71127. getData(): PhysicsRadialExplosionEventData;
  71128. /**
  71129. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71130. * @param impostor A physics imposter
  71131. * @param origin the origin of the explosion
  71132. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71133. */
  71134. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71135. /**
  71136. * Triggers affecterd impostors callbacks
  71137. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71138. */
  71139. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71140. /**
  71141. * Disposes the sphere.
  71142. * @param force Specifies if the sphere should be disposed by force
  71143. */
  71144. dispose(force?: boolean): void;
  71145. /*** Helpers ***/
  71146. private _prepareSphere;
  71147. private _intersectsWithSphere;
  71148. }
  71149. /**
  71150. * Represents a gravitational field event
  71151. */
  71152. class PhysicsGravitationalFieldEvent {
  71153. private _physicsHelper;
  71154. private _scene;
  71155. private _origin;
  71156. private _options;
  71157. private _tickCallback;
  71158. private _sphere;
  71159. private _dataFetched;
  71160. /**
  71161. * Initializes the physics gravitational field event
  71162. * @param _physicsHelper A physics helper
  71163. * @param _scene BabylonJS scene
  71164. * @param _origin The origin position of the gravitational field event
  71165. * @param _options The options for the vortex event
  71166. */
  71167. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71168. /**
  71169. * Returns the data related to the gravitational field event (sphere).
  71170. * @returns A gravitational field event
  71171. */
  71172. getData(): PhysicsGravitationalFieldEventData;
  71173. /**
  71174. * Enables the gravitational field.
  71175. */
  71176. enable(): void;
  71177. /**
  71178. * Disables the gravitational field.
  71179. */
  71180. disable(): void;
  71181. /**
  71182. * Disposes the sphere.
  71183. * @param force The force to dispose from the gravitational field event
  71184. */
  71185. dispose(force?: boolean): void;
  71186. private _tick;
  71187. }
  71188. /**
  71189. * Represents a physics updraft event
  71190. */
  71191. class PhysicsUpdraftEvent {
  71192. private _scene;
  71193. private _origin;
  71194. private _options;
  71195. private _physicsEngine;
  71196. private _originTop;
  71197. private _originDirection;
  71198. private _tickCallback;
  71199. private _cylinder;
  71200. private _cylinderPosition;
  71201. private _dataFetched;
  71202. /**
  71203. * Initializes the physics updraft event
  71204. * @param _scene BabylonJS scene
  71205. * @param _origin The origin position of the updraft
  71206. * @param _options The options for the updraft event
  71207. */
  71208. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71209. /**
  71210. * Returns the data related to the updraft event (cylinder).
  71211. * @returns A physics updraft event
  71212. */
  71213. getData(): PhysicsUpdraftEventData;
  71214. /**
  71215. * Enables the updraft.
  71216. */
  71217. enable(): void;
  71218. /**
  71219. * Disables the updraft.
  71220. */
  71221. disable(): void;
  71222. /**
  71223. * Disposes the cylinder.
  71224. * @param force Specifies if the updraft should be disposed by force
  71225. */
  71226. dispose(force?: boolean): void;
  71227. private getImpostorHitData;
  71228. private _tick;
  71229. /*** Helpers ***/
  71230. private _prepareCylinder;
  71231. private _intersectsWithCylinder;
  71232. }
  71233. /**
  71234. * Represents a physics vortex event
  71235. */
  71236. class PhysicsVortexEvent {
  71237. private _scene;
  71238. private _origin;
  71239. private _options;
  71240. private _physicsEngine;
  71241. private _originTop;
  71242. private _tickCallback;
  71243. private _cylinder;
  71244. private _cylinderPosition;
  71245. private _dataFetched;
  71246. /**
  71247. * Initializes the physics vortex event
  71248. * @param _scene The BabylonJS scene
  71249. * @param _origin The origin position of the vortex
  71250. * @param _options The options for the vortex event
  71251. */
  71252. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71253. /**
  71254. * Returns the data related to the vortex event (cylinder).
  71255. * @returns The physics vortex event data
  71256. */
  71257. getData(): PhysicsVortexEventData;
  71258. /**
  71259. * Enables the vortex.
  71260. */
  71261. enable(): void;
  71262. /**
  71263. * Disables the cortex.
  71264. */
  71265. disable(): void;
  71266. /**
  71267. * Disposes the sphere.
  71268. * @param force
  71269. */
  71270. dispose(force?: boolean): void;
  71271. private getImpostorHitData;
  71272. private _tick;
  71273. /*** Helpers ***/
  71274. private _prepareCylinder;
  71275. private _intersectsWithCylinder;
  71276. }
  71277. /**
  71278. * Options fot the radial explosion event
  71279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71280. */
  71281. export class PhysicsRadialExplosionEventOptions {
  71282. /**
  71283. * The radius of the sphere for the radial explosion.
  71284. */
  71285. radius: number;
  71286. /**
  71287. * The strenth of the explosion.
  71288. */
  71289. strength: number;
  71290. /**
  71291. * The strenght of the force in correspondence to the distance of the affected object
  71292. */
  71293. falloff: PhysicsRadialImpulseFalloff;
  71294. /**
  71295. * Sphere options for the radial explosion.
  71296. */
  71297. sphere: {
  71298. segments: number;
  71299. diameter: number;
  71300. };
  71301. /**
  71302. * Sphere options for the radial explosion.
  71303. */
  71304. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71305. }
  71306. /**
  71307. * Options fot the updraft event
  71308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71309. */
  71310. export class PhysicsUpdraftEventOptions {
  71311. /**
  71312. * The radius of the cylinder for the vortex
  71313. */
  71314. radius: number;
  71315. /**
  71316. * The strenth of the updraft.
  71317. */
  71318. strength: number;
  71319. /**
  71320. * The height of the cylinder for the updraft.
  71321. */
  71322. height: number;
  71323. /**
  71324. * The mode for the the updraft.
  71325. */
  71326. updraftMode: PhysicsUpdraftMode;
  71327. }
  71328. /**
  71329. * Options fot the vortex event
  71330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71331. */
  71332. export class PhysicsVortexEventOptions {
  71333. /**
  71334. * The radius of the cylinder for the vortex
  71335. */
  71336. radius: number;
  71337. /**
  71338. * The strenth of the vortex.
  71339. */
  71340. strength: number;
  71341. /**
  71342. * The height of the cylinder for the vortex.
  71343. */
  71344. height: number;
  71345. /**
  71346. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71347. */
  71348. centripetalForceThreshold: number;
  71349. /**
  71350. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71351. */
  71352. centripetalForceMultiplier: number;
  71353. /**
  71354. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71355. */
  71356. centrifugalForceMultiplier: number;
  71357. /**
  71358. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  71359. */
  71360. updraftForceMultiplier: number;
  71361. }
  71362. /**
  71363. * The strenght of the force in correspondence to the distance of the affected object
  71364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71365. */
  71366. export enum PhysicsRadialImpulseFalloff {
  71367. /** Defines that impulse is constant in strength across it's whole radius */
  71368. Constant = 0,
  71369. /** Defines that impulse gets weaker if it's further from the origin */
  71370. Linear = 1
  71371. }
  71372. /**
  71373. * The strength of the force in correspondence to the distance of the affected object
  71374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71375. */
  71376. export enum PhysicsUpdraftMode {
  71377. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  71378. Center = 0,
  71379. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  71380. Perpendicular = 1
  71381. }
  71382. /**
  71383. * Interface for a physics hit data
  71384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71385. */
  71386. export interface PhysicsHitData {
  71387. /**
  71388. * The force applied at the contact point
  71389. */
  71390. force: Vector3;
  71391. /**
  71392. * The contact point
  71393. */
  71394. contactPoint: Vector3;
  71395. /**
  71396. * The distance from the origin to the contact point
  71397. */
  71398. distanceFromOrigin: number;
  71399. }
  71400. /**
  71401. * Interface for radial explosion event data
  71402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71403. */
  71404. export interface PhysicsRadialExplosionEventData {
  71405. /**
  71406. * A sphere used for the radial explosion event
  71407. */
  71408. sphere: Mesh;
  71409. }
  71410. /**
  71411. * Interface for gravitational field event data
  71412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71413. */
  71414. export interface PhysicsGravitationalFieldEventData {
  71415. /**
  71416. * A sphere mesh used for the gravitational field event
  71417. */
  71418. sphere: Mesh;
  71419. }
  71420. /**
  71421. * Interface for updraft event data
  71422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71423. */
  71424. export interface PhysicsUpdraftEventData {
  71425. /**
  71426. * A cylinder used for the updraft event
  71427. */
  71428. cylinder: Mesh;
  71429. }
  71430. /**
  71431. * Interface for vortex event data
  71432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71433. */
  71434. export interface PhysicsVortexEventData {
  71435. /**
  71436. * A cylinder used for the vortex event
  71437. */
  71438. cylinder: Mesh;
  71439. }
  71440. /**
  71441. * Interface for an affected physics impostor
  71442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71443. */
  71444. export interface PhysicsAffectedImpostorWithData {
  71445. /**
  71446. * The impostor affected by the effect
  71447. */
  71448. impostor: PhysicsImpostor;
  71449. /**
  71450. * The data about the hit/horce from the explosion
  71451. */
  71452. hitData: PhysicsHitData;
  71453. }
  71454. }
  71455. declare module "babylonjs/Physics/Plugins/index" {
  71456. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  71457. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  71458. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  71459. }
  71460. declare module "babylonjs/Physics/index" {
  71461. export * from "babylonjs/Physics/IPhysicsEngine";
  71462. export * from "babylonjs/Physics/physicsEngine";
  71463. export * from "babylonjs/Physics/physicsEngineComponent";
  71464. export * from "babylonjs/Physics/physicsHelper";
  71465. export * from "babylonjs/Physics/physicsImpostor";
  71466. export * from "babylonjs/Physics/physicsJoint";
  71467. export * from "babylonjs/Physics/Plugins/index";
  71468. }
  71469. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  71470. /** @hidden */
  71471. export var blackAndWhitePixelShader: {
  71472. name: string;
  71473. shader: string;
  71474. };
  71475. }
  71476. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  71477. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71478. import { Camera } from "babylonjs/Cameras/camera";
  71479. import { Engine } from "babylonjs/Engines/engine";
  71480. import "babylonjs/Shaders/blackAndWhite.fragment";
  71481. /**
  71482. * Post process used to render in black and white
  71483. */
  71484. export class BlackAndWhitePostProcess extends PostProcess {
  71485. /**
  71486. * Linear about to convert he result to black and white (default: 1)
  71487. */
  71488. degree: number;
  71489. /**
  71490. * Creates a black and white post process
  71491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  71492. * @param name The name of the effect.
  71493. * @param options The required width/height ratio to downsize to before computing the render pass.
  71494. * @param camera The camera to apply the render pass to.
  71495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71496. * @param engine The engine which the post process will be applied. (default: current engine)
  71497. * @param reusable If the post process can be reused on the same frame. (default: false)
  71498. */
  71499. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71500. }
  71501. }
  71502. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  71503. import { Nullable } from "babylonjs/types";
  71504. import { Camera } from "babylonjs/Cameras/camera";
  71505. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71506. import { Engine } from "babylonjs/Engines/engine";
  71507. /**
  71508. * This represents a set of one or more post processes in Babylon.
  71509. * A post process can be used to apply a shader to a texture after it is rendered.
  71510. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71511. */
  71512. export class PostProcessRenderEffect {
  71513. private _postProcesses;
  71514. private _getPostProcesses;
  71515. private _singleInstance;
  71516. private _cameras;
  71517. private _indicesForCamera;
  71518. /**
  71519. * Name of the effect
  71520. * @hidden
  71521. */
  71522. _name: string;
  71523. /**
  71524. * Instantiates a post process render effect.
  71525. * A post process can be used to apply a shader to a texture after it is rendered.
  71526. * @param engine The engine the effect is tied to
  71527. * @param name The name of the effect
  71528. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  71529. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  71530. */
  71531. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  71532. /**
  71533. * Checks if all the post processes in the effect are supported.
  71534. */
  71535. get isSupported(): boolean;
  71536. /**
  71537. * Updates the current state of the effect
  71538. * @hidden
  71539. */
  71540. _update(): void;
  71541. /**
  71542. * Attaches the effect on cameras
  71543. * @param cameras The camera to attach to.
  71544. * @hidden
  71545. */
  71546. _attachCameras(cameras: Camera): void;
  71547. /**
  71548. * Attaches the effect on cameras
  71549. * @param cameras The camera to attach to.
  71550. * @hidden
  71551. */
  71552. _attachCameras(cameras: Camera[]): void;
  71553. /**
  71554. * Detaches the effect on cameras
  71555. * @param cameras The camera to detatch from.
  71556. * @hidden
  71557. */
  71558. _detachCameras(cameras: Camera): void;
  71559. /**
  71560. * Detatches the effect on cameras
  71561. * @param cameras The camera to detatch from.
  71562. * @hidden
  71563. */
  71564. _detachCameras(cameras: Camera[]): void;
  71565. /**
  71566. * Enables the effect on given cameras
  71567. * @param cameras The camera to enable.
  71568. * @hidden
  71569. */
  71570. _enable(cameras: Camera): void;
  71571. /**
  71572. * Enables the effect on given cameras
  71573. * @param cameras The camera to enable.
  71574. * @hidden
  71575. */
  71576. _enable(cameras: Nullable<Camera[]>): void;
  71577. /**
  71578. * Disables the effect on the given cameras
  71579. * @param cameras The camera to disable.
  71580. * @hidden
  71581. */
  71582. _disable(cameras: Camera): void;
  71583. /**
  71584. * Disables the effect on the given cameras
  71585. * @param cameras The camera to disable.
  71586. * @hidden
  71587. */
  71588. _disable(cameras: Nullable<Camera[]>): void;
  71589. /**
  71590. * Gets a list of the post processes contained in the effect.
  71591. * @param camera The camera to get the post processes on.
  71592. * @returns The list of the post processes in the effect.
  71593. */
  71594. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  71595. }
  71596. }
  71597. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  71598. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71599. /** @hidden */
  71600. export var extractHighlightsPixelShader: {
  71601. name: string;
  71602. shader: string;
  71603. };
  71604. }
  71605. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  71606. import { Nullable } from "babylonjs/types";
  71607. import { Camera } from "babylonjs/Cameras/camera";
  71608. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71609. import { Engine } from "babylonjs/Engines/engine";
  71610. import "babylonjs/Shaders/extractHighlights.fragment";
  71611. /**
  71612. * 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.
  71613. */
  71614. export class ExtractHighlightsPostProcess extends PostProcess {
  71615. /**
  71616. * The luminance threshold, pixels below this value will be set to black.
  71617. */
  71618. threshold: number;
  71619. /** @hidden */
  71620. _exposure: number;
  71621. /**
  71622. * Post process which has the input texture to be used when performing highlight extraction
  71623. * @hidden
  71624. */
  71625. _inputPostProcess: Nullable<PostProcess>;
  71626. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71627. }
  71628. }
  71629. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  71630. /** @hidden */
  71631. export var bloomMergePixelShader: {
  71632. name: string;
  71633. shader: string;
  71634. };
  71635. }
  71636. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  71637. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71638. import { Nullable } from "babylonjs/types";
  71639. import { Engine } from "babylonjs/Engines/engine";
  71640. import { Camera } from "babylonjs/Cameras/camera";
  71641. import "babylonjs/Shaders/bloomMerge.fragment";
  71642. /**
  71643. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71644. */
  71645. export class BloomMergePostProcess extends PostProcess {
  71646. /** Weight of the bloom to be added to the original input. */
  71647. weight: number;
  71648. /**
  71649. * Creates a new instance of @see BloomMergePostProcess
  71650. * @param name The name of the effect.
  71651. * @param originalFromInput Post process which's input will be used for the merge.
  71652. * @param blurred Blurred highlights post process which's output will be used.
  71653. * @param weight Weight of the bloom to be added to the original input.
  71654. * @param options The required width/height ratio to downsize to before computing the render pass.
  71655. * @param camera The camera to apply the render pass to.
  71656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71657. * @param engine The engine which the post process will be applied. (default: current engine)
  71658. * @param reusable If the post process can be reused on the same frame. (default: false)
  71659. * @param textureType Type of textures used when performing the post process. (default: 0)
  71660. * @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)
  71661. */
  71662. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  71663. /** Weight of the bloom to be added to the original input. */
  71664. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71665. }
  71666. }
  71667. declare module "babylonjs/PostProcesses/bloomEffect" {
  71668. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71669. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71670. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71671. import { Camera } from "babylonjs/Cameras/camera";
  71672. import { Scene } from "babylonjs/scene";
  71673. /**
  71674. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  71675. */
  71676. export class BloomEffect extends PostProcessRenderEffect {
  71677. private bloomScale;
  71678. /**
  71679. * @hidden Internal
  71680. */
  71681. _effects: Array<PostProcess>;
  71682. /**
  71683. * @hidden Internal
  71684. */
  71685. _downscale: ExtractHighlightsPostProcess;
  71686. private _blurX;
  71687. private _blurY;
  71688. private _merge;
  71689. /**
  71690. * The luminance threshold to find bright areas of the image to bloom.
  71691. */
  71692. get threshold(): number;
  71693. set threshold(value: number);
  71694. /**
  71695. * The strength of the bloom.
  71696. */
  71697. get weight(): number;
  71698. set weight(value: number);
  71699. /**
  71700. * Specifies the size of the bloom blur kernel, relative to the final output size
  71701. */
  71702. get kernel(): number;
  71703. set kernel(value: number);
  71704. /**
  71705. * Creates a new instance of @see BloomEffect
  71706. * @param scene The scene the effect belongs to.
  71707. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  71708. * @param bloomKernel The size of the kernel to be used when applying the blur.
  71709. * @param bloomWeight The the strength of bloom.
  71710. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71711. * @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)
  71712. */
  71713. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  71714. /**
  71715. * Disposes each of the internal effects for a given camera.
  71716. * @param camera The camera to dispose the effect on.
  71717. */
  71718. disposeEffects(camera: Camera): void;
  71719. /**
  71720. * @hidden Internal
  71721. */
  71722. _updateEffects(): void;
  71723. /**
  71724. * Internal
  71725. * @returns if all the contained post processes are ready.
  71726. * @hidden
  71727. */
  71728. _isReady(): boolean;
  71729. }
  71730. }
  71731. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  71732. /** @hidden */
  71733. export var chromaticAberrationPixelShader: {
  71734. name: string;
  71735. shader: string;
  71736. };
  71737. }
  71738. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  71739. import { Vector2 } from "babylonjs/Maths/math.vector";
  71740. import { Nullable } from "babylonjs/types";
  71741. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71742. import { Camera } from "babylonjs/Cameras/camera";
  71743. import { Engine } from "babylonjs/Engines/engine";
  71744. import "babylonjs/Shaders/chromaticAberration.fragment";
  71745. /**
  71746. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  71747. */
  71748. export class ChromaticAberrationPostProcess extends PostProcess {
  71749. /**
  71750. * The amount of seperation of rgb channels (default: 30)
  71751. */
  71752. aberrationAmount: number;
  71753. /**
  71754. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71755. */
  71756. radialIntensity: number;
  71757. /**
  71758. * 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))
  71759. */
  71760. direction: Vector2;
  71761. /**
  71762. * 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))
  71763. */
  71764. centerPosition: Vector2;
  71765. /**
  71766. * Creates a new instance ChromaticAberrationPostProcess
  71767. * @param name The name of the effect.
  71768. * @param screenWidth The width of the screen to apply the effect on.
  71769. * @param screenHeight The height of the screen to apply the effect on.
  71770. * @param options The required width/height ratio to downsize to before computing the render pass.
  71771. * @param camera The camera to apply the render pass to.
  71772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71773. * @param engine The engine which the post process will be applied. (default: current engine)
  71774. * @param reusable If the post process can be reused on the same frame. (default: false)
  71775. * @param textureType Type of textures used when performing the post process. (default: 0)
  71776. * @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)
  71777. */
  71778. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71779. }
  71780. }
  71781. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71782. /** @hidden */
  71783. export var circleOfConfusionPixelShader: {
  71784. name: string;
  71785. shader: string;
  71786. };
  71787. }
  71788. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71789. import { Nullable } from "babylonjs/types";
  71790. import { Engine } from "babylonjs/Engines/engine";
  71791. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71792. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71793. import { Camera } from "babylonjs/Cameras/camera";
  71794. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71795. /**
  71796. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71797. */
  71798. export class CircleOfConfusionPostProcess extends PostProcess {
  71799. /**
  71800. * 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.
  71801. */
  71802. lensSize: number;
  71803. /**
  71804. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71805. */
  71806. fStop: number;
  71807. /**
  71808. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71809. */
  71810. focusDistance: number;
  71811. /**
  71812. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71813. */
  71814. focalLength: number;
  71815. private _depthTexture;
  71816. /**
  71817. * Creates a new instance CircleOfConfusionPostProcess
  71818. * @param name The name of the effect.
  71819. * @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.
  71820. * @param options The required width/height ratio to downsize to before computing the render pass.
  71821. * @param camera The camera to apply the render pass to.
  71822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71823. * @param engine The engine which the post process will be applied. (default: current engine)
  71824. * @param reusable If the post process can be reused on the same frame. (default: false)
  71825. * @param textureType Type of textures used when performing the post process. (default: 0)
  71826. * @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)
  71827. */
  71828. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71829. /**
  71830. * 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.
  71831. */
  71832. set depthTexture(value: RenderTargetTexture);
  71833. }
  71834. }
  71835. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71836. /** @hidden */
  71837. export var colorCorrectionPixelShader: {
  71838. name: string;
  71839. shader: string;
  71840. };
  71841. }
  71842. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71843. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71844. import { Engine } from "babylonjs/Engines/engine";
  71845. import { Camera } from "babylonjs/Cameras/camera";
  71846. import "babylonjs/Shaders/colorCorrection.fragment";
  71847. /**
  71848. *
  71849. * This post-process allows the modification of rendered colors by using
  71850. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71851. *
  71852. * The object needs to be provided an url to a texture containing the color
  71853. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71854. * Use an image editing software to tweak the LUT to match your needs.
  71855. *
  71856. * For an example of a color LUT, see here:
  71857. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71858. * For explanations on color grading, see here:
  71859. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71860. *
  71861. */
  71862. export class ColorCorrectionPostProcess extends PostProcess {
  71863. private _colorTableTexture;
  71864. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71865. }
  71866. }
  71867. declare module "babylonjs/Shaders/convolution.fragment" {
  71868. /** @hidden */
  71869. export var convolutionPixelShader: {
  71870. name: string;
  71871. shader: string;
  71872. };
  71873. }
  71874. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71875. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71876. import { Nullable } from "babylonjs/types";
  71877. import { Camera } from "babylonjs/Cameras/camera";
  71878. import { Engine } from "babylonjs/Engines/engine";
  71879. import "babylonjs/Shaders/convolution.fragment";
  71880. /**
  71881. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71882. * input texture to perform effects such as edge detection or sharpening
  71883. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71884. */
  71885. export class ConvolutionPostProcess extends PostProcess {
  71886. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71887. kernel: number[];
  71888. /**
  71889. * Creates a new instance ConvolutionPostProcess
  71890. * @param name The name of the effect.
  71891. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71892. * @param options The required width/height ratio to downsize to before computing the render pass.
  71893. * @param camera The camera to apply the render pass to.
  71894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71895. * @param engine The engine which the post process will be applied. (default: current engine)
  71896. * @param reusable If the post process can be reused on the same frame. (default: false)
  71897. * @param textureType Type of textures used when performing the post process. (default: 0)
  71898. */
  71899. constructor(name: string,
  71900. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71901. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71902. /**
  71903. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71904. */
  71905. static EdgeDetect0Kernel: number[];
  71906. /**
  71907. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71908. */
  71909. static EdgeDetect1Kernel: number[];
  71910. /**
  71911. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71912. */
  71913. static EdgeDetect2Kernel: number[];
  71914. /**
  71915. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71916. */
  71917. static SharpenKernel: number[];
  71918. /**
  71919. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71920. */
  71921. static EmbossKernel: number[];
  71922. /**
  71923. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71924. */
  71925. static GaussianKernel: number[];
  71926. }
  71927. }
  71928. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71929. import { Nullable } from "babylonjs/types";
  71930. import { Vector2 } from "babylonjs/Maths/math.vector";
  71931. import { Camera } from "babylonjs/Cameras/camera";
  71932. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71933. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71934. import { Engine } from "babylonjs/Engines/engine";
  71935. import { Scene } from "babylonjs/scene";
  71936. /**
  71937. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71938. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71939. * based on samples that have a large difference in distance than the center pixel.
  71940. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71941. */
  71942. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71943. direction: Vector2;
  71944. /**
  71945. * Creates a new instance CircleOfConfusionPostProcess
  71946. * @param name The name of the effect.
  71947. * @param scene The scene the effect belongs to.
  71948. * @param direction The direction the blur should be applied.
  71949. * @param kernel The size of the kernel used to blur.
  71950. * @param options The required width/height ratio to downsize to before computing the render pass.
  71951. * @param camera The camera to apply the render pass to.
  71952. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71953. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71955. * @param engine The engine which the post process will be applied. (default: current engine)
  71956. * @param reusable If the post process can be reused on the same frame. (default: false)
  71957. * @param textureType Type of textures used when performing the post process. (default: 0)
  71958. * @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)
  71959. */
  71960. 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);
  71961. }
  71962. }
  71963. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71964. /** @hidden */
  71965. export var depthOfFieldMergePixelShader: {
  71966. name: string;
  71967. shader: string;
  71968. };
  71969. }
  71970. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71971. import { Nullable } from "babylonjs/types";
  71972. import { Camera } from "babylonjs/Cameras/camera";
  71973. import { Effect } from "babylonjs/Materials/effect";
  71974. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71975. import { Engine } from "babylonjs/Engines/engine";
  71976. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71977. /**
  71978. * Options to be set when merging outputs from the default pipeline.
  71979. */
  71980. export class DepthOfFieldMergePostProcessOptions {
  71981. /**
  71982. * The original image to merge on top of
  71983. */
  71984. originalFromInput: PostProcess;
  71985. /**
  71986. * Parameters to perform the merge of the depth of field effect
  71987. */
  71988. depthOfField?: {
  71989. circleOfConfusion: PostProcess;
  71990. blurSteps: Array<PostProcess>;
  71991. };
  71992. /**
  71993. * Parameters to perform the merge of bloom effect
  71994. */
  71995. bloom?: {
  71996. blurred: PostProcess;
  71997. weight: number;
  71998. };
  71999. }
  72000. /**
  72001. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72002. */
  72003. export class DepthOfFieldMergePostProcess extends PostProcess {
  72004. private blurSteps;
  72005. /**
  72006. * Creates a new instance of DepthOfFieldMergePostProcess
  72007. * @param name The name of the effect.
  72008. * @param originalFromInput Post process which's input will be used for the merge.
  72009. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72010. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72011. * @param options The required width/height ratio to downsize to before computing the render pass.
  72012. * @param camera The camera to apply the render pass to.
  72013. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72014. * @param engine The engine which the post process will be applied. (default: current engine)
  72015. * @param reusable If the post process can be reused on the same frame. (default: false)
  72016. * @param textureType Type of textures used when performing the post process. (default: 0)
  72017. * @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)
  72018. */
  72019. 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);
  72020. /**
  72021. * Updates the effect with the current post process compile time values and recompiles the shader.
  72022. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72023. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72024. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72025. * @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
  72026. * @param onCompiled Called when the shader has been compiled.
  72027. * @param onError Called if there is an error when compiling a shader.
  72028. */
  72029. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72030. }
  72031. }
  72032. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72033. import { Nullable } from "babylonjs/types";
  72034. import { Camera } from "babylonjs/Cameras/camera";
  72035. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72036. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72037. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72038. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72039. import { Scene } from "babylonjs/scene";
  72040. /**
  72041. * Specifies the level of max blur that should be applied when using the depth of field effect
  72042. */
  72043. export enum DepthOfFieldEffectBlurLevel {
  72044. /**
  72045. * Subtle blur
  72046. */
  72047. Low = 0,
  72048. /**
  72049. * Medium blur
  72050. */
  72051. Medium = 1,
  72052. /**
  72053. * Large blur
  72054. */
  72055. High = 2
  72056. }
  72057. /**
  72058. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72059. */
  72060. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72061. private _circleOfConfusion;
  72062. /**
  72063. * @hidden Internal, blurs from high to low
  72064. */
  72065. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72066. private _depthOfFieldBlurY;
  72067. private _dofMerge;
  72068. /**
  72069. * @hidden Internal post processes in depth of field effect
  72070. */
  72071. _effects: Array<PostProcess>;
  72072. /**
  72073. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72074. */
  72075. set focalLength(value: number);
  72076. get focalLength(): number;
  72077. /**
  72078. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72079. */
  72080. set fStop(value: number);
  72081. get fStop(): number;
  72082. /**
  72083. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72084. */
  72085. set focusDistance(value: number);
  72086. get focusDistance(): number;
  72087. /**
  72088. * 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.
  72089. */
  72090. set lensSize(value: number);
  72091. get lensSize(): number;
  72092. /**
  72093. * Creates a new instance DepthOfFieldEffect
  72094. * @param scene The scene the effect belongs to.
  72095. * @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.
  72096. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72097. * @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)
  72098. */
  72099. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72100. /**
  72101. * Get the current class name of the current effet
  72102. * @returns "DepthOfFieldEffect"
  72103. */
  72104. getClassName(): string;
  72105. /**
  72106. * 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.
  72107. */
  72108. set depthTexture(value: RenderTargetTexture);
  72109. /**
  72110. * Disposes each of the internal effects for a given camera.
  72111. * @param camera The camera to dispose the effect on.
  72112. */
  72113. disposeEffects(camera: Camera): void;
  72114. /**
  72115. * @hidden Internal
  72116. */
  72117. _updateEffects(): void;
  72118. /**
  72119. * Internal
  72120. * @returns if all the contained post processes are ready.
  72121. * @hidden
  72122. */
  72123. _isReady(): boolean;
  72124. }
  72125. }
  72126. declare module "babylonjs/Shaders/displayPass.fragment" {
  72127. /** @hidden */
  72128. export var displayPassPixelShader: {
  72129. name: string;
  72130. shader: string;
  72131. };
  72132. }
  72133. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72134. import { Nullable } from "babylonjs/types";
  72135. import { Camera } from "babylonjs/Cameras/camera";
  72136. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72137. import { Engine } from "babylonjs/Engines/engine";
  72138. import "babylonjs/Shaders/displayPass.fragment";
  72139. /**
  72140. * DisplayPassPostProcess which produces an output the same as it's input
  72141. */
  72142. export class DisplayPassPostProcess extends PostProcess {
  72143. /**
  72144. * Creates the DisplayPassPostProcess
  72145. * @param name The name of the effect.
  72146. * @param options The required width/height ratio to downsize to before computing the render pass.
  72147. * @param camera The camera to apply the render pass to.
  72148. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72149. * @param engine The engine which the post process will be applied. (default: current engine)
  72150. * @param reusable If the post process can be reused on the same frame. (default: false)
  72151. */
  72152. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72153. }
  72154. }
  72155. declare module "babylonjs/Shaders/filter.fragment" {
  72156. /** @hidden */
  72157. export var filterPixelShader: {
  72158. name: string;
  72159. shader: string;
  72160. };
  72161. }
  72162. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72163. import { Nullable } from "babylonjs/types";
  72164. import { Matrix } from "babylonjs/Maths/math.vector";
  72165. import { Camera } from "babylonjs/Cameras/camera";
  72166. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72167. import { Engine } from "babylonjs/Engines/engine";
  72168. import "babylonjs/Shaders/filter.fragment";
  72169. /**
  72170. * Applies a kernel filter to the image
  72171. */
  72172. export class FilterPostProcess extends PostProcess {
  72173. /** The matrix to be applied to the image */
  72174. kernelMatrix: Matrix;
  72175. /**
  72176. *
  72177. * @param name The name of the effect.
  72178. * @param kernelMatrix The matrix to be applied to the image
  72179. * @param options The required width/height ratio to downsize to before computing the render pass.
  72180. * @param camera The camera to apply the render pass to.
  72181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72182. * @param engine The engine which the post process will be applied. (default: current engine)
  72183. * @param reusable If the post process can be reused on the same frame. (default: false)
  72184. */
  72185. constructor(name: string,
  72186. /** The matrix to be applied to the image */
  72187. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72188. }
  72189. }
  72190. declare module "babylonjs/Shaders/fxaa.fragment" {
  72191. /** @hidden */
  72192. export var fxaaPixelShader: {
  72193. name: string;
  72194. shader: string;
  72195. };
  72196. }
  72197. declare module "babylonjs/Shaders/fxaa.vertex" {
  72198. /** @hidden */
  72199. export var fxaaVertexShader: {
  72200. name: string;
  72201. shader: string;
  72202. };
  72203. }
  72204. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72205. import { Nullable } from "babylonjs/types";
  72206. import { Camera } from "babylonjs/Cameras/camera";
  72207. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72208. import { Engine } from "babylonjs/Engines/engine";
  72209. import "babylonjs/Shaders/fxaa.fragment";
  72210. import "babylonjs/Shaders/fxaa.vertex";
  72211. /**
  72212. * Fxaa post process
  72213. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72214. */
  72215. export class FxaaPostProcess extends PostProcess {
  72216. /** @hidden */
  72217. texelWidth: number;
  72218. /** @hidden */
  72219. texelHeight: number;
  72220. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72221. private _getDefines;
  72222. }
  72223. }
  72224. declare module "babylonjs/Shaders/grain.fragment" {
  72225. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72226. /** @hidden */
  72227. export var grainPixelShader: {
  72228. name: string;
  72229. shader: string;
  72230. };
  72231. }
  72232. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72233. import { Nullable } from "babylonjs/types";
  72234. import { Camera } from "babylonjs/Cameras/camera";
  72235. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72236. import { Engine } from "babylonjs/Engines/engine";
  72237. import "babylonjs/Shaders/grain.fragment";
  72238. /**
  72239. * The GrainPostProcess adds noise to the image at mid luminance levels
  72240. */
  72241. export class GrainPostProcess extends PostProcess {
  72242. /**
  72243. * The intensity of the grain added (default: 30)
  72244. */
  72245. intensity: number;
  72246. /**
  72247. * If the grain should be randomized on every frame
  72248. */
  72249. animated: boolean;
  72250. /**
  72251. * Creates a new instance of @see GrainPostProcess
  72252. * @param name The name of the effect.
  72253. * @param options The required width/height ratio to downsize to before computing the render pass.
  72254. * @param camera The camera to apply the render pass to.
  72255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72256. * @param engine The engine which the post process will be applied. (default: current engine)
  72257. * @param reusable If the post process can be reused on the same frame. (default: false)
  72258. * @param textureType Type of textures used when performing the post process. (default: 0)
  72259. * @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)
  72260. */
  72261. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72262. }
  72263. }
  72264. declare module "babylonjs/Shaders/highlights.fragment" {
  72265. /** @hidden */
  72266. export var highlightsPixelShader: {
  72267. name: string;
  72268. shader: string;
  72269. };
  72270. }
  72271. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72272. import { Nullable } from "babylonjs/types";
  72273. import { Camera } from "babylonjs/Cameras/camera";
  72274. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72275. import { Engine } from "babylonjs/Engines/engine";
  72276. import "babylonjs/Shaders/highlights.fragment";
  72277. /**
  72278. * Extracts highlights from the image
  72279. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72280. */
  72281. export class HighlightsPostProcess extends PostProcess {
  72282. /**
  72283. * Extracts highlights from the image
  72284. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72285. * @param name The name of the effect.
  72286. * @param options The required width/height ratio to downsize to before computing the render pass.
  72287. * @param camera The camera to apply the render pass to.
  72288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72289. * @param engine The engine which the post process will be applied. (default: current engine)
  72290. * @param reusable If the post process can be reused on the same frame. (default: false)
  72291. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72292. */
  72293. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72294. }
  72295. }
  72296. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72297. /** @hidden */
  72298. export var mrtFragmentDeclaration: {
  72299. name: string;
  72300. shader: string;
  72301. };
  72302. }
  72303. declare module "babylonjs/Shaders/geometry.fragment" {
  72304. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72305. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72306. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72307. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72308. /** @hidden */
  72309. export var geometryPixelShader: {
  72310. name: string;
  72311. shader: string;
  72312. };
  72313. }
  72314. declare module "babylonjs/Shaders/geometry.vertex" {
  72315. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72316. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72317. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72318. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72319. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72320. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72321. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72322. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72323. /** @hidden */
  72324. export var geometryVertexShader: {
  72325. name: string;
  72326. shader: string;
  72327. };
  72328. }
  72329. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72330. import { Matrix } from "babylonjs/Maths/math.vector";
  72331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72332. import { Mesh } from "babylonjs/Meshes/mesh";
  72333. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72334. import { Effect } from "babylonjs/Materials/effect";
  72335. import { Scene } from "babylonjs/scene";
  72336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72337. import "babylonjs/Shaders/geometry.fragment";
  72338. import "babylonjs/Shaders/geometry.vertex";
  72339. /** @hidden */
  72340. interface ISavedTransformationMatrix {
  72341. world: Matrix;
  72342. viewProjection: Matrix;
  72343. }
  72344. /**
  72345. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72346. */
  72347. export class GeometryBufferRenderer {
  72348. /**
  72349. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72350. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72351. */
  72352. static readonly POSITION_TEXTURE_TYPE: number;
  72353. /**
  72354. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72355. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72356. */
  72357. static readonly VELOCITY_TEXTURE_TYPE: number;
  72358. /**
  72359. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  72360. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  72361. */
  72362. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  72363. /**
  72364. * Dictionary used to store the previous transformation matrices of each rendered mesh
  72365. * in order to compute objects velocities when enableVelocity is set to "true"
  72366. * @hidden
  72367. */
  72368. _previousTransformationMatrices: {
  72369. [index: number]: ISavedTransformationMatrix;
  72370. };
  72371. /**
  72372. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  72373. * in order to compute objects velocities when enableVelocity is set to "true"
  72374. * @hidden
  72375. */
  72376. _previousBonesTransformationMatrices: {
  72377. [index: number]: Float32Array;
  72378. };
  72379. /**
  72380. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  72381. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  72382. */
  72383. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  72384. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  72385. renderTransparentMeshes: boolean;
  72386. private _scene;
  72387. private _multiRenderTarget;
  72388. private _ratio;
  72389. private _enablePosition;
  72390. private _enableVelocity;
  72391. private _enableReflectivity;
  72392. private _positionIndex;
  72393. private _velocityIndex;
  72394. private _reflectivityIndex;
  72395. protected _effect: Effect;
  72396. protected _cachedDefines: string;
  72397. /**
  72398. * Set the render list (meshes to be rendered) used in the G buffer.
  72399. */
  72400. set renderList(meshes: Mesh[]);
  72401. /**
  72402. * Gets wether or not G buffer are supported by the running hardware.
  72403. * This requires draw buffer supports
  72404. */
  72405. get isSupported(): boolean;
  72406. /**
  72407. * Returns the index of the given texture type in the G-Buffer textures array
  72408. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72409. * @returns the index of the given texture type in the G-Buffer textures array
  72410. */
  72411. getTextureIndex(textureType: number): number;
  72412. /**
  72413. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72414. */
  72415. get enablePosition(): boolean;
  72416. /**
  72417. * Sets whether or not objects positions are enabled for the G buffer.
  72418. */
  72419. set enablePosition(enable: boolean);
  72420. /**
  72421. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72422. */
  72423. get enableVelocity(): boolean;
  72424. /**
  72425. * Sets wether or not objects velocities are enabled for the G buffer.
  72426. */
  72427. set enableVelocity(enable: boolean);
  72428. /**
  72429. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72430. */
  72431. get enableReflectivity(): boolean;
  72432. /**
  72433. * Sets wether or not objects roughness are enabled for the G buffer.
  72434. */
  72435. set enableReflectivity(enable: boolean);
  72436. /**
  72437. * Gets the scene associated with the buffer.
  72438. */
  72439. get scene(): Scene;
  72440. /**
  72441. * Gets the ratio used by the buffer during its creation.
  72442. * How big is the buffer related to the main canvas.
  72443. */
  72444. get ratio(): number;
  72445. /** @hidden */
  72446. static _SceneComponentInitialization: (scene: Scene) => void;
  72447. /**
  72448. * Creates a new G Buffer for the scene
  72449. * @param scene The scene the buffer belongs to
  72450. * @param ratio How big is the buffer related to the main canvas.
  72451. */
  72452. constructor(scene: Scene, ratio?: number);
  72453. /**
  72454. * Checks wether everything is ready to render a submesh to the G buffer.
  72455. * @param subMesh the submesh to check readiness for
  72456. * @param useInstances is the mesh drawn using instance or not
  72457. * @returns true if ready otherwise false
  72458. */
  72459. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72460. /**
  72461. * Gets the current underlying G Buffer.
  72462. * @returns the buffer
  72463. */
  72464. getGBuffer(): MultiRenderTarget;
  72465. /**
  72466. * Gets the number of samples used to render the buffer (anti aliasing).
  72467. */
  72468. get samples(): number;
  72469. /**
  72470. * Sets the number of samples used to render the buffer (anti aliasing).
  72471. */
  72472. set samples(value: number);
  72473. /**
  72474. * Disposes the renderer and frees up associated resources.
  72475. */
  72476. dispose(): void;
  72477. protected _createRenderTargets(): void;
  72478. private _copyBonesTransformationMatrices;
  72479. }
  72480. }
  72481. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  72482. import { Nullable } from "babylonjs/types";
  72483. import { Scene } from "babylonjs/scene";
  72484. import { ISceneComponent } from "babylonjs/sceneComponent";
  72485. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  72486. module "babylonjs/scene" {
  72487. interface Scene {
  72488. /** @hidden (Backing field) */
  72489. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72490. /**
  72491. * Gets or Sets the current geometry buffer associated to the scene.
  72492. */
  72493. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72494. /**
  72495. * Enables a GeometryBufferRender and associates it with the scene
  72496. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  72497. * @returns the GeometryBufferRenderer
  72498. */
  72499. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  72500. /**
  72501. * Disables the GeometryBufferRender associated with the scene
  72502. */
  72503. disableGeometryBufferRenderer(): void;
  72504. }
  72505. }
  72506. /**
  72507. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72508. * in several rendering techniques.
  72509. */
  72510. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  72511. /**
  72512. * The component name helpful to identify the component in the list of scene components.
  72513. */
  72514. readonly name: string;
  72515. /**
  72516. * The scene the component belongs to.
  72517. */
  72518. scene: Scene;
  72519. /**
  72520. * Creates a new instance of the component for the given scene
  72521. * @param scene Defines the scene to register the component in
  72522. */
  72523. constructor(scene: Scene);
  72524. /**
  72525. * Registers the component in a given scene
  72526. */
  72527. register(): void;
  72528. /**
  72529. * Rebuilds the elements related to this component in case of
  72530. * context lost for instance.
  72531. */
  72532. rebuild(): void;
  72533. /**
  72534. * Disposes the component and the associated ressources
  72535. */
  72536. dispose(): void;
  72537. private _gatherRenderTargets;
  72538. }
  72539. }
  72540. declare module "babylonjs/Shaders/motionBlur.fragment" {
  72541. /** @hidden */
  72542. export var motionBlurPixelShader: {
  72543. name: string;
  72544. shader: string;
  72545. };
  72546. }
  72547. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  72548. import { Nullable } from "babylonjs/types";
  72549. import { Camera } from "babylonjs/Cameras/camera";
  72550. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72551. import { Scene } from "babylonjs/scene";
  72552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72553. import "babylonjs/Animations/animatable";
  72554. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72555. import "babylonjs/Shaders/motionBlur.fragment";
  72556. import { Engine } from "babylonjs/Engines/engine";
  72557. /**
  72558. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  72559. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  72560. * As an example, all you have to do is to create the post-process:
  72561. * var mb = new BABYLON.MotionBlurPostProcess(
  72562. * 'mb', // The name of the effect.
  72563. * scene, // The scene containing the objects to blur according to their velocity.
  72564. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  72565. * camera // The camera to apply the render pass to.
  72566. * );
  72567. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  72568. */
  72569. export class MotionBlurPostProcess extends PostProcess {
  72570. /**
  72571. * Defines how much the image is blurred by the movement. Default value is equal to 1
  72572. */
  72573. motionStrength: number;
  72574. /**
  72575. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  72576. */
  72577. get motionBlurSamples(): number;
  72578. /**
  72579. * Sets the number of iterations to be used for motion blur quality
  72580. */
  72581. set motionBlurSamples(samples: number);
  72582. private _motionBlurSamples;
  72583. private _geometryBufferRenderer;
  72584. /**
  72585. * Creates a new instance MotionBlurPostProcess
  72586. * @param name The name of the effect.
  72587. * @param scene The scene containing the objects to blur according to their velocity.
  72588. * @param options The required width/height ratio to downsize to before computing the render pass.
  72589. * @param camera The camera to apply the render pass to.
  72590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72591. * @param engine The engine which the post process will be applied. (default: current engine)
  72592. * @param reusable If the post process can be reused on the same frame. (default: false)
  72593. * @param textureType Type of textures used when performing the post process. (default: 0)
  72594. * @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)
  72595. */
  72596. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72597. /**
  72598. * Excludes the given skinned mesh from computing bones velocities.
  72599. * 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.
  72600. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  72601. */
  72602. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72603. /**
  72604. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  72605. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  72606. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  72607. */
  72608. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72609. /**
  72610. * Disposes the post process.
  72611. * @param camera The camera to dispose the post process on.
  72612. */
  72613. dispose(camera?: Camera): void;
  72614. }
  72615. }
  72616. declare module "babylonjs/Shaders/refraction.fragment" {
  72617. /** @hidden */
  72618. export var refractionPixelShader: {
  72619. name: string;
  72620. shader: string;
  72621. };
  72622. }
  72623. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  72624. import { Color3 } from "babylonjs/Maths/math.color";
  72625. import { Camera } from "babylonjs/Cameras/camera";
  72626. import { Texture } from "babylonjs/Materials/Textures/texture";
  72627. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72628. import { Engine } from "babylonjs/Engines/engine";
  72629. import "babylonjs/Shaders/refraction.fragment";
  72630. /**
  72631. * Post process which applies a refractin texture
  72632. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72633. */
  72634. export class RefractionPostProcess extends PostProcess {
  72635. /** the base color of the refraction (used to taint the rendering) */
  72636. color: Color3;
  72637. /** simulated refraction depth */
  72638. depth: number;
  72639. /** the coefficient of the base color (0 to remove base color tainting) */
  72640. colorLevel: number;
  72641. private _refTexture;
  72642. private _ownRefractionTexture;
  72643. /**
  72644. * Gets or sets the refraction texture
  72645. * Please note that you are responsible for disposing the texture if you set it manually
  72646. */
  72647. get refractionTexture(): Texture;
  72648. set refractionTexture(value: Texture);
  72649. /**
  72650. * Initializes the RefractionPostProcess
  72651. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72652. * @param name The name of the effect.
  72653. * @param refractionTextureUrl Url of the refraction texture to use
  72654. * @param color the base color of the refraction (used to taint the rendering)
  72655. * @param depth simulated refraction depth
  72656. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  72657. * @param camera The camera to apply the render pass to.
  72658. * @param options The required width/height ratio to downsize to before computing the render pass.
  72659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72660. * @param engine The engine which the post process will be applied. (default: current engine)
  72661. * @param reusable If the post process can be reused on the same frame. (default: false)
  72662. */
  72663. constructor(name: string, refractionTextureUrl: string,
  72664. /** the base color of the refraction (used to taint the rendering) */
  72665. color: Color3,
  72666. /** simulated refraction depth */
  72667. depth: number,
  72668. /** the coefficient of the base color (0 to remove base color tainting) */
  72669. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72670. /**
  72671. * Disposes of the post process
  72672. * @param camera Camera to dispose post process on
  72673. */
  72674. dispose(camera: Camera): void;
  72675. }
  72676. }
  72677. declare module "babylonjs/Shaders/sharpen.fragment" {
  72678. /** @hidden */
  72679. export var sharpenPixelShader: {
  72680. name: string;
  72681. shader: string;
  72682. };
  72683. }
  72684. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  72685. import { Nullable } from "babylonjs/types";
  72686. import { Camera } from "babylonjs/Cameras/camera";
  72687. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72688. import "babylonjs/Shaders/sharpen.fragment";
  72689. import { Engine } from "babylonjs/Engines/engine";
  72690. /**
  72691. * The SharpenPostProcess applies a sharpen kernel to every pixel
  72692. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72693. */
  72694. export class SharpenPostProcess extends PostProcess {
  72695. /**
  72696. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  72697. */
  72698. colorAmount: number;
  72699. /**
  72700. * How much sharpness should be applied (default: 0.3)
  72701. */
  72702. edgeAmount: number;
  72703. /**
  72704. * Creates a new instance ConvolutionPostProcess
  72705. * @param name The name of the effect.
  72706. * @param options The required width/height ratio to downsize to before computing the render pass.
  72707. * @param camera The camera to apply the render pass to.
  72708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72709. * @param engine The engine which the post process will be applied. (default: current engine)
  72710. * @param reusable If the post process can be reused on the same frame. (default: false)
  72711. * @param textureType Type of textures used when performing the post process. (default: 0)
  72712. * @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)
  72713. */
  72714. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72715. }
  72716. }
  72717. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  72718. import { Nullable } from "babylonjs/types";
  72719. import { Camera } from "babylonjs/Cameras/camera";
  72720. import { Engine } from "babylonjs/Engines/engine";
  72721. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72722. import { IInspectable } from "babylonjs/Misc/iInspectable";
  72723. /**
  72724. * PostProcessRenderPipeline
  72725. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72726. */
  72727. export class PostProcessRenderPipeline {
  72728. private engine;
  72729. private _renderEffects;
  72730. private _renderEffectsForIsolatedPass;
  72731. /**
  72732. * List of inspectable custom properties (used by the Inspector)
  72733. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72734. */
  72735. inspectableCustomProperties: IInspectable[];
  72736. /**
  72737. * @hidden
  72738. */
  72739. protected _cameras: Camera[];
  72740. /** @hidden */
  72741. _name: string;
  72742. /**
  72743. * Gets pipeline name
  72744. */
  72745. get name(): string;
  72746. /** Gets the list of attached cameras */
  72747. get cameras(): Camera[];
  72748. /**
  72749. * Initializes a PostProcessRenderPipeline
  72750. * @param engine engine to add the pipeline to
  72751. * @param name name of the pipeline
  72752. */
  72753. constructor(engine: Engine, name: string);
  72754. /**
  72755. * Gets the class name
  72756. * @returns "PostProcessRenderPipeline"
  72757. */
  72758. getClassName(): string;
  72759. /**
  72760. * If all the render effects in the pipeline are supported
  72761. */
  72762. get isSupported(): boolean;
  72763. /**
  72764. * Adds an effect to the pipeline
  72765. * @param renderEffect the effect to add
  72766. */
  72767. addEffect(renderEffect: PostProcessRenderEffect): void;
  72768. /** @hidden */
  72769. _rebuild(): void;
  72770. /** @hidden */
  72771. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72772. /** @hidden */
  72773. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72774. /** @hidden */
  72775. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72776. /** @hidden */
  72777. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72778. /** @hidden */
  72779. _attachCameras(cameras: Camera, unique: boolean): void;
  72780. /** @hidden */
  72781. _attachCameras(cameras: Camera[], unique: boolean): void;
  72782. /** @hidden */
  72783. _detachCameras(cameras: Camera): void;
  72784. /** @hidden */
  72785. _detachCameras(cameras: Nullable<Camera[]>): void;
  72786. /** @hidden */
  72787. _update(): void;
  72788. /** @hidden */
  72789. _reset(): void;
  72790. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72791. /**
  72792. * Disposes of the pipeline
  72793. */
  72794. dispose(): void;
  72795. }
  72796. }
  72797. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72798. import { Camera } from "babylonjs/Cameras/camera";
  72799. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72800. /**
  72801. * PostProcessRenderPipelineManager class
  72802. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72803. */
  72804. export class PostProcessRenderPipelineManager {
  72805. private _renderPipelines;
  72806. /**
  72807. * Initializes a PostProcessRenderPipelineManager
  72808. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72809. */
  72810. constructor();
  72811. /**
  72812. * Gets the list of supported render pipelines
  72813. */
  72814. get supportedPipelines(): PostProcessRenderPipeline[];
  72815. /**
  72816. * Adds a pipeline to the manager
  72817. * @param renderPipeline The pipeline to add
  72818. */
  72819. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72820. /**
  72821. * Attaches a camera to the pipeline
  72822. * @param renderPipelineName The name of the pipeline to attach to
  72823. * @param cameras the camera to attach
  72824. * @param unique if the camera can be attached multiple times to the pipeline
  72825. */
  72826. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72827. /**
  72828. * Detaches a camera from the pipeline
  72829. * @param renderPipelineName The name of the pipeline to detach from
  72830. * @param cameras the camera to detach
  72831. */
  72832. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72833. /**
  72834. * Enables an effect by name on a pipeline
  72835. * @param renderPipelineName the name of the pipeline to enable the effect in
  72836. * @param renderEffectName the name of the effect to enable
  72837. * @param cameras the cameras that the effect should be enabled on
  72838. */
  72839. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72840. /**
  72841. * Disables an effect by name on a pipeline
  72842. * @param renderPipelineName the name of the pipeline to disable the effect in
  72843. * @param renderEffectName the name of the effect to disable
  72844. * @param cameras the cameras that the effect should be disabled on
  72845. */
  72846. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72847. /**
  72848. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72849. */
  72850. update(): void;
  72851. /** @hidden */
  72852. _rebuild(): void;
  72853. /**
  72854. * Disposes of the manager and pipelines
  72855. */
  72856. dispose(): void;
  72857. }
  72858. }
  72859. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72860. import { ISceneComponent } from "babylonjs/sceneComponent";
  72861. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72862. import { Scene } from "babylonjs/scene";
  72863. module "babylonjs/scene" {
  72864. interface Scene {
  72865. /** @hidden (Backing field) */
  72866. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72867. /**
  72868. * Gets the postprocess render pipeline manager
  72869. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72870. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72871. */
  72872. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72873. }
  72874. }
  72875. /**
  72876. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72877. */
  72878. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72879. /**
  72880. * The component name helpfull to identify the component in the list of scene components.
  72881. */
  72882. readonly name: string;
  72883. /**
  72884. * The scene the component belongs to.
  72885. */
  72886. scene: Scene;
  72887. /**
  72888. * Creates a new instance of the component for the given scene
  72889. * @param scene Defines the scene to register the component in
  72890. */
  72891. constructor(scene: Scene);
  72892. /**
  72893. * Registers the component in a given scene
  72894. */
  72895. register(): void;
  72896. /**
  72897. * Rebuilds the elements related to this component in case of
  72898. * context lost for instance.
  72899. */
  72900. rebuild(): void;
  72901. /**
  72902. * Disposes the component and the associated ressources
  72903. */
  72904. dispose(): void;
  72905. private _gatherRenderTargets;
  72906. }
  72907. }
  72908. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72909. import { Nullable } from "babylonjs/types";
  72910. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72911. import { Camera } from "babylonjs/Cameras/camera";
  72912. import { IDisposable } from "babylonjs/scene";
  72913. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72914. import { Scene } from "babylonjs/scene";
  72915. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72916. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72917. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72918. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72919. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72920. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72921. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72922. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72923. import { Animation } from "babylonjs/Animations/animation";
  72924. /**
  72925. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72926. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72927. */
  72928. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72929. private _scene;
  72930. private _camerasToBeAttached;
  72931. /**
  72932. * ID of the sharpen post process,
  72933. */
  72934. private readonly SharpenPostProcessId;
  72935. /**
  72936. * @ignore
  72937. * ID of the image processing post process;
  72938. */
  72939. readonly ImageProcessingPostProcessId: string;
  72940. /**
  72941. * @ignore
  72942. * ID of the Fast Approximate Anti-Aliasing post process;
  72943. */
  72944. readonly FxaaPostProcessId: string;
  72945. /**
  72946. * ID of the chromatic aberration post process,
  72947. */
  72948. private readonly ChromaticAberrationPostProcessId;
  72949. /**
  72950. * ID of the grain post process
  72951. */
  72952. private readonly GrainPostProcessId;
  72953. /**
  72954. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72955. */
  72956. sharpen: SharpenPostProcess;
  72957. private _sharpenEffect;
  72958. private bloom;
  72959. /**
  72960. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72961. */
  72962. depthOfField: DepthOfFieldEffect;
  72963. /**
  72964. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72965. */
  72966. fxaa: FxaaPostProcess;
  72967. /**
  72968. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72969. */
  72970. imageProcessing: ImageProcessingPostProcess;
  72971. /**
  72972. * Chromatic aberration post process which will shift rgb colors in the image
  72973. */
  72974. chromaticAberration: ChromaticAberrationPostProcess;
  72975. private _chromaticAberrationEffect;
  72976. /**
  72977. * Grain post process which add noise to the image
  72978. */
  72979. grain: GrainPostProcess;
  72980. private _grainEffect;
  72981. /**
  72982. * Glow post process which adds a glow to emissive areas of the image
  72983. */
  72984. private _glowLayer;
  72985. /**
  72986. * Animations which can be used to tweak settings over a period of time
  72987. */
  72988. animations: Animation[];
  72989. private _imageProcessingConfigurationObserver;
  72990. private _sharpenEnabled;
  72991. private _bloomEnabled;
  72992. private _depthOfFieldEnabled;
  72993. private _depthOfFieldBlurLevel;
  72994. private _fxaaEnabled;
  72995. private _imageProcessingEnabled;
  72996. private _defaultPipelineTextureType;
  72997. private _bloomScale;
  72998. private _chromaticAberrationEnabled;
  72999. private _grainEnabled;
  73000. private _buildAllowed;
  73001. /**
  73002. * Gets active scene
  73003. */
  73004. get scene(): Scene;
  73005. /**
  73006. * Enable or disable the sharpen process from the pipeline
  73007. */
  73008. set sharpenEnabled(enabled: boolean);
  73009. get sharpenEnabled(): boolean;
  73010. private _resizeObserver;
  73011. private _hardwareScaleLevel;
  73012. private _bloomKernel;
  73013. /**
  73014. * Specifies the size of the bloom blur kernel, relative to the final output size
  73015. */
  73016. get bloomKernel(): number;
  73017. set bloomKernel(value: number);
  73018. /**
  73019. * Specifies the weight of the bloom in the final rendering
  73020. */
  73021. private _bloomWeight;
  73022. /**
  73023. * Specifies the luma threshold for the area that will be blurred by the bloom
  73024. */
  73025. private _bloomThreshold;
  73026. private _hdr;
  73027. /**
  73028. * The strength of the bloom.
  73029. */
  73030. set bloomWeight(value: number);
  73031. get bloomWeight(): number;
  73032. /**
  73033. * The strength of the bloom.
  73034. */
  73035. set bloomThreshold(value: number);
  73036. get bloomThreshold(): number;
  73037. /**
  73038. * The scale of the bloom, lower value will provide better performance.
  73039. */
  73040. set bloomScale(value: number);
  73041. get bloomScale(): number;
  73042. /**
  73043. * Enable or disable the bloom from the pipeline
  73044. */
  73045. set bloomEnabled(enabled: boolean);
  73046. get bloomEnabled(): boolean;
  73047. private _rebuildBloom;
  73048. /**
  73049. * If the depth of field is enabled.
  73050. */
  73051. get depthOfFieldEnabled(): boolean;
  73052. set depthOfFieldEnabled(enabled: boolean);
  73053. /**
  73054. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73055. */
  73056. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73057. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73058. /**
  73059. * If the anti aliasing is enabled.
  73060. */
  73061. set fxaaEnabled(enabled: boolean);
  73062. get fxaaEnabled(): boolean;
  73063. private _samples;
  73064. /**
  73065. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73066. */
  73067. set samples(sampleCount: number);
  73068. get samples(): number;
  73069. /**
  73070. * If image processing is enabled.
  73071. */
  73072. set imageProcessingEnabled(enabled: boolean);
  73073. get imageProcessingEnabled(): boolean;
  73074. /**
  73075. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73076. */
  73077. set glowLayerEnabled(enabled: boolean);
  73078. get glowLayerEnabled(): boolean;
  73079. /**
  73080. * Gets the glow layer (or null if not defined)
  73081. */
  73082. get glowLayer(): Nullable<GlowLayer>;
  73083. /**
  73084. * Enable or disable the chromaticAberration process from the pipeline
  73085. */
  73086. set chromaticAberrationEnabled(enabled: boolean);
  73087. get chromaticAberrationEnabled(): boolean;
  73088. /**
  73089. * Enable or disable the grain process from the pipeline
  73090. */
  73091. set grainEnabled(enabled: boolean);
  73092. get grainEnabled(): boolean;
  73093. /**
  73094. * @constructor
  73095. * @param name - The rendering pipeline name (default: "")
  73096. * @param hdr - If high dynamic range textures should be used (default: true)
  73097. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73098. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73099. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73100. */
  73101. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73102. /**
  73103. * Get the class name
  73104. * @returns "DefaultRenderingPipeline"
  73105. */
  73106. getClassName(): string;
  73107. /**
  73108. * Force the compilation of the entire pipeline.
  73109. */
  73110. prepare(): void;
  73111. private _hasCleared;
  73112. private _prevPostProcess;
  73113. private _prevPrevPostProcess;
  73114. private _setAutoClearAndTextureSharing;
  73115. private _depthOfFieldSceneObserver;
  73116. private _buildPipeline;
  73117. private _disposePostProcesses;
  73118. /**
  73119. * Adds a camera to the pipeline
  73120. * @param camera the camera to be added
  73121. */
  73122. addCamera(camera: Camera): void;
  73123. /**
  73124. * Removes a camera from the pipeline
  73125. * @param camera the camera to remove
  73126. */
  73127. removeCamera(camera: Camera): void;
  73128. /**
  73129. * Dispose of the pipeline and stop all post processes
  73130. */
  73131. dispose(): void;
  73132. /**
  73133. * Serialize the rendering pipeline (Used when exporting)
  73134. * @returns the serialized object
  73135. */
  73136. serialize(): any;
  73137. /**
  73138. * Parse the serialized pipeline
  73139. * @param source Source pipeline.
  73140. * @param scene The scene to load the pipeline to.
  73141. * @param rootUrl The URL of the serialized pipeline.
  73142. * @returns An instantiated pipeline from the serialized object.
  73143. */
  73144. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73145. }
  73146. }
  73147. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73148. /** @hidden */
  73149. export var lensHighlightsPixelShader: {
  73150. name: string;
  73151. shader: string;
  73152. };
  73153. }
  73154. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73155. /** @hidden */
  73156. export var depthOfFieldPixelShader: {
  73157. name: string;
  73158. shader: string;
  73159. };
  73160. }
  73161. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73162. import { Camera } from "babylonjs/Cameras/camera";
  73163. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73164. import { Scene } from "babylonjs/scene";
  73165. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73166. import "babylonjs/Shaders/chromaticAberration.fragment";
  73167. import "babylonjs/Shaders/lensHighlights.fragment";
  73168. import "babylonjs/Shaders/depthOfField.fragment";
  73169. /**
  73170. * BABYLON.JS Chromatic Aberration GLSL Shader
  73171. * Author: Olivier Guyot
  73172. * Separates very slightly R, G and B colors on the edges of the screen
  73173. * Inspired by Francois Tarlier & Martins Upitis
  73174. */
  73175. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73176. /**
  73177. * @ignore
  73178. * The chromatic aberration PostProcess id in the pipeline
  73179. */
  73180. LensChromaticAberrationEffect: string;
  73181. /**
  73182. * @ignore
  73183. * The highlights enhancing PostProcess id in the pipeline
  73184. */
  73185. HighlightsEnhancingEffect: string;
  73186. /**
  73187. * @ignore
  73188. * The depth-of-field PostProcess id in the pipeline
  73189. */
  73190. LensDepthOfFieldEffect: string;
  73191. private _scene;
  73192. private _depthTexture;
  73193. private _grainTexture;
  73194. private _chromaticAberrationPostProcess;
  73195. private _highlightsPostProcess;
  73196. private _depthOfFieldPostProcess;
  73197. private _edgeBlur;
  73198. private _grainAmount;
  73199. private _chromaticAberration;
  73200. private _distortion;
  73201. private _highlightsGain;
  73202. private _highlightsThreshold;
  73203. private _dofDistance;
  73204. private _dofAperture;
  73205. private _dofDarken;
  73206. private _dofPentagon;
  73207. private _blurNoise;
  73208. /**
  73209. * @constructor
  73210. *
  73211. * Effect parameters are as follow:
  73212. * {
  73213. * chromatic_aberration: number; // from 0 to x (1 for realism)
  73214. * edge_blur: number; // from 0 to x (1 for realism)
  73215. * distortion: number; // from 0 to x (1 for realism)
  73216. * grain_amount: number; // from 0 to 1
  73217. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73218. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73219. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73220. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73221. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73222. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73223. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73224. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73225. * }
  73226. * Note: if an effect parameter is unset, effect is disabled
  73227. *
  73228. * @param name The rendering pipeline name
  73229. * @param parameters - An object containing all parameters (see above)
  73230. * @param scene The scene linked to this pipeline
  73231. * @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)
  73232. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73233. */
  73234. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73235. /**
  73236. * Get the class name
  73237. * @returns "LensRenderingPipeline"
  73238. */
  73239. getClassName(): string;
  73240. /**
  73241. * Gets associated scene
  73242. */
  73243. get scene(): Scene;
  73244. /**
  73245. * Gets or sets the edge blur
  73246. */
  73247. get edgeBlur(): number;
  73248. set edgeBlur(value: number);
  73249. /**
  73250. * Gets or sets the grain amount
  73251. */
  73252. get grainAmount(): number;
  73253. set grainAmount(value: number);
  73254. /**
  73255. * Gets or sets the chromatic aberration amount
  73256. */
  73257. get chromaticAberration(): number;
  73258. set chromaticAberration(value: number);
  73259. /**
  73260. * Gets or sets the depth of field aperture
  73261. */
  73262. get dofAperture(): number;
  73263. set dofAperture(value: number);
  73264. /**
  73265. * Gets or sets the edge distortion
  73266. */
  73267. get edgeDistortion(): number;
  73268. set edgeDistortion(value: number);
  73269. /**
  73270. * Gets or sets the depth of field distortion
  73271. */
  73272. get dofDistortion(): number;
  73273. set dofDistortion(value: number);
  73274. /**
  73275. * Gets or sets the darken out of focus amount
  73276. */
  73277. get darkenOutOfFocus(): number;
  73278. set darkenOutOfFocus(value: number);
  73279. /**
  73280. * Gets or sets a boolean indicating if blur noise is enabled
  73281. */
  73282. get blurNoise(): boolean;
  73283. set blurNoise(value: boolean);
  73284. /**
  73285. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73286. */
  73287. get pentagonBokeh(): boolean;
  73288. set pentagonBokeh(value: boolean);
  73289. /**
  73290. * Gets or sets the highlight grain amount
  73291. */
  73292. get highlightsGain(): number;
  73293. set highlightsGain(value: number);
  73294. /**
  73295. * Gets or sets the highlight threshold
  73296. */
  73297. get highlightsThreshold(): number;
  73298. set highlightsThreshold(value: number);
  73299. /**
  73300. * Sets the amount of blur at the edges
  73301. * @param amount blur amount
  73302. */
  73303. setEdgeBlur(amount: number): void;
  73304. /**
  73305. * Sets edge blur to 0
  73306. */
  73307. disableEdgeBlur(): void;
  73308. /**
  73309. * Sets the amout of grain
  73310. * @param amount Amount of grain
  73311. */
  73312. setGrainAmount(amount: number): void;
  73313. /**
  73314. * Set grain amount to 0
  73315. */
  73316. disableGrain(): void;
  73317. /**
  73318. * Sets the chromatic aberration amount
  73319. * @param amount amount of chromatic aberration
  73320. */
  73321. setChromaticAberration(amount: number): void;
  73322. /**
  73323. * Sets chromatic aberration amount to 0
  73324. */
  73325. disableChromaticAberration(): void;
  73326. /**
  73327. * Sets the EdgeDistortion amount
  73328. * @param amount amount of EdgeDistortion
  73329. */
  73330. setEdgeDistortion(amount: number): void;
  73331. /**
  73332. * Sets edge distortion to 0
  73333. */
  73334. disableEdgeDistortion(): void;
  73335. /**
  73336. * Sets the FocusDistance amount
  73337. * @param amount amount of FocusDistance
  73338. */
  73339. setFocusDistance(amount: number): void;
  73340. /**
  73341. * Disables depth of field
  73342. */
  73343. disableDepthOfField(): void;
  73344. /**
  73345. * Sets the Aperture amount
  73346. * @param amount amount of Aperture
  73347. */
  73348. setAperture(amount: number): void;
  73349. /**
  73350. * Sets the DarkenOutOfFocus amount
  73351. * @param amount amount of DarkenOutOfFocus
  73352. */
  73353. setDarkenOutOfFocus(amount: number): void;
  73354. private _pentagonBokehIsEnabled;
  73355. /**
  73356. * Creates a pentagon bokeh effect
  73357. */
  73358. enablePentagonBokeh(): void;
  73359. /**
  73360. * Disables the pentagon bokeh effect
  73361. */
  73362. disablePentagonBokeh(): void;
  73363. /**
  73364. * Enables noise blur
  73365. */
  73366. enableNoiseBlur(): void;
  73367. /**
  73368. * Disables noise blur
  73369. */
  73370. disableNoiseBlur(): void;
  73371. /**
  73372. * Sets the HighlightsGain amount
  73373. * @param amount amount of HighlightsGain
  73374. */
  73375. setHighlightsGain(amount: number): void;
  73376. /**
  73377. * Sets the HighlightsThreshold amount
  73378. * @param amount amount of HighlightsThreshold
  73379. */
  73380. setHighlightsThreshold(amount: number): void;
  73381. /**
  73382. * Disables highlights
  73383. */
  73384. disableHighlights(): void;
  73385. /**
  73386. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  73387. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  73388. */
  73389. dispose(disableDepthRender?: boolean): void;
  73390. private _createChromaticAberrationPostProcess;
  73391. private _createHighlightsPostProcess;
  73392. private _createDepthOfFieldPostProcess;
  73393. private _createGrainTexture;
  73394. }
  73395. }
  73396. declare module "babylonjs/Shaders/ssao2.fragment" {
  73397. /** @hidden */
  73398. export var ssao2PixelShader: {
  73399. name: string;
  73400. shader: string;
  73401. };
  73402. }
  73403. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73404. /** @hidden */
  73405. export var ssaoCombinePixelShader: {
  73406. name: string;
  73407. shader: string;
  73408. };
  73409. }
  73410. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73411. import { Camera } from "babylonjs/Cameras/camera";
  73412. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73413. import { Scene } from "babylonjs/scene";
  73414. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73415. import "babylonjs/Shaders/ssao2.fragment";
  73416. import "babylonjs/Shaders/ssaoCombine.fragment";
  73417. /**
  73418. * Render pipeline to produce ssao effect
  73419. */
  73420. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73421. /**
  73422. * @ignore
  73423. * The PassPostProcess id in the pipeline that contains the original scene color
  73424. */
  73425. SSAOOriginalSceneColorEffect: string;
  73426. /**
  73427. * @ignore
  73428. * The SSAO PostProcess id in the pipeline
  73429. */
  73430. SSAORenderEffect: string;
  73431. /**
  73432. * @ignore
  73433. * The horizontal blur PostProcess id in the pipeline
  73434. */
  73435. SSAOBlurHRenderEffect: string;
  73436. /**
  73437. * @ignore
  73438. * The vertical blur PostProcess id in the pipeline
  73439. */
  73440. SSAOBlurVRenderEffect: string;
  73441. /**
  73442. * @ignore
  73443. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73444. */
  73445. SSAOCombineRenderEffect: string;
  73446. /**
  73447. * The output strength of the SSAO post-process. Default value is 1.0.
  73448. */
  73449. totalStrength: number;
  73450. /**
  73451. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  73452. */
  73453. maxZ: number;
  73454. /**
  73455. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  73456. */
  73457. minZAspect: number;
  73458. private _samples;
  73459. /**
  73460. * Number of samples used for the SSAO calculations. Default value is 8
  73461. */
  73462. set samples(n: number);
  73463. get samples(): number;
  73464. private _textureSamples;
  73465. /**
  73466. * Number of samples to use for antialiasing
  73467. */
  73468. set textureSamples(n: number);
  73469. get textureSamples(): number;
  73470. /**
  73471. * Ratio object used for SSAO ratio and blur ratio
  73472. */
  73473. private _ratio;
  73474. /**
  73475. * Dynamically generated sphere sampler.
  73476. */
  73477. private _sampleSphere;
  73478. /**
  73479. * Blur filter offsets
  73480. */
  73481. private _samplerOffsets;
  73482. private _expensiveBlur;
  73483. /**
  73484. * If bilateral blur should be used
  73485. */
  73486. set expensiveBlur(b: boolean);
  73487. get expensiveBlur(): boolean;
  73488. /**
  73489. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  73490. */
  73491. radius: number;
  73492. /**
  73493. * The base color of the SSAO post-process
  73494. * The final result is "base + ssao" between [0, 1]
  73495. */
  73496. base: number;
  73497. /**
  73498. * Support test.
  73499. */
  73500. static get IsSupported(): boolean;
  73501. private _scene;
  73502. private _depthTexture;
  73503. private _normalTexture;
  73504. private _randomTexture;
  73505. private _originalColorPostProcess;
  73506. private _ssaoPostProcess;
  73507. private _blurHPostProcess;
  73508. private _blurVPostProcess;
  73509. private _ssaoCombinePostProcess;
  73510. /**
  73511. * Gets active scene
  73512. */
  73513. get scene(): Scene;
  73514. /**
  73515. * @constructor
  73516. * @param name The rendering pipeline name
  73517. * @param scene The scene linked to this pipeline
  73518. * @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 }
  73519. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73520. */
  73521. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73522. /**
  73523. * Get the class name
  73524. * @returns "SSAO2RenderingPipeline"
  73525. */
  73526. getClassName(): string;
  73527. /**
  73528. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73529. */
  73530. dispose(disableGeometryBufferRenderer?: boolean): void;
  73531. private _createBlurPostProcess;
  73532. /** @hidden */
  73533. _rebuild(): void;
  73534. private _bits;
  73535. private _radicalInverse_VdC;
  73536. private _hammersley;
  73537. private _hemisphereSample_uniform;
  73538. private _generateHemisphere;
  73539. private _createSSAOPostProcess;
  73540. private _createSSAOCombinePostProcess;
  73541. private _createRandomTexture;
  73542. /**
  73543. * Serialize the rendering pipeline (Used when exporting)
  73544. * @returns the serialized object
  73545. */
  73546. serialize(): any;
  73547. /**
  73548. * Parse the serialized pipeline
  73549. * @param source Source pipeline.
  73550. * @param scene The scene to load the pipeline to.
  73551. * @param rootUrl The URL of the serialized pipeline.
  73552. * @returns An instantiated pipeline from the serialized object.
  73553. */
  73554. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  73555. }
  73556. }
  73557. declare module "babylonjs/Shaders/ssao.fragment" {
  73558. /** @hidden */
  73559. export var ssaoPixelShader: {
  73560. name: string;
  73561. shader: string;
  73562. };
  73563. }
  73564. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  73565. import { Camera } from "babylonjs/Cameras/camera";
  73566. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73567. import { Scene } from "babylonjs/scene";
  73568. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73569. import "babylonjs/Shaders/ssao.fragment";
  73570. import "babylonjs/Shaders/ssaoCombine.fragment";
  73571. /**
  73572. * Render pipeline to produce ssao effect
  73573. */
  73574. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  73575. /**
  73576. * @ignore
  73577. * The PassPostProcess id in the pipeline that contains the original scene color
  73578. */
  73579. SSAOOriginalSceneColorEffect: string;
  73580. /**
  73581. * @ignore
  73582. * The SSAO PostProcess id in the pipeline
  73583. */
  73584. SSAORenderEffect: string;
  73585. /**
  73586. * @ignore
  73587. * The horizontal blur PostProcess id in the pipeline
  73588. */
  73589. SSAOBlurHRenderEffect: string;
  73590. /**
  73591. * @ignore
  73592. * The vertical blur PostProcess id in the pipeline
  73593. */
  73594. SSAOBlurVRenderEffect: string;
  73595. /**
  73596. * @ignore
  73597. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73598. */
  73599. SSAOCombineRenderEffect: string;
  73600. /**
  73601. * The output strength of the SSAO post-process. Default value is 1.0.
  73602. */
  73603. totalStrength: number;
  73604. /**
  73605. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  73606. */
  73607. radius: number;
  73608. /**
  73609. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  73610. * Must not be equal to fallOff and superior to fallOff.
  73611. * Default value is 0.0075
  73612. */
  73613. area: number;
  73614. /**
  73615. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  73616. * Must not be equal to area and inferior to area.
  73617. * Default value is 0.000001
  73618. */
  73619. fallOff: number;
  73620. /**
  73621. * The base color of the SSAO post-process
  73622. * The final result is "base + ssao" between [0, 1]
  73623. */
  73624. base: number;
  73625. private _scene;
  73626. private _depthTexture;
  73627. private _randomTexture;
  73628. private _originalColorPostProcess;
  73629. private _ssaoPostProcess;
  73630. private _blurHPostProcess;
  73631. private _blurVPostProcess;
  73632. private _ssaoCombinePostProcess;
  73633. private _firstUpdate;
  73634. /**
  73635. * Gets active scene
  73636. */
  73637. get scene(): Scene;
  73638. /**
  73639. * @constructor
  73640. * @param name - The rendering pipeline name
  73641. * @param scene - The scene linked to this pipeline
  73642. * @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 }
  73643. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  73644. */
  73645. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73646. /**
  73647. * Get the class name
  73648. * @returns "SSAORenderingPipeline"
  73649. */
  73650. getClassName(): string;
  73651. /**
  73652. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73653. */
  73654. dispose(disableDepthRender?: boolean): void;
  73655. private _createBlurPostProcess;
  73656. /** @hidden */
  73657. _rebuild(): void;
  73658. private _createSSAOPostProcess;
  73659. private _createSSAOCombinePostProcess;
  73660. private _createRandomTexture;
  73661. }
  73662. }
  73663. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  73664. /** @hidden */
  73665. export var screenSpaceReflectionPixelShader: {
  73666. name: string;
  73667. shader: string;
  73668. };
  73669. }
  73670. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  73671. import { Nullable } from "babylonjs/types";
  73672. import { Camera } from "babylonjs/Cameras/camera";
  73673. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73674. import { Scene } from "babylonjs/scene";
  73675. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  73676. import { Engine } from "babylonjs/Engines/engine";
  73677. /**
  73678. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  73679. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  73680. */
  73681. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  73682. /**
  73683. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  73684. */
  73685. threshold: number;
  73686. /**
  73687. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  73688. */
  73689. strength: number;
  73690. /**
  73691. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  73692. */
  73693. reflectionSpecularFalloffExponent: number;
  73694. /**
  73695. * 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]
  73696. */
  73697. step: number;
  73698. /**
  73699. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  73700. */
  73701. roughnessFactor: number;
  73702. private _geometryBufferRenderer;
  73703. private _enableSmoothReflections;
  73704. private _reflectionSamples;
  73705. private _smoothSteps;
  73706. /**
  73707. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  73708. * @param name The name of the effect.
  73709. * @param scene The scene containing the objects to calculate reflections.
  73710. * @param options The required width/height ratio to downsize to before computing the render pass.
  73711. * @param camera The camera to apply the render pass to.
  73712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73713. * @param engine The engine which the post process will be applied. (default: current engine)
  73714. * @param reusable If the post process can be reused on the same frame. (default: false)
  73715. * @param textureType Type of textures used when performing the post process. (default: 0)
  73716. * @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)
  73717. */
  73718. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73719. /**
  73720. * Gets wether or not smoothing reflections is enabled.
  73721. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73722. */
  73723. get enableSmoothReflections(): boolean;
  73724. /**
  73725. * Sets wether or not smoothing reflections is enabled.
  73726. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73727. */
  73728. set enableSmoothReflections(enabled: boolean);
  73729. /**
  73730. * Gets the number of samples taken while computing reflections. More samples count is high,
  73731. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73732. */
  73733. get reflectionSamples(): number;
  73734. /**
  73735. * Sets the number of samples taken while computing reflections. More samples count is high,
  73736. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73737. */
  73738. set reflectionSamples(samples: number);
  73739. /**
  73740. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  73741. * more the post-process will require GPU power and can generate a drop in FPS.
  73742. * Default value (5.0) work pretty well in all cases but can be adjusted.
  73743. */
  73744. get smoothSteps(): number;
  73745. set smoothSteps(steps: number);
  73746. private _updateEffectDefines;
  73747. }
  73748. }
  73749. declare module "babylonjs/Shaders/standard.fragment" {
  73750. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  73751. /** @hidden */
  73752. export var standardPixelShader: {
  73753. name: string;
  73754. shader: string;
  73755. };
  73756. }
  73757. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  73758. import { Nullable } from "babylonjs/types";
  73759. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73760. import { Camera } from "babylonjs/Cameras/camera";
  73761. import { Texture } from "babylonjs/Materials/Textures/texture";
  73762. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73763. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73764. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73765. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73766. import { IDisposable } from "babylonjs/scene";
  73767. import { SpotLight } from "babylonjs/Lights/spotLight";
  73768. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  73769. import { Scene } from "babylonjs/scene";
  73770. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73771. import { Animation } from "babylonjs/Animations/animation";
  73772. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73773. import "babylonjs/Shaders/standard.fragment";
  73774. /**
  73775. * Standard rendering pipeline
  73776. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73777. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73778. */
  73779. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73780. /**
  73781. * Public members
  73782. */
  73783. /**
  73784. * Post-process which contains the original scene color before the pipeline applies all the effects
  73785. */
  73786. originalPostProcess: Nullable<PostProcess>;
  73787. /**
  73788. * Post-process used to down scale an image x4
  73789. */
  73790. downSampleX4PostProcess: Nullable<PostProcess>;
  73791. /**
  73792. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73793. */
  73794. brightPassPostProcess: Nullable<PostProcess>;
  73795. /**
  73796. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73797. */
  73798. blurHPostProcesses: PostProcess[];
  73799. /**
  73800. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73801. */
  73802. blurVPostProcesses: PostProcess[];
  73803. /**
  73804. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73805. */
  73806. textureAdderPostProcess: Nullable<PostProcess>;
  73807. /**
  73808. * Post-process used to create volumetric lighting effect
  73809. */
  73810. volumetricLightPostProcess: Nullable<PostProcess>;
  73811. /**
  73812. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73813. */
  73814. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73815. /**
  73816. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73817. */
  73818. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73819. /**
  73820. * Post-process used to merge the volumetric light effect and the real scene color
  73821. */
  73822. volumetricLightMergePostProces: Nullable<PostProcess>;
  73823. /**
  73824. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73825. */
  73826. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73827. /**
  73828. * Base post-process used to calculate the average luminance of the final image for HDR
  73829. */
  73830. luminancePostProcess: Nullable<PostProcess>;
  73831. /**
  73832. * Post-processes used to create down sample post-processes in order to get
  73833. * the average luminance of the final image for HDR
  73834. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73835. */
  73836. luminanceDownSamplePostProcesses: PostProcess[];
  73837. /**
  73838. * Post-process used to create a HDR effect (light adaptation)
  73839. */
  73840. hdrPostProcess: Nullable<PostProcess>;
  73841. /**
  73842. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73843. */
  73844. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73845. /**
  73846. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73847. */
  73848. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73849. /**
  73850. * Post-process used to merge the final HDR post-process and the real scene color
  73851. */
  73852. hdrFinalPostProcess: Nullable<PostProcess>;
  73853. /**
  73854. * Post-process used to create a lens flare effect
  73855. */
  73856. lensFlarePostProcess: Nullable<PostProcess>;
  73857. /**
  73858. * Post-process that merges the result of the lens flare post-process and the real scene color
  73859. */
  73860. lensFlareComposePostProcess: Nullable<PostProcess>;
  73861. /**
  73862. * Post-process used to create a motion blur effect
  73863. */
  73864. motionBlurPostProcess: Nullable<PostProcess>;
  73865. /**
  73866. * Post-process used to create a depth of field effect
  73867. */
  73868. depthOfFieldPostProcess: Nullable<PostProcess>;
  73869. /**
  73870. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73871. */
  73872. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73873. /**
  73874. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73875. */
  73876. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73877. /**
  73878. * Represents the brightness threshold in order to configure the illuminated surfaces
  73879. */
  73880. brightThreshold: number;
  73881. /**
  73882. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73883. */
  73884. blurWidth: number;
  73885. /**
  73886. * Sets if the blur for highlighted surfaces must be only horizontal
  73887. */
  73888. horizontalBlur: boolean;
  73889. /**
  73890. * Gets the overall exposure used by the pipeline
  73891. */
  73892. get exposure(): number;
  73893. /**
  73894. * Sets the overall exposure used by the pipeline
  73895. */
  73896. set exposure(value: number);
  73897. /**
  73898. * Texture used typically to simulate "dirty" on camera lens
  73899. */
  73900. lensTexture: Nullable<Texture>;
  73901. /**
  73902. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73903. */
  73904. volumetricLightCoefficient: number;
  73905. /**
  73906. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73907. */
  73908. volumetricLightPower: number;
  73909. /**
  73910. * Used the set the blur intensity to smooth the volumetric lights
  73911. */
  73912. volumetricLightBlurScale: number;
  73913. /**
  73914. * Light (spot or directional) used to generate the volumetric lights rays
  73915. * The source light must have a shadow generate so the pipeline can get its
  73916. * depth map
  73917. */
  73918. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73919. /**
  73920. * For eye adaptation, represents the minimum luminance the eye can see
  73921. */
  73922. hdrMinimumLuminance: number;
  73923. /**
  73924. * For eye adaptation, represents the decrease luminance speed
  73925. */
  73926. hdrDecreaseRate: number;
  73927. /**
  73928. * For eye adaptation, represents the increase luminance speed
  73929. */
  73930. hdrIncreaseRate: number;
  73931. /**
  73932. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73933. */
  73934. get hdrAutoExposure(): boolean;
  73935. /**
  73936. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73937. */
  73938. set hdrAutoExposure(value: boolean);
  73939. /**
  73940. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73941. */
  73942. lensColorTexture: Nullable<Texture>;
  73943. /**
  73944. * The overall strengh for the lens flare effect
  73945. */
  73946. lensFlareStrength: number;
  73947. /**
  73948. * Dispersion coefficient for lens flare ghosts
  73949. */
  73950. lensFlareGhostDispersal: number;
  73951. /**
  73952. * Main lens flare halo width
  73953. */
  73954. lensFlareHaloWidth: number;
  73955. /**
  73956. * Based on the lens distortion effect, defines how much the lens flare result
  73957. * is distorted
  73958. */
  73959. lensFlareDistortionStrength: number;
  73960. /**
  73961. * Configures the blur intensity used for for lens flare (halo)
  73962. */
  73963. lensFlareBlurWidth: number;
  73964. /**
  73965. * Lens star texture must be used to simulate rays on the flares and is available
  73966. * in the documentation
  73967. */
  73968. lensStarTexture: Nullable<Texture>;
  73969. /**
  73970. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73971. * flare effect by taking account of the dirt texture
  73972. */
  73973. lensFlareDirtTexture: Nullable<Texture>;
  73974. /**
  73975. * Represents the focal length for the depth of field effect
  73976. */
  73977. depthOfFieldDistance: number;
  73978. /**
  73979. * Represents the blur intensity for the blurred part of the depth of field effect
  73980. */
  73981. depthOfFieldBlurWidth: number;
  73982. /**
  73983. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73984. */
  73985. get motionStrength(): number;
  73986. /**
  73987. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73988. */
  73989. set motionStrength(strength: number);
  73990. /**
  73991. * Gets wether or not the motion blur post-process is object based or screen based.
  73992. */
  73993. get objectBasedMotionBlur(): boolean;
  73994. /**
  73995. * Sets wether or not the motion blur post-process should be object based or screen based
  73996. */
  73997. set objectBasedMotionBlur(value: boolean);
  73998. /**
  73999. * List of animations for the pipeline (IAnimatable implementation)
  74000. */
  74001. animations: Animation[];
  74002. /**
  74003. * Private members
  74004. */
  74005. private _scene;
  74006. private _currentDepthOfFieldSource;
  74007. private _basePostProcess;
  74008. private _fixedExposure;
  74009. private _currentExposure;
  74010. private _hdrAutoExposure;
  74011. private _hdrCurrentLuminance;
  74012. private _motionStrength;
  74013. private _isObjectBasedMotionBlur;
  74014. private _floatTextureType;
  74015. private _camerasToBeAttached;
  74016. private _ratio;
  74017. private _bloomEnabled;
  74018. private _depthOfFieldEnabled;
  74019. private _vlsEnabled;
  74020. private _lensFlareEnabled;
  74021. private _hdrEnabled;
  74022. private _motionBlurEnabled;
  74023. private _fxaaEnabled;
  74024. private _screenSpaceReflectionsEnabled;
  74025. private _motionBlurSamples;
  74026. private _volumetricLightStepsCount;
  74027. private _samples;
  74028. /**
  74029. * @ignore
  74030. * Specifies if the bloom pipeline is enabled
  74031. */
  74032. get BloomEnabled(): boolean;
  74033. set BloomEnabled(enabled: boolean);
  74034. /**
  74035. * @ignore
  74036. * Specifies if the depth of field pipeline is enabed
  74037. */
  74038. get DepthOfFieldEnabled(): boolean;
  74039. set DepthOfFieldEnabled(enabled: boolean);
  74040. /**
  74041. * @ignore
  74042. * Specifies if the lens flare pipeline is enabed
  74043. */
  74044. get LensFlareEnabled(): boolean;
  74045. set LensFlareEnabled(enabled: boolean);
  74046. /**
  74047. * @ignore
  74048. * Specifies if the HDR pipeline is enabled
  74049. */
  74050. get HDREnabled(): boolean;
  74051. set HDREnabled(enabled: boolean);
  74052. /**
  74053. * @ignore
  74054. * Specifies if the volumetric lights scattering effect is enabled
  74055. */
  74056. get VLSEnabled(): boolean;
  74057. set VLSEnabled(enabled: boolean);
  74058. /**
  74059. * @ignore
  74060. * Specifies if the motion blur effect is enabled
  74061. */
  74062. get MotionBlurEnabled(): boolean;
  74063. set MotionBlurEnabled(enabled: boolean);
  74064. /**
  74065. * Specifies if anti-aliasing is enabled
  74066. */
  74067. get fxaaEnabled(): boolean;
  74068. set fxaaEnabled(enabled: boolean);
  74069. /**
  74070. * Specifies if screen space reflections are enabled.
  74071. */
  74072. get screenSpaceReflectionsEnabled(): boolean;
  74073. set screenSpaceReflectionsEnabled(enabled: boolean);
  74074. /**
  74075. * Specifies the number of steps used to calculate the volumetric lights
  74076. * Typically in interval [50, 200]
  74077. */
  74078. get volumetricLightStepsCount(): number;
  74079. set volumetricLightStepsCount(count: number);
  74080. /**
  74081. * Specifies the number of samples used for the motion blur effect
  74082. * Typically in interval [16, 64]
  74083. */
  74084. get motionBlurSamples(): number;
  74085. set motionBlurSamples(samples: number);
  74086. /**
  74087. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74088. */
  74089. get samples(): number;
  74090. set samples(sampleCount: number);
  74091. /**
  74092. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74093. * @constructor
  74094. * @param name The rendering pipeline name
  74095. * @param scene The scene linked to this pipeline
  74096. * @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)
  74097. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74098. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74099. */
  74100. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74101. private _buildPipeline;
  74102. private _createDownSampleX4PostProcess;
  74103. private _createBrightPassPostProcess;
  74104. private _createBlurPostProcesses;
  74105. private _createTextureAdderPostProcess;
  74106. private _createVolumetricLightPostProcess;
  74107. private _createLuminancePostProcesses;
  74108. private _createHdrPostProcess;
  74109. private _createLensFlarePostProcess;
  74110. private _createDepthOfFieldPostProcess;
  74111. private _createMotionBlurPostProcess;
  74112. private _getDepthTexture;
  74113. private _disposePostProcesses;
  74114. /**
  74115. * Dispose of the pipeline and stop all post processes
  74116. */
  74117. dispose(): void;
  74118. /**
  74119. * Serialize the rendering pipeline (Used when exporting)
  74120. * @returns the serialized object
  74121. */
  74122. serialize(): any;
  74123. /**
  74124. * Parse the serialized pipeline
  74125. * @param source Source pipeline.
  74126. * @param scene The scene to load the pipeline to.
  74127. * @param rootUrl The URL of the serialized pipeline.
  74128. * @returns An instantiated pipeline from the serialized object.
  74129. */
  74130. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74131. /**
  74132. * Luminance steps
  74133. */
  74134. static LuminanceSteps: number;
  74135. }
  74136. }
  74137. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74138. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74139. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74140. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74141. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74142. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74143. }
  74144. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74145. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74146. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74147. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74148. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74149. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74150. }
  74151. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74152. /** @hidden */
  74153. export var stereoscopicInterlacePixelShader: {
  74154. name: string;
  74155. shader: string;
  74156. };
  74157. }
  74158. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74159. import { Camera } from "babylonjs/Cameras/camera";
  74160. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74161. import { Engine } from "babylonjs/Engines/engine";
  74162. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74163. /**
  74164. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74165. */
  74166. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74167. private _stepSize;
  74168. private _passedProcess;
  74169. /**
  74170. * Initializes a StereoscopicInterlacePostProcessI
  74171. * @param name The name of the effect.
  74172. * @param rigCameras The rig cameras to be appled to the post process
  74173. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74174. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74176. * @param engine The engine which the post process will be applied. (default: current engine)
  74177. * @param reusable If the post process can be reused on the same frame. (default: false)
  74178. */
  74179. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74180. }
  74181. /**
  74182. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74183. */
  74184. export class StereoscopicInterlacePostProcess extends PostProcess {
  74185. private _stepSize;
  74186. private _passedProcess;
  74187. /**
  74188. * Initializes a StereoscopicInterlacePostProcess
  74189. * @param name The name of the effect.
  74190. * @param rigCameras The rig cameras to be appled to the post process
  74191. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74193. * @param engine The engine which the post process will be applied. (default: current engine)
  74194. * @param reusable If the post process can be reused on the same frame. (default: false)
  74195. */
  74196. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74197. }
  74198. }
  74199. declare module "babylonjs/Shaders/tonemap.fragment" {
  74200. /** @hidden */
  74201. export var tonemapPixelShader: {
  74202. name: string;
  74203. shader: string;
  74204. };
  74205. }
  74206. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  74207. import { Camera } from "babylonjs/Cameras/camera";
  74208. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74209. import "babylonjs/Shaders/tonemap.fragment";
  74210. import { Engine } from "babylonjs/Engines/engine";
  74211. /** Defines operator used for tonemapping */
  74212. export enum TonemappingOperator {
  74213. /** Hable */
  74214. Hable = 0,
  74215. /** Reinhard */
  74216. Reinhard = 1,
  74217. /** HejiDawson */
  74218. HejiDawson = 2,
  74219. /** Photographic */
  74220. Photographic = 3
  74221. }
  74222. /**
  74223. * Defines a post process to apply tone mapping
  74224. */
  74225. export class TonemapPostProcess extends PostProcess {
  74226. private _operator;
  74227. /** Defines the required exposure adjustement */
  74228. exposureAdjustment: number;
  74229. /**
  74230. * Creates a new TonemapPostProcess
  74231. * @param name defines the name of the postprocess
  74232. * @param _operator defines the operator to use
  74233. * @param exposureAdjustment defines the required exposure adjustement
  74234. * @param camera defines the camera to use (can be null)
  74235. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74236. * @param engine defines the hosting engine (can be ignore if camera is set)
  74237. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74238. */
  74239. constructor(name: string, _operator: TonemappingOperator,
  74240. /** Defines the required exposure adjustement */
  74241. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74242. }
  74243. }
  74244. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74245. /** @hidden */
  74246. export var volumetricLightScatteringPixelShader: {
  74247. name: string;
  74248. shader: string;
  74249. };
  74250. }
  74251. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74252. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74253. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74254. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74255. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74256. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74257. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74258. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74259. /** @hidden */
  74260. export var volumetricLightScatteringPassVertexShader: {
  74261. name: string;
  74262. shader: string;
  74263. };
  74264. }
  74265. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74266. /** @hidden */
  74267. export var volumetricLightScatteringPassPixelShader: {
  74268. name: string;
  74269. shader: string;
  74270. };
  74271. }
  74272. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74273. import { Vector3 } from "babylonjs/Maths/math.vector";
  74274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74275. import { Mesh } from "babylonjs/Meshes/mesh";
  74276. import { Camera } from "babylonjs/Cameras/camera";
  74277. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74278. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74279. import { Scene } from "babylonjs/scene";
  74280. import "babylonjs/Meshes/Builders/planeBuilder";
  74281. import "babylonjs/Shaders/depth.vertex";
  74282. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74283. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74284. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74285. import { Engine } from "babylonjs/Engines/engine";
  74286. /**
  74287. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74288. */
  74289. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74290. private _volumetricLightScatteringPass;
  74291. private _volumetricLightScatteringRTT;
  74292. private _viewPort;
  74293. private _screenCoordinates;
  74294. private _cachedDefines;
  74295. /**
  74296. * If not undefined, the mesh position is computed from the attached node position
  74297. */
  74298. attachedNode: {
  74299. position: Vector3;
  74300. };
  74301. /**
  74302. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74303. */
  74304. customMeshPosition: Vector3;
  74305. /**
  74306. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74307. */
  74308. useCustomMeshPosition: boolean;
  74309. /**
  74310. * If the post-process should inverse the light scattering direction
  74311. */
  74312. invert: boolean;
  74313. /**
  74314. * The internal mesh used by the post-process
  74315. */
  74316. mesh: Mesh;
  74317. /**
  74318. * @hidden
  74319. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74320. */
  74321. get useDiffuseColor(): boolean;
  74322. set useDiffuseColor(useDiffuseColor: boolean);
  74323. /**
  74324. * Array containing the excluded meshes not rendered in the internal pass
  74325. */
  74326. excludedMeshes: AbstractMesh[];
  74327. /**
  74328. * Controls the overall intensity of the post-process
  74329. */
  74330. exposure: number;
  74331. /**
  74332. * Dissipates each sample's contribution in range [0, 1]
  74333. */
  74334. decay: number;
  74335. /**
  74336. * Controls the overall intensity of each sample
  74337. */
  74338. weight: number;
  74339. /**
  74340. * Controls the density of each sample
  74341. */
  74342. density: number;
  74343. /**
  74344. * @constructor
  74345. * @param name The post-process name
  74346. * @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)
  74347. * @param camera The camera that the post-process will be attached to
  74348. * @param mesh The mesh used to create the light scattering
  74349. * @param samples The post-process quality, default 100
  74350. * @param samplingModeThe post-process filtering mode
  74351. * @param engine The babylon engine
  74352. * @param reusable If the post-process is reusable
  74353. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  74354. */
  74355. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  74356. /**
  74357. * Returns the string "VolumetricLightScatteringPostProcess"
  74358. * @returns "VolumetricLightScatteringPostProcess"
  74359. */
  74360. getClassName(): string;
  74361. private _isReady;
  74362. /**
  74363. * Sets the new light position for light scattering effect
  74364. * @param position The new custom light position
  74365. */
  74366. setCustomMeshPosition(position: Vector3): void;
  74367. /**
  74368. * Returns the light position for light scattering effect
  74369. * @return Vector3 The custom light position
  74370. */
  74371. getCustomMeshPosition(): Vector3;
  74372. /**
  74373. * Disposes the internal assets and detaches the post-process from the camera
  74374. */
  74375. dispose(camera: Camera): void;
  74376. /**
  74377. * Returns the render target texture used by the post-process
  74378. * @return the render target texture used by the post-process
  74379. */
  74380. getPass(): RenderTargetTexture;
  74381. private _meshExcluded;
  74382. private _createPass;
  74383. private _updateMeshScreenCoordinates;
  74384. /**
  74385. * Creates a default mesh for the Volumeric Light Scattering post-process
  74386. * @param name The mesh name
  74387. * @param scene The scene where to create the mesh
  74388. * @return the default mesh
  74389. */
  74390. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  74391. }
  74392. }
  74393. declare module "babylonjs/PostProcesses/index" {
  74394. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  74395. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  74396. export * from "babylonjs/PostProcesses/bloomEffect";
  74397. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  74398. export * from "babylonjs/PostProcesses/blurPostProcess";
  74399. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74400. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  74401. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  74402. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  74403. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74404. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  74405. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  74406. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  74407. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74408. export * from "babylonjs/PostProcesses/filterPostProcess";
  74409. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  74410. export * from "babylonjs/PostProcesses/grainPostProcess";
  74411. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  74412. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74413. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  74414. export * from "babylonjs/PostProcesses/passPostProcess";
  74415. export * from "babylonjs/PostProcesses/postProcess";
  74416. export * from "babylonjs/PostProcesses/postProcessManager";
  74417. export * from "babylonjs/PostProcesses/refractionPostProcess";
  74418. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  74419. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  74420. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  74421. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  74422. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  74423. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  74424. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  74425. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74426. }
  74427. declare module "babylonjs/Probes/index" {
  74428. export * from "babylonjs/Probes/reflectionProbe";
  74429. }
  74430. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  74431. import { Scene } from "babylonjs/scene";
  74432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74433. import { SmartArray } from "babylonjs/Misc/smartArray";
  74434. import { ISceneComponent } from "babylonjs/sceneComponent";
  74435. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  74436. import "babylonjs/Meshes/Builders/boxBuilder";
  74437. import "babylonjs/Shaders/color.fragment";
  74438. import "babylonjs/Shaders/color.vertex";
  74439. import { Color3 } from "babylonjs/Maths/math.color";
  74440. import { Observable } from "babylonjs/Misc/observable";
  74441. module "babylonjs/scene" {
  74442. interface Scene {
  74443. /** @hidden (Backing field) */
  74444. _boundingBoxRenderer: BoundingBoxRenderer;
  74445. /** @hidden (Backing field) */
  74446. _forceShowBoundingBoxes: boolean;
  74447. /**
  74448. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  74449. */
  74450. forceShowBoundingBoxes: boolean;
  74451. /**
  74452. * Gets the bounding box renderer associated with the scene
  74453. * @returns a BoundingBoxRenderer
  74454. */
  74455. getBoundingBoxRenderer(): BoundingBoxRenderer;
  74456. }
  74457. }
  74458. module "babylonjs/Meshes/abstractMesh" {
  74459. interface AbstractMesh {
  74460. /** @hidden (Backing field) */
  74461. _showBoundingBox: boolean;
  74462. /**
  74463. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  74464. */
  74465. showBoundingBox: boolean;
  74466. }
  74467. }
  74468. /**
  74469. * Component responsible of rendering the bounding box of the meshes in a scene.
  74470. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  74471. */
  74472. export class BoundingBoxRenderer implements ISceneComponent {
  74473. /**
  74474. * The component name helpfull to identify the component in the list of scene components.
  74475. */
  74476. readonly name: string;
  74477. /**
  74478. * The scene the component belongs to.
  74479. */
  74480. scene: Scene;
  74481. /**
  74482. * Color of the bounding box lines placed in front of an object
  74483. */
  74484. frontColor: Color3;
  74485. /**
  74486. * Color of the bounding box lines placed behind an object
  74487. */
  74488. backColor: Color3;
  74489. /**
  74490. * Defines if the renderer should show the back lines or not
  74491. */
  74492. showBackLines: boolean;
  74493. /**
  74494. * Observable raised before rendering a bounding box
  74495. */
  74496. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  74497. /**
  74498. * Observable raised after rendering a bounding box
  74499. */
  74500. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  74501. /**
  74502. * @hidden
  74503. */
  74504. renderList: SmartArray<BoundingBox>;
  74505. private _colorShader;
  74506. private _vertexBuffers;
  74507. private _indexBuffer;
  74508. private _fillIndexBuffer;
  74509. private _fillIndexData;
  74510. /**
  74511. * Instantiates a new bounding box renderer in a scene.
  74512. * @param scene the scene the renderer renders in
  74513. */
  74514. constructor(scene: Scene);
  74515. /**
  74516. * Registers the component in a given scene
  74517. */
  74518. register(): void;
  74519. private _evaluateSubMesh;
  74520. private _activeMesh;
  74521. private _prepareRessources;
  74522. private _createIndexBuffer;
  74523. /**
  74524. * Rebuilds the elements related to this component in case of
  74525. * context lost for instance.
  74526. */
  74527. rebuild(): void;
  74528. /**
  74529. * @hidden
  74530. */
  74531. reset(): void;
  74532. /**
  74533. * Render the bounding boxes of a specific rendering group
  74534. * @param renderingGroupId defines the rendering group to render
  74535. */
  74536. render(renderingGroupId: number): void;
  74537. /**
  74538. * In case of occlusion queries, we can render the occlusion bounding box through this method
  74539. * @param mesh Define the mesh to render the occlusion bounding box for
  74540. */
  74541. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  74542. /**
  74543. * Dispose and release the resources attached to this renderer.
  74544. */
  74545. dispose(): void;
  74546. }
  74547. }
  74548. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  74549. import { Nullable } from "babylonjs/types";
  74550. import { Scene } from "babylonjs/scene";
  74551. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  74552. import { Camera } from "babylonjs/Cameras/camera";
  74553. import { ISceneComponent } from "babylonjs/sceneComponent";
  74554. module "babylonjs/scene" {
  74555. interface Scene {
  74556. /** @hidden (Backing field) */
  74557. _depthRenderer: {
  74558. [id: string]: DepthRenderer;
  74559. };
  74560. /**
  74561. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  74562. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  74563. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  74564. * @returns the created depth renderer
  74565. */
  74566. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  74567. /**
  74568. * Disables a depth renderer for a given camera
  74569. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  74570. */
  74571. disableDepthRenderer(camera?: Nullable<Camera>): void;
  74572. }
  74573. }
  74574. /**
  74575. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  74576. * in several rendering techniques.
  74577. */
  74578. export class DepthRendererSceneComponent implements ISceneComponent {
  74579. /**
  74580. * The component name helpfull to identify the component in the list of scene components.
  74581. */
  74582. readonly name: string;
  74583. /**
  74584. * The scene the component belongs to.
  74585. */
  74586. scene: Scene;
  74587. /**
  74588. * Creates a new instance of the component for the given scene
  74589. * @param scene Defines the scene to register the component in
  74590. */
  74591. constructor(scene: Scene);
  74592. /**
  74593. * Registers the component in a given scene
  74594. */
  74595. register(): void;
  74596. /**
  74597. * Rebuilds the elements related to this component in case of
  74598. * context lost for instance.
  74599. */
  74600. rebuild(): void;
  74601. /**
  74602. * Disposes the component and the associated ressources
  74603. */
  74604. dispose(): void;
  74605. private _gatherRenderTargets;
  74606. private _gatherActiveCameraRenderTargets;
  74607. }
  74608. }
  74609. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  74610. /** @hidden */
  74611. export var fibonacci: {
  74612. name: string;
  74613. shader: string;
  74614. };
  74615. }
  74616. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  74617. /** @hidden */
  74618. export var diffusionProfile: {
  74619. name: string;
  74620. shader: string;
  74621. };
  74622. }
  74623. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  74624. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  74625. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74626. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  74627. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  74628. /** @hidden */
  74629. export var subSurfaceScatteringPixelShader: {
  74630. name: string;
  74631. shader: string;
  74632. };
  74633. }
  74634. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  74635. import { Nullable } from "babylonjs/types";
  74636. import { Camera } from "babylonjs/Cameras/camera";
  74637. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74638. import { Engine } from "babylonjs/Engines/engine";
  74639. import { Scene } from "babylonjs/scene";
  74640. import "babylonjs/Shaders/imageProcessing.fragment";
  74641. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  74642. import "babylonjs/Shaders/postprocess.vertex";
  74643. /**
  74644. * Sub surface scattering post process
  74645. */
  74646. export class SubSurfaceScatteringPostProcess extends PostProcess {
  74647. /** @hidden */
  74648. texelWidth: number;
  74649. /** @hidden */
  74650. texelHeight: number;
  74651. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74652. }
  74653. }
  74654. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  74655. import { Color3 } from "babylonjs/Maths/math.color";
  74656. /**
  74657. * Contains all parameters needed for the prepass to perform
  74658. * screen space subsurface scattering
  74659. */
  74660. export class SubSurfaceConfiguration {
  74661. private _ssDiffusionS;
  74662. private _ssFilterRadii;
  74663. private _ssDiffusionD;
  74664. /**
  74665. * Diffusion profile color for subsurface scattering
  74666. */
  74667. get ssDiffusionS(): number[];
  74668. /**
  74669. * Diffusion profile max color channel value for subsurface scattering
  74670. */
  74671. get ssDiffusionD(): number[];
  74672. /**
  74673. * Diffusion profile filter radius for subsurface scattering
  74674. */
  74675. get ssFilterRadii(): number[];
  74676. /**
  74677. * Diffusion profile colors for subsurface scattering
  74678. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  74679. * See ...
  74680. * Note that you can only store up to 5 of them
  74681. */
  74682. ssDiffusionProfileColors: Color3[];
  74683. /**
  74684. * Defines the ratio real world => scene units.
  74685. * Used for subsurface scattering
  74686. */
  74687. metersPerUnit: number;
  74688. /**
  74689. * Builds a subsurface configuration object
  74690. * @param scene The scene
  74691. */
  74692. constructor();
  74693. /**
  74694. * Adds a new diffusion profile.
  74695. * Useful for more realistic subsurface scattering on diverse materials.
  74696. * @param color The color of the diffusion profile. Should be the average color of the material.
  74697. * @return The index of the diffusion profile for the material subsurface configuration
  74698. */
  74699. addDiffusionProfile(color: Color3): number;
  74700. /**
  74701. * Deletes all diffusion profiles.
  74702. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  74703. */
  74704. clearAllDiffusionProfiles(): void;
  74705. /**
  74706. * Disposes this object
  74707. */
  74708. dispose(): void;
  74709. /**
  74710. * @hidden
  74711. * https://zero-radiance.github.io/post/sampling-diffusion/
  74712. *
  74713. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  74714. * ------------------------------------------------------------------------------------
  74715. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  74716. * PDF[r, phi, s] = r * R[r, phi, s]
  74717. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  74718. * ------------------------------------------------------------------------------------
  74719. * We importance sample the color channel with the widest scattering distance.
  74720. */
  74721. getDiffusionProfileParameters(color: Color3): number;
  74722. /**
  74723. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  74724. * 'u' is the random number (the value of the CDF): [0, 1).
  74725. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  74726. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  74727. */
  74728. private _sampleBurleyDiffusionProfile;
  74729. }
  74730. }
  74731. declare module "babylonjs/Rendering/prePassRenderer" {
  74732. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  74733. import { Scene } from "babylonjs/scene";
  74734. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74735. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  74736. import { Effect } from "babylonjs/Materials/effect";
  74737. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  74738. /**
  74739. * Renders a pre pass of the scene
  74740. * This means every mesh in the scene will be rendered to a render target texture
  74741. * And then this texture will be composited to the rendering canvas with post processes
  74742. * It is necessary for effects like subsurface scattering or deferred shading
  74743. */
  74744. export class PrePassRenderer {
  74745. /** @hidden */
  74746. static _SceneComponentInitialization: (scene: Scene) => void;
  74747. private _scene;
  74748. private _engine;
  74749. private _isDirty;
  74750. /**
  74751. * Number of textures in the multi render target texture where the scene is directly rendered
  74752. */
  74753. readonly mrtCount: number;
  74754. /**
  74755. * The render target where the scene is directly rendered
  74756. */
  74757. prePassRT: MultiRenderTarget;
  74758. private _mrtTypes;
  74759. private _multiRenderAttachments;
  74760. private _defaultAttachments;
  74761. private _clearAttachments;
  74762. private readonly _clearColor;
  74763. /**
  74764. * Image processing post process for composition
  74765. */
  74766. imageProcessingPostProcess: ImageProcessingPostProcess;
  74767. /**
  74768. * Post process for subsurface scattering
  74769. */
  74770. subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
  74771. /**
  74772. * Configuration for sub surface scattering post process
  74773. */
  74774. subSurfaceConfiguration: SubSurfaceConfiguration;
  74775. private _enabled;
  74776. /**
  74777. * Indicates if the prepass is enabled
  74778. */
  74779. get enabled(): boolean;
  74780. /**
  74781. * How many samples are used for MSAA of the scene render target
  74782. */
  74783. get samples(): number;
  74784. set samples(n: number);
  74785. /**
  74786. * Instanciates a prepass renderer
  74787. * @param scene The scene
  74788. */
  74789. constructor(scene: Scene);
  74790. private _initializeAttachments;
  74791. private _createEffects;
  74792. /**
  74793. * Indicates if rendering a prepass is supported
  74794. */
  74795. get isSupported(): boolean;
  74796. /**
  74797. * Sets the proper output textures to draw in the engine.
  74798. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  74799. */
  74800. bindAttachmentsForEffect(effect: Effect): void;
  74801. /**
  74802. * @hidden
  74803. */
  74804. _beforeCameraDraw(): void;
  74805. /**
  74806. * @hidden
  74807. */
  74808. _afterCameraDraw(): void;
  74809. private _checkRTSize;
  74810. private _bindFrameBuffer;
  74811. /**
  74812. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  74813. */
  74814. clear(): void;
  74815. private _setState;
  74816. private _enable;
  74817. private _disable;
  74818. /**
  74819. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  74820. */
  74821. markAsDirty(): void;
  74822. private _update;
  74823. /**
  74824. * Disposes the prepass renderer.
  74825. */
  74826. dispose(): void;
  74827. }
  74828. }
  74829. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  74830. import { Nullable } from "babylonjs/types";
  74831. import { Scene } from "babylonjs/scene";
  74832. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  74833. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74834. import { AbstractScene } from "babylonjs/abstractScene";
  74835. module "babylonjs/abstractScene" {
  74836. interface AbstractScene {
  74837. /** @hidden (Backing field) */
  74838. _prePassRenderer: Nullable<PrePassRenderer>;
  74839. /**
  74840. * Gets or Sets the current prepass renderer associated to the scene.
  74841. */
  74842. prePassRenderer: Nullable<PrePassRenderer>;
  74843. /**
  74844. * Enables the prepass and associates it with the scene
  74845. * @returns the PrePassRenderer
  74846. */
  74847. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  74848. /**
  74849. * Disables the prepass associated with the scene
  74850. */
  74851. disablePrePassRenderer(): void;
  74852. }
  74853. }
  74854. /**
  74855. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74856. * in several rendering techniques.
  74857. */
  74858. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  74859. /**
  74860. * The component name helpful to identify the component in the list of scene components.
  74861. */
  74862. readonly name: string;
  74863. /**
  74864. * The scene the component belongs to.
  74865. */
  74866. scene: Scene;
  74867. /**
  74868. * Creates a new instance of the component for the given scene
  74869. * @param scene Defines the scene to register the component in
  74870. */
  74871. constructor(scene: Scene);
  74872. /**
  74873. * Registers the component in a given scene
  74874. */
  74875. register(): void;
  74876. private _beforeCameraDraw;
  74877. private _afterCameraDraw;
  74878. private _beforeClearStage;
  74879. /**
  74880. * Serializes the component data to the specified json object
  74881. * @param serializationObject The object to serialize to
  74882. */
  74883. serialize(serializationObject: any): void;
  74884. /**
  74885. * Adds all the elements from the container to the scene
  74886. * @param container the container holding the elements
  74887. */
  74888. addFromContainer(container: AbstractScene): void;
  74889. /**
  74890. * Removes all the elements in the container from the scene
  74891. * @param container contains the elements to remove
  74892. * @param dispose if the removed element should be disposed (default: false)
  74893. */
  74894. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  74895. /**
  74896. * Rebuilds the elements related to this component in case of
  74897. * context lost for instance.
  74898. */
  74899. rebuild(): void;
  74900. /**
  74901. * Disposes the component and the associated ressources
  74902. */
  74903. dispose(): void;
  74904. }
  74905. }
  74906. declare module "babylonjs/Shaders/outline.fragment" {
  74907. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74908. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  74909. /** @hidden */
  74910. export var outlinePixelShader: {
  74911. name: string;
  74912. shader: string;
  74913. };
  74914. }
  74915. declare module "babylonjs/Shaders/outline.vertex" {
  74916. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74917. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74918. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74919. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74920. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74921. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74922. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74923. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74924. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  74925. /** @hidden */
  74926. export var outlineVertexShader: {
  74927. name: string;
  74928. shader: string;
  74929. };
  74930. }
  74931. declare module "babylonjs/Rendering/outlineRenderer" {
  74932. import { SubMesh } from "babylonjs/Meshes/subMesh";
  74933. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  74934. import { Scene } from "babylonjs/scene";
  74935. import { ISceneComponent } from "babylonjs/sceneComponent";
  74936. import "babylonjs/Shaders/outline.fragment";
  74937. import "babylonjs/Shaders/outline.vertex";
  74938. module "babylonjs/scene" {
  74939. interface Scene {
  74940. /** @hidden */
  74941. _outlineRenderer: OutlineRenderer;
  74942. /**
  74943. * Gets the outline renderer associated with the scene
  74944. * @returns a OutlineRenderer
  74945. */
  74946. getOutlineRenderer(): OutlineRenderer;
  74947. }
  74948. }
  74949. module "babylonjs/Meshes/abstractMesh" {
  74950. interface AbstractMesh {
  74951. /** @hidden (Backing field) */
  74952. _renderOutline: boolean;
  74953. /**
  74954. * Gets or sets a boolean indicating if the outline must be rendered as well
  74955. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  74956. */
  74957. renderOutline: boolean;
  74958. /** @hidden (Backing field) */
  74959. _renderOverlay: boolean;
  74960. /**
  74961. * Gets or sets a boolean indicating if the overlay must be rendered as well
  74962. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  74963. */
  74964. renderOverlay: boolean;
  74965. }
  74966. }
  74967. /**
  74968. * This class is responsible to draw bothe outline/overlay of meshes.
  74969. * It should not be used directly but through the available method on mesh.
  74970. */
  74971. export class OutlineRenderer implements ISceneComponent {
  74972. /**
  74973. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  74974. */
  74975. private static _StencilReference;
  74976. /**
  74977. * The name of the component. Each component must have a unique name.
  74978. */
  74979. name: string;
  74980. /**
  74981. * The scene the component belongs to.
  74982. */
  74983. scene: Scene;
  74984. /**
  74985. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  74986. */
  74987. zOffset: number;
  74988. private _engine;
  74989. private _effect;
  74990. private _cachedDefines;
  74991. private _savedDepthWrite;
  74992. /**
  74993. * Instantiates a new outline renderer. (There could be only one per scene).
  74994. * @param scene Defines the scene it belongs to
  74995. */
  74996. constructor(scene: Scene);
  74997. /**
  74998. * Register the component to one instance of a scene.
  74999. */
  75000. register(): void;
  75001. /**
  75002. * Rebuilds the elements related to this component in case of
  75003. * context lost for instance.
  75004. */
  75005. rebuild(): void;
  75006. /**
  75007. * Disposes the component and the associated ressources.
  75008. */
  75009. dispose(): void;
  75010. /**
  75011. * Renders the outline in the canvas.
  75012. * @param subMesh Defines the sumesh to render
  75013. * @param batch Defines the batch of meshes in case of instances
  75014. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75015. */
  75016. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75017. /**
  75018. * Returns whether or not the outline renderer is ready for a given submesh.
  75019. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75020. * @param subMesh Defines the submesh to check readyness for
  75021. * @param useInstances Defines wheter wee are trying to render instances or not
  75022. * @returns true if ready otherwise false
  75023. */
  75024. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75025. private _beforeRenderingMesh;
  75026. private _afterRenderingMesh;
  75027. }
  75028. }
  75029. declare module "babylonjs/Rendering/index" {
  75030. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75031. export * from "babylonjs/Rendering/depthRenderer";
  75032. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75033. export * from "babylonjs/Rendering/edgesRenderer";
  75034. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75035. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75036. export * from "babylonjs/Rendering/prePassRenderer";
  75037. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75038. export * from "babylonjs/Rendering/outlineRenderer";
  75039. export * from "babylonjs/Rendering/renderingGroup";
  75040. export * from "babylonjs/Rendering/renderingManager";
  75041. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75042. }
  75043. declare module "babylonjs/Sprites/ISprites" {
  75044. /**
  75045. * Defines the basic options interface of a Sprite Frame Source Size.
  75046. */
  75047. export interface ISpriteJSONSpriteSourceSize {
  75048. /**
  75049. * number of the original width of the Frame
  75050. */
  75051. w: number;
  75052. /**
  75053. * number of the original height of the Frame
  75054. */
  75055. h: number;
  75056. }
  75057. /**
  75058. * Defines the basic options interface of a Sprite Frame Data.
  75059. */
  75060. export interface ISpriteJSONSpriteFrameData {
  75061. /**
  75062. * number of the x offset of the Frame
  75063. */
  75064. x: number;
  75065. /**
  75066. * number of the y offset of the Frame
  75067. */
  75068. y: number;
  75069. /**
  75070. * number of the width of the Frame
  75071. */
  75072. w: number;
  75073. /**
  75074. * number of the height of the Frame
  75075. */
  75076. h: number;
  75077. }
  75078. /**
  75079. * Defines the basic options interface of a JSON Sprite.
  75080. */
  75081. export interface ISpriteJSONSprite {
  75082. /**
  75083. * string name of the Frame
  75084. */
  75085. filename: string;
  75086. /**
  75087. * ISpriteJSONSpriteFrame basic object of the frame data
  75088. */
  75089. frame: ISpriteJSONSpriteFrameData;
  75090. /**
  75091. * boolean to flag is the frame was rotated.
  75092. */
  75093. rotated: boolean;
  75094. /**
  75095. * boolean to flag is the frame was trimmed.
  75096. */
  75097. trimmed: boolean;
  75098. /**
  75099. * ISpriteJSONSpriteFrame basic object of the source data
  75100. */
  75101. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75102. /**
  75103. * ISpriteJSONSpriteFrame basic object of the source data
  75104. */
  75105. sourceSize: ISpriteJSONSpriteSourceSize;
  75106. }
  75107. /**
  75108. * Defines the basic options interface of a JSON atlas.
  75109. */
  75110. export interface ISpriteJSONAtlas {
  75111. /**
  75112. * Array of objects that contain the frame data.
  75113. */
  75114. frames: Array<ISpriteJSONSprite>;
  75115. /**
  75116. * object basic object containing the sprite meta data.
  75117. */
  75118. meta?: object;
  75119. }
  75120. }
  75121. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75122. /** @hidden */
  75123. export var spriteMapPixelShader: {
  75124. name: string;
  75125. shader: string;
  75126. };
  75127. }
  75128. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75129. /** @hidden */
  75130. export var spriteMapVertexShader: {
  75131. name: string;
  75132. shader: string;
  75133. };
  75134. }
  75135. declare module "babylonjs/Sprites/spriteMap" {
  75136. import { IDisposable, Scene } from "babylonjs/scene";
  75137. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75138. import { Texture } from "babylonjs/Materials/Textures/texture";
  75139. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75140. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75141. import "babylonjs/Meshes/Builders/planeBuilder";
  75142. import "babylonjs/Shaders/spriteMap.fragment";
  75143. import "babylonjs/Shaders/spriteMap.vertex";
  75144. /**
  75145. * Defines the basic options interface of a SpriteMap
  75146. */
  75147. export interface ISpriteMapOptions {
  75148. /**
  75149. * Vector2 of the number of cells in the grid.
  75150. */
  75151. stageSize?: Vector2;
  75152. /**
  75153. * Vector2 of the size of the output plane in World Units.
  75154. */
  75155. outputSize?: Vector2;
  75156. /**
  75157. * Vector3 of the position of the output plane in World Units.
  75158. */
  75159. outputPosition?: Vector3;
  75160. /**
  75161. * Vector3 of the rotation of the output plane.
  75162. */
  75163. outputRotation?: Vector3;
  75164. /**
  75165. * number of layers that the system will reserve in resources.
  75166. */
  75167. layerCount?: number;
  75168. /**
  75169. * number of max animation frames a single cell will reserve in resources.
  75170. */
  75171. maxAnimationFrames?: number;
  75172. /**
  75173. * number cell index of the base tile when the system compiles.
  75174. */
  75175. baseTile?: number;
  75176. /**
  75177. * boolean flip the sprite after its been repositioned by the framing data.
  75178. */
  75179. flipU?: boolean;
  75180. /**
  75181. * Vector3 scalar of the global RGB values of the SpriteMap.
  75182. */
  75183. colorMultiply?: Vector3;
  75184. }
  75185. /**
  75186. * Defines the IDisposable interface in order to be cleanable from resources.
  75187. */
  75188. export interface ISpriteMap extends IDisposable {
  75189. /**
  75190. * String name of the SpriteMap.
  75191. */
  75192. name: string;
  75193. /**
  75194. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75195. */
  75196. atlasJSON: ISpriteJSONAtlas;
  75197. /**
  75198. * Texture of the SpriteMap.
  75199. */
  75200. spriteSheet: Texture;
  75201. /**
  75202. * The parameters to initialize the SpriteMap with.
  75203. */
  75204. options: ISpriteMapOptions;
  75205. }
  75206. /**
  75207. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75208. */
  75209. export class SpriteMap implements ISpriteMap {
  75210. /** The Name of the spriteMap */
  75211. name: string;
  75212. /** The JSON file with the frame and meta data */
  75213. atlasJSON: ISpriteJSONAtlas;
  75214. /** The systems Sprite Sheet Texture */
  75215. spriteSheet: Texture;
  75216. /** Arguments passed with the Constructor */
  75217. options: ISpriteMapOptions;
  75218. /** Public Sprite Storage array, parsed from atlasJSON */
  75219. sprites: Array<ISpriteJSONSprite>;
  75220. /** Returns the Number of Sprites in the System */
  75221. get spriteCount(): number;
  75222. /** Returns the Position of Output Plane*/
  75223. get position(): Vector3;
  75224. /** Returns the Position of Output Plane*/
  75225. set position(v: Vector3);
  75226. /** Returns the Rotation of Output Plane*/
  75227. get rotation(): Vector3;
  75228. /** Returns the Rotation of Output Plane*/
  75229. set rotation(v: Vector3);
  75230. /** Sets the AnimationMap*/
  75231. get animationMap(): RawTexture;
  75232. /** Sets the AnimationMap*/
  75233. set animationMap(v: RawTexture);
  75234. /** Scene that the SpriteMap was created in */
  75235. private _scene;
  75236. /** Texture Buffer of Float32 that holds tile frame data*/
  75237. private _frameMap;
  75238. /** Texture Buffers of Float32 that holds tileMap data*/
  75239. private _tileMaps;
  75240. /** Texture Buffer of Float32 that holds Animation Data*/
  75241. private _animationMap;
  75242. /** Custom ShaderMaterial Central to the System*/
  75243. private _material;
  75244. /** Custom ShaderMaterial Central to the System*/
  75245. private _output;
  75246. /** Systems Time Ticker*/
  75247. private _time;
  75248. /**
  75249. * Creates a new SpriteMap
  75250. * @param name defines the SpriteMaps Name
  75251. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75252. * @param spriteSheet is the Texture that the Sprites are on.
  75253. * @param options a basic deployment configuration
  75254. * @param scene The Scene that the map is deployed on
  75255. */
  75256. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75257. /**
  75258. * Returns tileID location
  75259. * @returns Vector2 the cell position ID
  75260. */
  75261. getTileID(): Vector2;
  75262. /**
  75263. * Gets the UV location of the mouse over the SpriteMap.
  75264. * @returns Vector2 the UV position of the mouse interaction
  75265. */
  75266. getMousePosition(): Vector2;
  75267. /**
  75268. * Creates the "frame" texture Buffer
  75269. * -------------------------------------
  75270. * Structure of frames
  75271. * "filename": "Falling-Water-2.png",
  75272. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75273. * "rotated": true,
  75274. * "trimmed": true,
  75275. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75276. * "sourceSize": {"w":32,"h":32}
  75277. * @returns RawTexture of the frameMap
  75278. */
  75279. private _createFrameBuffer;
  75280. /**
  75281. * Creates the tileMap texture Buffer
  75282. * @param buffer normally and array of numbers, or a false to generate from scratch
  75283. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75284. * @returns RawTexture of the tileMap
  75285. */
  75286. private _createTileBuffer;
  75287. /**
  75288. * Modifies the data of the tileMaps
  75289. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75290. * @param pos is the iVector2 Coordinates of the Tile
  75291. * @param tile The SpriteIndex of the new Tile
  75292. */
  75293. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75294. /**
  75295. * Creates the animationMap texture Buffer
  75296. * @param buffer normally and array of numbers, or a false to generate from scratch
  75297. * @returns RawTexture of the animationMap
  75298. */
  75299. private _createTileAnimationBuffer;
  75300. /**
  75301. * Modifies the data of the animationMap
  75302. * @param cellID is the Index of the Sprite
  75303. * @param _frame is the target Animation frame
  75304. * @param toCell is the Target Index of the next frame of the animation
  75305. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75306. * @param speed is a global scalar of the time variable on the map.
  75307. */
  75308. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  75309. /**
  75310. * Exports the .tilemaps file
  75311. */
  75312. saveTileMaps(): void;
  75313. /**
  75314. * Imports the .tilemaps file
  75315. * @param url of the .tilemaps file
  75316. */
  75317. loadTileMaps(url: string): void;
  75318. /**
  75319. * Release associated resources
  75320. */
  75321. dispose(): void;
  75322. }
  75323. }
  75324. declare module "babylonjs/Sprites/spritePackedManager" {
  75325. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  75326. import { Scene } from "babylonjs/scene";
  75327. /**
  75328. * Class used to manage multiple sprites of different sizes on the same spritesheet
  75329. * @see https://doc.babylonjs.com/babylon101/sprites
  75330. */
  75331. export class SpritePackedManager extends SpriteManager {
  75332. /** defines the packed manager's name */
  75333. name: string;
  75334. /**
  75335. * Creates a new sprite manager from a packed sprite sheet
  75336. * @param name defines the manager's name
  75337. * @param imgUrl defines the sprite sheet url
  75338. * @param capacity defines the maximum allowed number of sprites
  75339. * @param scene defines the hosting scene
  75340. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  75341. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75342. * @param samplingMode defines the smapling mode to use with spritesheet
  75343. * @param fromPacked set to true; do not alter
  75344. */
  75345. constructor(
  75346. /** defines the packed manager's name */
  75347. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  75348. }
  75349. }
  75350. declare module "babylonjs/Sprites/index" {
  75351. export * from "babylonjs/Sprites/sprite";
  75352. export * from "babylonjs/Sprites/ISprites";
  75353. export * from "babylonjs/Sprites/spriteManager";
  75354. export * from "babylonjs/Sprites/spriteMap";
  75355. export * from "babylonjs/Sprites/spritePackedManager";
  75356. export * from "babylonjs/Sprites/spriteSceneComponent";
  75357. }
  75358. declare module "babylonjs/States/index" {
  75359. export * from "babylonjs/States/alphaCullingState";
  75360. export * from "babylonjs/States/depthCullingState";
  75361. export * from "babylonjs/States/stencilState";
  75362. }
  75363. declare module "babylonjs/Misc/assetsManager" {
  75364. import { Scene } from "babylonjs/scene";
  75365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75366. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75367. import { Skeleton } from "babylonjs/Bones/skeleton";
  75368. import { Observable } from "babylonjs/Misc/observable";
  75369. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  75370. import { Texture } from "babylonjs/Materials/Textures/texture";
  75371. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  75372. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  75373. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  75374. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  75375. /**
  75376. * Defines the list of states available for a task inside a AssetsManager
  75377. */
  75378. export enum AssetTaskState {
  75379. /**
  75380. * Initialization
  75381. */
  75382. INIT = 0,
  75383. /**
  75384. * Running
  75385. */
  75386. RUNNING = 1,
  75387. /**
  75388. * Done
  75389. */
  75390. DONE = 2,
  75391. /**
  75392. * Error
  75393. */
  75394. ERROR = 3
  75395. }
  75396. /**
  75397. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  75398. */
  75399. export abstract class AbstractAssetTask {
  75400. /**
  75401. * Task name
  75402. */ name: string;
  75403. /**
  75404. * Callback called when the task is successful
  75405. */
  75406. onSuccess: (task: any) => void;
  75407. /**
  75408. * Callback called when the task is not successful
  75409. */
  75410. onError: (task: any, message?: string, exception?: any) => void;
  75411. /**
  75412. * Creates a new AssetsManager
  75413. * @param name defines the name of the task
  75414. */
  75415. constructor(
  75416. /**
  75417. * Task name
  75418. */ name: string);
  75419. private _isCompleted;
  75420. private _taskState;
  75421. private _errorObject;
  75422. /**
  75423. * Get if the task is completed
  75424. */
  75425. get isCompleted(): boolean;
  75426. /**
  75427. * Gets the current state of the task
  75428. */
  75429. get taskState(): AssetTaskState;
  75430. /**
  75431. * Gets the current error object (if task is in error)
  75432. */
  75433. get errorObject(): {
  75434. message?: string;
  75435. exception?: any;
  75436. };
  75437. /**
  75438. * Internal only
  75439. * @hidden
  75440. */
  75441. _setErrorObject(message?: string, exception?: any): void;
  75442. /**
  75443. * Execute the current task
  75444. * @param scene defines the scene where you want your assets to be loaded
  75445. * @param onSuccess is a callback called when the task is successfully executed
  75446. * @param onError is a callback called if an error occurs
  75447. */
  75448. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75449. /**
  75450. * Execute the current task
  75451. * @param scene defines the scene where you want your assets to be loaded
  75452. * @param onSuccess is a callback called when the task is successfully executed
  75453. * @param onError is a callback called if an error occurs
  75454. */
  75455. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75456. /**
  75457. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  75458. * This can be used with failed tasks that have the reason for failure fixed.
  75459. */
  75460. reset(): void;
  75461. private onErrorCallback;
  75462. private onDoneCallback;
  75463. }
  75464. /**
  75465. * Define the interface used by progress events raised during assets loading
  75466. */
  75467. export interface IAssetsProgressEvent {
  75468. /**
  75469. * Defines the number of remaining tasks to process
  75470. */
  75471. remainingCount: number;
  75472. /**
  75473. * Defines the total number of tasks
  75474. */
  75475. totalCount: number;
  75476. /**
  75477. * Defines the task that was just processed
  75478. */
  75479. task: AbstractAssetTask;
  75480. }
  75481. /**
  75482. * Class used to share progress information about assets loading
  75483. */
  75484. export class AssetsProgressEvent implements IAssetsProgressEvent {
  75485. /**
  75486. * Defines the number of remaining tasks to process
  75487. */
  75488. remainingCount: number;
  75489. /**
  75490. * Defines the total number of tasks
  75491. */
  75492. totalCount: number;
  75493. /**
  75494. * Defines the task that was just processed
  75495. */
  75496. task: AbstractAssetTask;
  75497. /**
  75498. * Creates a AssetsProgressEvent
  75499. * @param remainingCount defines the number of remaining tasks to process
  75500. * @param totalCount defines the total number of tasks
  75501. * @param task defines the task that was just processed
  75502. */
  75503. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  75504. }
  75505. /**
  75506. * Define a task used by AssetsManager to load meshes
  75507. */
  75508. export class MeshAssetTask extends AbstractAssetTask {
  75509. /**
  75510. * Defines the name of the task
  75511. */
  75512. name: string;
  75513. /**
  75514. * Defines the list of mesh's names you want to load
  75515. */
  75516. meshesNames: any;
  75517. /**
  75518. * Defines the root url to use as a base to load your meshes and associated resources
  75519. */
  75520. rootUrl: string;
  75521. /**
  75522. * Defines the filename or File of the scene to load from
  75523. */
  75524. sceneFilename: string | File;
  75525. /**
  75526. * Gets the list of loaded meshes
  75527. */
  75528. loadedMeshes: Array<AbstractMesh>;
  75529. /**
  75530. * Gets the list of loaded particle systems
  75531. */
  75532. loadedParticleSystems: Array<IParticleSystem>;
  75533. /**
  75534. * Gets the list of loaded skeletons
  75535. */
  75536. loadedSkeletons: Array<Skeleton>;
  75537. /**
  75538. * Gets the list of loaded animation groups
  75539. */
  75540. loadedAnimationGroups: Array<AnimationGroup>;
  75541. /**
  75542. * Callback called when the task is successful
  75543. */
  75544. onSuccess: (task: MeshAssetTask) => void;
  75545. /**
  75546. * Callback called when the task is successful
  75547. */
  75548. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  75549. /**
  75550. * Creates a new MeshAssetTask
  75551. * @param name defines the name of the task
  75552. * @param meshesNames defines the list of mesh's names you want to load
  75553. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  75554. * @param sceneFilename defines the filename or File of the scene to load from
  75555. */
  75556. constructor(
  75557. /**
  75558. * Defines the name of the task
  75559. */
  75560. name: string,
  75561. /**
  75562. * Defines the list of mesh's names you want to load
  75563. */
  75564. meshesNames: any,
  75565. /**
  75566. * Defines the root url to use as a base to load your meshes and associated resources
  75567. */
  75568. rootUrl: string,
  75569. /**
  75570. * Defines the filename or File of the scene to load from
  75571. */
  75572. sceneFilename: string | File);
  75573. /**
  75574. * Execute the current task
  75575. * @param scene defines the scene where you want your assets to be loaded
  75576. * @param onSuccess is a callback called when the task is successfully executed
  75577. * @param onError is a callback called if an error occurs
  75578. */
  75579. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75580. }
  75581. /**
  75582. * Define a task used by AssetsManager to load text content
  75583. */
  75584. export class TextFileAssetTask extends AbstractAssetTask {
  75585. /**
  75586. * Defines the name of the task
  75587. */
  75588. name: string;
  75589. /**
  75590. * Defines the location of the file to load
  75591. */
  75592. url: string;
  75593. /**
  75594. * Gets the loaded text string
  75595. */
  75596. text: string;
  75597. /**
  75598. * Callback called when the task is successful
  75599. */
  75600. onSuccess: (task: TextFileAssetTask) => void;
  75601. /**
  75602. * Callback called when the task is successful
  75603. */
  75604. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  75605. /**
  75606. * Creates a new TextFileAssetTask object
  75607. * @param name defines the name of the task
  75608. * @param url defines the location of the file to load
  75609. */
  75610. constructor(
  75611. /**
  75612. * Defines the name of the task
  75613. */
  75614. name: string,
  75615. /**
  75616. * Defines the location of the file to load
  75617. */
  75618. url: string);
  75619. /**
  75620. * Execute the current task
  75621. * @param scene defines the scene where you want your assets to be loaded
  75622. * @param onSuccess is a callback called when the task is successfully executed
  75623. * @param onError is a callback called if an error occurs
  75624. */
  75625. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75626. }
  75627. /**
  75628. * Define a task used by AssetsManager to load binary data
  75629. */
  75630. export class BinaryFileAssetTask extends AbstractAssetTask {
  75631. /**
  75632. * Defines the name of the task
  75633. */
  75634. name: string;
  75635. /**
  75636. * Defines the location of the file to load
  75637. */
  75638. url: string;
  75639. /**
  75640. * Gets the lodaded data (as an array buffer)
  75641. */
  75642. data: ArrayBuffer;
  75643. /**
  75644. * Callback called when the task is successful
  75645. */
  75646. onSuccess: (task: BinaryFileAssetTask) => void;
  75647. /**
  75648. * Callback called when the task is successful
  75649. */
  75650. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  75651. /**
  75652. * Creates a new BinaryFileAssetTask object
  75653. * @param name defines the name of the new task
  75654. * @param url defines the location of the file to load
  75655. */
  75656. constructor(
  75657. /**
  75658. * Defines the name of the task
  75659. */
  75660. name: string,
  75661. /**
  75662. * Defines the location of the file to load
  75663. */
  75664. url: string);
  75665. /**
  75666. * Execute the current task
  75667. * @param scene defines the scene where you want your assets to be loaded
  75668. * @param onSuccess is a callback called when the task is successfully executed
  75669. * @param onError is a callback called if an error occurs
  75670. */
  75671. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75672. }
  75673. /**
  75674. * Define a task used by AssetsManager to load images
  75675. */
  75676. export class ImageAssetTask extends AbstractAssetTask {
  75677. /**
  75678. * Defines the name of the task
  75679. */
  75680. name: string;
  75681. /**
  75682. * Defines the location of the image to load
  75683. */
  75684. url: string;
  75685. /**
  75686. * Gets the loaded images
  75687. */
  75688. image: HTMLImageElement;
  75689. /**
  75690. * Callback called when the task is successful
  75691. */
  75692. onSuccess: (task: ImageAssetTask) => void;
  75693. /**
  75694. * Callback called when the task is successful
  75695. */
  75696. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  75697. /**
  75698. * Creates a new ImageAssetTask
  75699. * @param name defines the name of the task
  75700. * @param url defines the location of the image to load
  75701. */
  75702. constructor(
  75703. /**
  75704. * Defines the name of the task
  75705. */
  75706. name: string,
  75707. /**
  75708. * Defines the location of the image to load
  75709. */
  75710. url: string);
  75711. /**
  75712. * Execute the current task
  75713. * @param scene defines the scene where you want your assets to be loaded
  75714. * @param onSuccess is a callback called when the task is successfully executed
  75715. * @param onError is a callback called if an error occurs
  75716. */
  75717. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75718. }
  75719. /**
  75720. * Defines the interface used by texture loading tasks
  75721. */
  75722. export interface ITextureAssetTask<TEX extends BaseTexture> {
  75723. /**
  75724. * Gets the loaded texture
  75725. */
  75726. texture: TEX;
  75727. }
  75728. /**
  75729. * Define a task used by AssetsManager to load 2D textures
  75730. */
  75731. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  75732. /**
  75733. * Defines the name of the task
  75734. */
  75735. name: string;
  75736. /**
  75737. * Defines the location of the file to load
  75738. */
  75739. url: string;
  75740. /**
  75741. * Defines if mipmap should not be generated (default is false)
  75742. */
  75743. noMipmap?: boolean | undefined;
  75744. /**
  75745. * Defines if texture must be inverted on Y axis (default is true)
  75746. */
  75747. invertY: boolean;
  75748. /**
  75749. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75750. */
  75751. samplingMode: number;
  75752. /**
  75753. * Gets the loaded texture
  75754. */
  75755. texture: Texture;
  75756. /**
  75757. * Callback called when the task is successful
  75758. */
  75759. onSuccess: (task: TextureAssetTask) => void;
  75760. /**
  75761. * Callback called when the task is successful
  75762. */
  75763. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  75764. /**
  75765. * Creates a new TextureAssetTask object
  75766. * @param name defines the name of the task
  75767. * @param url defines the location of the file to load
  75768. * @param noMipmap defines if mipmap should not be generated (default is false)
  75769. * @param invertY defines if texture must be inverted on Y axis (default is true)
  75770. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75771. */
  75772. constructor(
  75773. /**
  75774. * Defines the name of the task
  75775. */
  75776. name: string,
  75777. /**
  75778. * Defines the location of the file to load
  75779. */
  75780. url: string,
  75781. /**
  75782. * Defines if mipmap should not be generated (default is false)
  75783. */
  75784. noMipmap?: boolean | undefined,
  75785. /**
  75786. * Defines if texture must be inverted on Y axis (default is true)
  75787. */
  75788. invertY?: boolean,
  75789. /**
  75790. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75791. */
  75792. samplingMode?: number);
  75793. /**
  75794. * Execute the current task
  75795. * @param scene defines the scene where you want your assets to be loaded
  75796. * @param onSuccess is a callback called when the task is successfully executed
  75797. * @param onError is a callback called if an error occurs
  75798. */
  75799. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75800. }
  75801. /**
  75802. * Define a task used by AssetsManager to load cube textures
  75803. */
  75804. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  75805. /**
  75806. * Defines the name of the task
  75807. */
  75808. name: string;
  75809. /**
  75810. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75811. */
  75812. url: string;
  75813. /**
  75814. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75815. */
  75816. extensions?: string[] | undefined;
  75817. /**
  75818. * Defines if mipmaps should not be generated (default is false)
  75819. */
  75820. noMipmap?: boolean | undefined;
  75821. /**
  75822. * Defines the explicit list of files (undefined by default)
  75823. */
  75824. files?: string[] | undefined;
  75825. /**
  75826. * Gets the loaded texture
  75827. */
  75828. texture: CubeTexture;
  75829. /**
  75830. * Callback called when the task is successful
  75831. */
  75832. onSuccess: (task: CubeTextureAssetTask) => void;
  75833. /**
  75834. * Callback called when the task is successful
  75835. */
  75836. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  75837. /**
  75838. * Creates a new CubeTextureAssetTask
  75839. * @param name defines the name of the task
  75840. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75841. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75842. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75843. * @param files defines the explicit list of files (undefined by default)
  75844. */
  75845. constructor(
  75846. /**
  75847. * Defines the name of the task
  75848. */
  75849. name: string,
  75850. /**
  75851. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75852. */
  75853. url: string,
  75854. /**
  75855. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75856. */
  75857. extensions?: string[] | undefined,
  75858. /**
  75859. * Defines if mipmaps should not be generated (default is false)
  75860. */
  75861. noMipmap?: boolean | undefined,
  75862. /**
  75863. * Defines the explicit list of files (undefined by default)
  75864. */
  75865. files?: string[] | undefined);
  75866. /**
  75867. * Execute the current task
  75868. * @param scene defines the scene where you want your assets to be loaded
  75869. * @param onSuccess is a callback called when the task is successfully executed
  75870. * @param onError is a callback called if an error occurs
  75871. */
  75872. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75873. }
  75874. /**
  75875. * Define a task used by AssetsManager to load HDR cube textures
  75876. */
  75877. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  75878. /**
  75879. * Defines the name of the task
  75880. */
  75881. name: string;
  75882. /**
  75883. * Defines the location of the file to load
  75884. */
  75885. url: string;
  75886. /**
  75887. * Defines the desired size (the more it increases the longer the generation will be)
  75888. */
  75889. size: number;
  75890. /**
  75891. * Defines if mipmaps should not be generated (default is false)
  75892. */
  75893. noMipmap: boolean;
  75894. /**
  75895. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75896. */
  75897. generateHarmonics: boolean;
  75898. /**
  75899. * 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)
  75900. */
  75901. gammaSpace: boolean;
  75902. /**
  75903. * Internal Use Only
  75904. */
  75905. reserved: boolean;
  75906. /**
  75907. * Gets the loaded texture
  75908. */
  75909. texture: HDRCubeTexture;
  75910. /**
  75911. * Callback called when the task is successful
  75912. */
  75913. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  75914. /**
  75915. * Callback called when the task is successful
  75916. */
  75917. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  75918. /**
  75919. * Creates a new HDRCubeTextureAssetTask object
  75920. * @param name defines the name of the task
  75921. * @param url defines the location of the file to load
  75922. * @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.
  75923. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75924. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75925. * @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)
  75926. * @param reserved Internal use only
  75927. */
  75928. constructor(
  75929. /**
  75930. * Defines the name of the task
  75931. */
  75932. name: string,
  75933. /**
  75934. * Defines the location of the file to load
  75935. */
  75936. url: string,
  75937. /**
  75938. * Defines the desired size (the more it increases the longer the generation will be)
  75939. */
  75940. size: number,
  75941. /**
  75942. * Defines if mipmaps should not be generated (default is false)
  75943. */
  75944. noMipmap?: boolean,
  75945. /**
  75946. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75947. */
  75948. generateHarmonics?: boolean,
  75949. /**
  75950. * 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)
  75951. */
  75952. gammaSpace?: boolean,
  75953. /**
  75954. * Internal Use Only
  75955. */
  75956. reserved?: boolean);
  75957. /**
  75958. * Execute the current task
  75959. * @param scene defines the scene where you want your assets to be loaded
  75960. * @param onSuccess is a callback called when the task is successfully executed
  75961. * @param onError is a callback called if an error occurs
  75962. */
  75963. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75964. }
  75965. /**
  75966. * Define a task used by AssetsManager to load Equirectangular cube textures
  75967. */
  75968. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  75969. /**
  75970. * Defines the name of the task
  75971. */
  75972. name: string;
  75973. /**
  75974. * Defines the location of the file to load
  75975. */
  75976. url: string;
  75977. /**
  75978. * Defines the desired size (the more it increases the longer the generation will be)
  75979. */
  75980. size: number;
  75981. /**
  75982. * Defines if mipmaps should not be generated (default is false)
  75983. */
  75984. noMipmap: boolean;
  75985. /**
  75986. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75987. * but the standard material would require them in Gamma space) (default is true)
  75988. */
  75989. gammaSpace: boolean;
  75990. /**
  75991. * Gets the loaded texture
  75992. */
  75993. texture: EquiRectangularCubeTexture;
  75994. /**
  75995. * Callback called when the task is successful
  75996. */
  75997. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  75998. /**
  75999. * Callback called when the task is successful
  76000. */
  76001. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  76002. /**
  76003. * Creates a new EquiRectangularCubeTextureAssetTask object
  76004. * @param name defines the name of the task
  76005. * @param url defines the location of the file to load
  76006. * @param size defines the desired size (the more it increases the longer the generation will be)
  76007. * If the size is omitted this implies you are using a preprocessed cubemap.
  76008. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76009. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76010. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76011. * (default is true)
  76012. */
  76013. constructor(
  76014. /**
  76015. * Defines the name of the task
  76016. */
  76017. name: string,
  76018. /**
  76019. * Defines the location of the file to load
  76020. */
  76021. url: string,
  76022. /**
  76023. * Defines the desired size (the more it increases the longer the generation will be)
  76024. */
  76025. size: number,
  76026. /**
  76027. * Defines if mipmaps should not be generated (default is false)
  76028. */
  76029. noMipmap?: boolean,
  76030. /**
  76031. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76032. * but the standard material would require them in Gamma space) (default is true)
  76033. */
  76034. gammaSpace?: boolean);
  76035. /**
  76036. * Execute the current task
  76037. * @param scene defines the scene where you want your assets to be loaded
  76038. * @param onSuccess is a callback called when the task is successfully executed
  76039. * @param onError is a callback called if an error occurs
  76040. */
  76041. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76042. }
  76043. /**
  76044. * This class can be used to easily import assets into a scene
  76045. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76046. */
  76047. export class AssetsManager {
  76048. private _scene;
  76049. private _isLoading;
  76050. protected _tasks: AbstractAssetTask[];
  76051. protected _waitingTasksCount: number;
  76052. protected _totalTasksCount: number;
  76053. /**
  76054. * Callback called when all tasks are processed
  76055. */
  76056. onFinish: (tasks: AbstractAssetTask[]) => void;
  76057. /**
  76058. * Callback called when a task is successful
  76059. */
  76060. onTaskSuccess: (task: AbstractAssetTask) => void;
  76061. /**
  76062. * Callback called when a task had an error
  76063. */
  76064. onTaskError: (task: AbstractAssetTask) => void;
  76065. /**
  76066. * Callback called when a task is done (whatever the result is)
  76067. */
  76068. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76069. /**
  76070. * Observable called when all tasks are processed
  76071. */
  76072. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76073. /**
  76074. * Observable called when a task had an error
  76075. */
  76076. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76077. /**
  76078. * Observable called when all tasks were executed
  76079. */
  76080. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76081. /**
  76082. * Observable called when a task is done (whatever the result is)
  76083. */
  76084. onProgressObservable: Observable<IAssetsProgressEvent>;
  76085. /**
  76086. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76087. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76088. */
  76089. useDefaultLoadingScreen: boolean;
  76090. /**
  76091. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76092. * when all assets have been downloaded.
  76093. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76094. */
  76095. autoHideLoadingUI: boolean;
  76096. /**
  76097. * Creates a new AssetsManager
  76098. * @param scene defines the scene to work on
  76099. */
  76100. constructor(scene: Scene);
  76101. /**
  76102. * Add a MeshAssetTask to the list of active tasks
  76103. * @param taskName defines the name of the new task
  76104. * @param meshesNames defines the name of meshes to load
  76105. * @param rootUrl defines the root url to use to locate files
  76106. * @param sceneFilename defines the filename of the scene file
  76107. * @returns a new MeshAssetTask object
  76108. */
  76109. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76110. /**
  76111. * Add a TextFileAssetTask to the list of active tasks
  76112. * @param taskName defines the name of the new task
  76113. * @param url defines the url of the file to load
  76114. * @returns a new TextFileAssetTask object
  76115. */
  76116. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76117. /**
  76118. * Add a BinaryFileAssetTask to the list of active tasks
  76119. * @param taskName defines the name of the new task
  76120. * @param url defines the url of the file to load
  76121. * @returns a new BinaryFileAssetTask object
  76122. */
  76123. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76124. /**
  76125. * Add a ImageAssetTask to the list of active tasks
  76126. * @param taskName defines the name of the new task
  76127. * @param url defines the url of the file to load
  76128. * @returns a new ImageAssetTask object
  76129. */
  76130. addImageTask(taskName: string, url: string): ImageAssetTask;
  76131. /**
  76132. * Add a TextureAssetTask to the list of active tasks
  76133. * @param taskName defines the name of the new task
  76134. * @param url defines the url of the file to load
  76135. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76136. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76137. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76138. * @returns a new TextureAssetTask object
  76139. */
  76140. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76141. /**
  76142. * Add a CubeTextureAssetTask to the list of active tasks
  76143. * @param taskName defines the name of the new task
  76144. * @param url defines the url of the file to load
  76145. * @param extensions defines the extension to use to load the cube map (can be null)
  76146. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76147. * @param files defines the list of files to load (can be null)
  76148. * @returns a new CubeTextureAssetTask object
  76149. */
  76150. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76151. /**
  76152. *
  76153. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76154. * @param taskName defines the name of the new task
  76155. * @param url defines the url of the file to load
  76156. * @param size defines the size you want for the cubemap (can be null)
  76157. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76158. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76159. * @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)
  76160. * @param reserved Internal use only
  76161. * @returns a new HDRCubeTextureAssetTask object
  76162. */
  76163. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76164. /**
  76165. *
  76166. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76167. * @param taskName defines the name of the new task
  76168. * @param url defines the url of the file to load
  76169. * @param size defines the size you want for the cubemap (can be null)
  76170. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76171. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76172. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76173. * @returns a new EquiRectangularCubeTextureAssetTask object
  76174. */
  76175. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76176. /**
  76177. * Remove a task from the assets manager.
  76178. * @param task the task to remove
  76179. */
  76180. removeTask(task: AbstractAssetTask): void;
  76181. private _decreaseWaitingTasksCount;
  76182. private _runTask;
  76183. /**
  76184. * Reset the AssetsManager and remove all tasks
  76185. * @return the current instance of the AssetsManager
  76186. */
  76187. reset(): AssetsManager;
  76188. /**
  76189. * Start the loading process
  76190. * @return the current instance of the AssetsManager
  76191. */
  76192. load(): AssetsManager;
  76193. /**
  76194. * Start the loading process as an async operation
  76195. * @return a promise returning the list of failed tasks
  76196. */
  76197. loadAsync(): Promise<void>;
  76198. }
  76199. }
  76200. declare module "babylonjs/Misc/deferred" {
  76201. /**
  76202. * Wrapper class for promise with external resolve and reject.
  76203. */
  76204. export class Deferred<T> {
  76205. /**
  76206. * The promise associated with this deferred object.
  76207. */
  76208. readonly promise: Promise<T>;
  76209. private _resolve;
  76210. private _reject;
  76211. /**
  76212. * The resolve method of the promise associated with this deferred object.
  76213. */
  76214. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76215. /**
  76216. * The reject method of the promise associated with this deferred object.
  76217. */
  76218. get reject(): (reason?: any) => void;
  76219. /**
  76220. * Constructor for this deferred object.
  76221. */
  76222. constructor();
  76223. }
  76224. }
  76225. declare module "babylonjs/Misc/meshExploder" {
  76226. import { Mesh } from "babylonjs/Meshes/mesh";
  76227. /**
  76228. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  76229. */
  76230. export class MeshExploder {
  76231. private _centerMesh;
  76232. private _meshes;
  76233. private _meshesOrigins;
  76234. private _toCenterVectors;
  76235. private _scaledDirection;
  76236. private _newPosition;
  76237. private _centerPosition;
  76238. /**
  76239. * Explodes meshes from a center mesh.
  76240. * @param meshes The meshes to explode.
  76241. * @param centerMesh The mesh to be center of explosion.
  76242. */
  76243. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  76244. private _setCenterMesh;
  76245. /**
  76246. * Get class name
  76247. * @returns "MeshExploder"
  76248. */
  76249. getClassName(): string;
  76250. /**
  76251. * "Exploded meshes"
  76252. * @returns Array of meshes with the centerMesh at index 0.
  76253. */
  76254. getMeshes(): Array<Mesh>;
  76255. /**
  76256. * Explodes meshes giving a specific direction
  76257. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  76258. */
  76259. explode(direction?: number): void;
  76260. }
  76261. }
  76262. declare module "babylonjs/Misc/filesInput" {
  76263. import { Engine } from "babylonjs/Engines/engine";
  76264. import { Scene } from "babylonjs/scene";
  76265. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  76266. import { Nullable } from "babylonjs/types";
  76267. /**
  76268. * Class used to help managing file picking and drag'n'drop
  76269. */
  76270. export class FilesInput {
  76271. /**
  76272. * List of files ready to be loaded
  76273. */
  76274. static get FilesToLoad(): {
  76275. [key: string]: File;
  76276. };
  76277. /**
  76278. * Callback called when a file is processed
  76279. */
  76280. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  76281. private _engine;
  76282. private _currentScene;
  76283. private _sceneLoadedCallback;
  76284. private _progressCallback;
  76285. private _additionalRenderLoopLogicCallback;
  76286. private _textureLoadingCallback;
  76287. private _startingProcessingFilesCallback;
  76288. private _onReloadCallback;
  76289. private _errorCallback;
  76290. private _elementToMonitor;
  76291. private _sceneFileToLoad;
  76292. private _filesToLoad;
  76293. /**
  76294. * Creates a new FilesInput
  76295. * @param engine defines the rendering engine
  76296. * @param scene defines the hosting scene
  76297. * @param sceneLoadedCallback callback called when scene is loaded
  76298. * @param progressCallback callback called to track progress
  76299. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  76300. * @param textureLoadingCallback callback called when a texture is loading
  76301. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  76302. * @param onReloadCallback callback called when a reload is requested
  76303. * @param errorCallback callback call if an error occurs
  76304. */
  76305. 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>);
  76306. private _dragEnterHandler;
  76307. private _dragOverHandler;
  76308. private _dropHandler;
  76309. /**
  76310. * Calls this function to listen to drag'n'drop events on a specific DOM element
  76311. * @param elementToMonitor defines the DOM element to track
  76312. */
  76313. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  76314. /** Gets the current list of files to load */
  76315. get filesToLoad(): File[];
  76316. /**
  76317. * Release all associated resources
  76318. */
  76319. dispose(): void;
  76320. private renderFunction;
  76321. private drag;
  76322. private drop;
  76323. private _traverseFolder;
  76324. private _processFiles;
  76325. /**
  76326. * Load files from a drop event
  76327. * @param event defines the drop event to use as source
  76328. */
  76329. loadFiles(event: any): void;
  76330. private _processReload;
  76331. /**
  76332. * Reload the current scene from the loaded files
  76333. */
  76334. reload(): void;
  76335. }
  76336. }
  76337. declare module "babylonjs/Misc/HighDynamicRange/index" {
  76338. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  76339. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  76340. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  76341. }
  76342. declare module "babylonjs/Misc/sceneOptimizer" {
  76343. import { Scene, IDisposable } from "babylonjs/scene";
  76344. import { Observable } from "babylonjs/Misc/observable";
  76345. /**
  76346. * Defines the root class used to create scene optimization to use with SceneOptimizer
  76347. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76348. */
  76349. export class SceneOptimization {
  76350. /**
  76351. * Defines the priority of this optimization (0 by default which means first in the list)
  76352. */
  76353. priority: number;
  76354. /**
  76355. * Gets a string describing the action executed by the current optimization
  76356. * @returns description string
  76357. */
  76358. getDescription(): string;
  76359. /**
  76360. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76361. * @param scene defines the current scene where to apply this optimization
  76362. * @param optimizer defines the current optimizer
  76363. * @returns true if everything that can be done was applied
  76364. */
  76365. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76366. /**
  76367. * Creates the SceneOptimization object
  76368. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76369. * @param desc defines the description associated with the optimization
  76370. */
  76371. constructor(
  76372. /**
  76373. * Defines the priority of this optimization (0 by default which means first in the list)
  76374. */
  76375. priority?: number);
  76376. }
  76377. /**
  76378. * Defines an optimization used to reduce the size of render target textures
  76379. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76380. */
  76381. export class TextureOptimization extends SceneOptimization {
  76382. /**
  76383. * Defines the priority of this optimization (0 by default which means first in the list)
  76384. */
  76385. priority: number;
  76386. /**
  76387. * 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
  76388. */
  76389. maximumSize: number;
  76390. /**
  76391. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76392. */
  76393. step: number;
  76394. /**
  76395. * Gets a string describing the action executed by the current optimization
  76396. * @returns description string
  76397. */
  76398. getDescription(): string;
  76399. /**
  76400. * Creates the TextureOptimization object
  76401. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76402. * @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
  76403. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76404. */
  76405. constructor(
  76406. /**
  76407. * Defines the priority of this optimization (0 by default which means first in the list)
  76408. */
  76409. priority?: number,
  76410. /**
  76411. * 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
  76412. */
  76413. maximumSize?: number,
  76414. /**
  76415. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76416. */
  76417. step?: number);
  76418. /**
  76419. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76420. * @param scene defines the current scene where to apply this optimization
  76421. * @param optimizer defines the current optimizer
  76422. * @returns true if everything that can be done was applied
  76423. */
  76424. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76425. }
  76426. /**
  76427. * Defines an optimization used to increase or decrease the rendering resolution
  76428. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76429. */
  76430. export class HardwareScalingOptimization extends SceneOptimization {
  76431. /**
  76432. * Defines the priority of this optimization (0 by default which means first in the list)
  76433. */
  76434. priority: number;
  76435. /**
  76436. * Defines the maximum scale to use (2 by default)
  76437. */
  76438. maximumScale: number;
  76439. /**
  76440. * Defines the step to use between two passes (0.5 by default)
  76441. */
  76442. step: number;
  76443. private _currentScale;
  76444. private _directionOffset;
  76445. /**
  76446. * Gets a string describing the action executed by the current optimization
  76447. * @return description string
  76448. */
  76449. getDescription(): string;
  76450. /**
  76451. * Creates the HardwareScalingOptimization object
  76452. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76453. * @param maximumScale defines the maximum scale to use (2 by default)
  76454. * @param step defines the step to use between two passes (0.5 by default)
  76455. */
  76456. constructor(
  76457. /**
  76458. * Defines the priority of this optimization (0 by default which means first in the list)
  76459. */
  76460. priority?: number,
  76461. /**
  76462. * Defines the maximum scale to use (2 by default)
  76463. */
  76464. maximumScale?: number,
  76465. /**
  76466. * Defines the step to use between two passes (0.5 by default)
  76467. */
  76468. step?: number);
  76469. /**
  76470. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76471. * @param scene defines the current scene where to apply this optimization
  76472. * @param optimizer defines the current optimizer
  76473. * @returns true if everything that can be done was applied
  76474. */
  76475. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76476. }
  76477. /**
  76478. * Defines an optimization used to remove shadows
  76479. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76480. */
  76481. export class ShadowsOptimization extends SceneOptimization {
  76482. /**
  76483. * Gets a string describing the action executed by the current optimization
  76484. * @return description string
  76485. */
  76486. getDescription(): string;
  76487. /**
  76488. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76489. * @param scene defines the current scene where to apply this optimization
  76490. * @param optimizer defines the current optimizer
  76491. * @returns true if everything that can be done was applied
  76492. */
  76493. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76494. }
  76495. /**
  76496. * Defines an optimization used to turn post-processes off
  76497. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76498. */
  76499. export class PostProcessesOptimization extends SceneOptimization {
  76500. /**
  76501. * Gets a string describing the action executed by the current optimization
  76502. * @return description string
  76503. */
  76504. getDescription(): string;
  76505. /**
  76506. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76507. * @param scene defines the current scene where to apply this optimization
  76508. * @param optimizer defines the current optimizer
  76509. * @returns true if everything that can be done was applied
  76510. */
  76511. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76512. }
  76513. /**
  76514. * Defines an optimization used to turn lens flares off
  76515. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76516. */
  76517. export class LensFlaresOptimization extends SceneOptimization {
  76518. /**
  76519. * Gets a string describing the action executed by the current optimization
  76520. * @return description string
  76521. */
  76522. getDescription(): string;
  76523. /**
  76524. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76525. * @param scene defines the current scene where to apply this optimization
  76526. * @param optimizer defines the current optimizer
  76527. * @returns true if everything that can be done was applied
  76528. */
  76529. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76530. }
  76531. /**
  76532. * Defines an optimization based on user defined callback.
  76533. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76534. */
  76535. export class CustomOptimization extends SceneOptimization {
  76536. /**
  76537. * Callback called to apply the custom optimization.
  76538. */
  76539. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  76540. /**
  76541. * Callback called to get custom description
  76542. */
  76543. onGetDescription: () => string;
  76544. /**
  76545. * Gets a string describing the action executed by the current optimization
  76546. * @returns description string
  76547. */
  76548. getDescription(): string;
  76549. /**
  76550. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76551. * @param scene defines the current scene where to apply this optimization
  76552. * @param optimizer defines the current optimizer
  76553. * @returns true if everything that can be done was applied
  76554. */
  76555. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76556. }
  76557. /**
  76558. * Defines an optimization used to turn particles off
  76559. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76560. */
  76561. export class ParticlesOptimization extends SceneOptimization {
  76562. /**
  76563. * Gets a string describing the action executed by the current optimization
  76564. * @return description string
  76565. */
  76566. getDescription(): string;
  76567. /**
  76568. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76569. * @param scene defines the current scene where to apply this optimization
  76570. * @param optimizer defines the current optimizer
  76571. * @returns true if everything that can be done was applied
  76572. */
  76573. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76574. }
  76575. /**
  76576. * Defines an optimization used to turn render targets off
  76577. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76578. */
  76579. export class RenderTargetsOptimization extends SceneOptimization {
  76580. /**
  76581. * Gets a string describing the action executed by the current optimization
  76582. * @return description string
  76583. */
  76584. getDescription(): string;
  76585. /**
  76586. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76587. * @param scene defines the current scene where to apply this optimization
  76588. * @param optimizer defines the current optimizer
  76589. * @returns true if everything that can be done was applied
  76590. */
  76591. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76592. }
  76593. /**
  76594. * Defines an optimization used to merge meshes with compatible materials
  76595. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76596. */
  76597. export class MergeMeshesOptimization extends SceneOptimization {
  76598. private static _UpdateSelectionTree;
  76599. /**
  76600. * Gets or sets a boolean which defines if optimization octree has to be updated
  76601. */
  76602. static get UpdateSelectionTree(): boolean;
  76603. /**
  76604. * Gets or sets a boolean which defines if optimization octree has to be updated
  76605. */
  76606. static set UpdateSelectionTree(value: boolean);
  76607. /**
  76608. * Gets a string describing the action executed by the current optimization
  76609. * @return description string
  76610. */
  76611. getDescription(): string;
  76612. private _canBeMerged;
  76613. /**
  76614. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76615. * @param scene defines the current scene where to apply this optimization
  76616. * @param optimizer defines the current optimizer
  76617. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  76618. * @returns true if everything that can be done was applied
  76619. */
  76620. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  76621. }
  76622. /**
  76623. * Defines a list of options used by SceneOptimizer
  76624. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76625. */
  76626. export class SceneOptimizerOptions {
  76627. /**
  76628. * Defines the target frame rate to reach (60 by default)
  76629. */
  76630. targetFrameRate: number;
  76631. /**
  76632. * Defines the interval between two checkes (2000ms by default)
  76633. */
  76634. trackerDuration: number;
  76635. /**
  76636. * Gets the list of optimizations to apply
  76637. */
  76638. optimizations: SceneOptimization[];
  76639. /**
  76640. * Creates a new list of options used by SceneOptimizer
  76641. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  76642. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  76643. */
  76644. constructor(
  76645. /**
  76646. * Defines the target frame rate to reach (60 by default)
  76647. */
  76648. targetFrameRate?: number,
  76649. /**
  76650. * Defines the interval between two checkes (2000ms by default)
  76651. */
  76652. trackerDuration?: number);
  76653. /**
  76654. * Add a new optimization
  76655. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  76656. * @returns the current SceneOptimizerOptions
  76657. */
  76658. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  76659. /**
  76660. * Add a new custom optimization
  76661. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  76662. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  76663. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76664. * @returns the current SceneOptimizerOptions
  76665. */
  76666. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  76667. /**
  76668. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  76669. * @param targetFrameRate defines the target frame rate (60 by default)
  76670. * @returns a SceneOptimizerOptions object
  76671. */
  76672. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76673. /**
  76674. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  76675. * @param targetFrameRate defines the target frame rate (60 by default)
  76676. * @returns a SceneOptimizerOptions object
  76677. */
  76678. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76679. /**
  76680. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  76681. * @param targetFrameRate defines the target frame rate (60 by default)
  76682. * @returns a SceneOptimizerOptions object
  76683. */
  76684. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76685. }
  76686. /**
  76687. * Class used to run optimizations in order to reach a target frame rate
  76688. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76689. */
  76690. export class SceneOptimizer implements IDisposable {
  76691. private _isRunning;
  76692. private _options;
  76693. private _scene;
  76694. private _currentPriorityLevel;
  76695. private _targetFrameRate;
  76696. private _trackerDuration;
  76697. private _currentFrameRate;
  76698. private _sceneDisposeObserver;
  76699. private _improvementMode;
  76700. /**
  76701. * Defines an observable called when the optimizer reaches the target frame rate
  76702. */
  76703. onSuccessObservable: Observable<SceneOptimizer>;
  76704. /**
  76705. * Defines an observable called when the optimizer enables an optimization
  76706. */
  76707. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  76708. /**
  76709. * Defines an observable called when the optimizer is not able to reach the target frame rate
  76710. */
  76711. onFailureObservable: Observable<SceneOptimizer>;
  76712. /**
  76713. * Gets a boolean indicating if the optimizer is in improvement mode
  76714. */
  76715. get isInImprovementMode(): boolean;
  76716. /**
  76717. * Gets the current priority level (0 at start)
  76718. */
  76719. get currentPriorityLevel(): number;
  76720. /**
  76721. * Gets the current frame rate checked by the SceneOptimizer
  76722. */
  76723. get currentFrameRate(): number;
  76724. /**
  76725. * Gets or sets the current target frame rate (60 by default)
  76726. */
  76727. get targetFrameRate(): number;
  76728. /**
  76729. * Gets or sets the current target frame rate (60 by default)
  76730. */
  76731. set targetFrameRate(value: number);
  76732. /**
  76733. * Gets or sets the current interval between two checks (every 2000ms by default)
  76734. */
  76735. get trackerDuration(): number;
  76736. /**
  76737. * Gets or sets the current interval between two checks (every 2000ms by default)
  76738. */
  76739. set trackerDuration(value: number);
  76740. /**
  76741. * Gets the list of active optimizations
  76742. */
  76743. get optimizations(): SceneOptimization[];
  76744. /**
  76745. * Creates a new SceneOptimizer
  76746. * @param scene defines the scene to work on
  76747. * @param options defines the options to use with the SceneOptimizer
  76748. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  76749. * @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)
  76750. */
  76751. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  76752. /**
  76753. * Stops the current optimizer
  76754. */
  76755. stop(): void;
  76756. /**
  76757. * Reset the optimizer to initial step (current priority level = 0)
  76758. */
  76759. reset(): void;
  76760. /**
  76761. * Start the optimizer. By default it will try to reach a specific framerate
  76762. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  76763. */
  76764. start(): void;
  76765. private _checkCurrentState;
  76766. /**
  76767. * Release all resources
  76768. */
  76769. dispose(): void;
  76770. /**
  76771. * Helper function to create a SceneOptimizer with one single line of code
  76772. * @param scene defines the scene to work on
  76773. * @param options defines the options to use with the SceneOptimizer
  76774. * @param onSuccess defines a callback to call on success
  76775. * @param onFailure defines a callback to call on failure
  76776. * @returns the new SceneOptimizer object
  76777. */
  76778. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  76779. }
  76780. }
  76781. declare module "babylonjs/Misc/sceneSerializer" {
  76782. import { Scene } from "babylonjs/scene";
  76783. /**
  76784. * Class used to serialize a scene into a string
  76785. */
  76786. export class SceneSerializer {
  76787. /**
  76788. * Clear cache used by a previous serialization
  76789. */
  76790. static ClearCache(): void;
  76791. /**
  76792. * Serialize a scene into a JSON compatible object
  76793. * @param scene defines the scene to serialize
  76794. * @returns a JSON compatible object
  76795. */
  76796. static Serialize(scene: Scene): any;
  76797. /**
  76798. * Serialize a mesh into a JSON compatible object
  76799. * @param toSerialize defines the mesh to serialize
  76800. * @param withParents defines if parents must be serialized as well
  76801. * @param withChildren defines if children must be serialized as well
  76802. * @returns a JSON compatible object
  76803. */
  76804. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  76805. }
  76806. }
  76807. declare module "babylonjs/Misc/textureTools" {
  76808. import { Texture } from "babylonjs/Materials/Textures/texture";
  76809. /**
  76810. * Class used to host texture specific utilities
  76811. */
  76812. export class TextureTools {
  76813. /**
  76814. * Uses the GPU to create a copy texture rescaled at a given size
  76815. * @param texture Texture to copy from
  76816. * @param width defines the desired width
  76817. * @param height defines the desired height
  76818. * @param useBilinearMode defines if bilinear mode has to be used
  76819. * @return the generated texture
  76820. */
  76821. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  76822. }
  76823. }
  76824. declare module "babylonjs/Misc/videoRecorder" {
  76825. import { Nullable } from "babylonjs/types";
  76826. import { Engine } from "babylonjs/Engines/engine";
  76827. /**
  76828. * This represents the different options available for the video capture.
  76829. */
  76830. export interface VideoRecorderOptions {
  76831. /** Defines the mime type of the video. */
  76832. mimeType: string;
  76833. /** Defines the FPS the video should be recorded at. */
  76834. fps: number;
  76835. /** Defines the chunk size for the recording data. */
  76836. recordChunckSize: number;
  76837. /** The audio tracks to attach to the recording. */
  76838. audioTracks?: MediaStreamTrack[];
  76839. }
  76840. /**
  76841. * This can help with recording videos from BabylonJS.
  76842. * This is based on the available WebRTC functionalities of the browser.
  76843. *
  76844. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  76845. */
  76846. export class VideoRecorder {
  76847. private static readonly _defaultOptions;
  76848. /**
  76849. * Returns whether or not the VideoRecorder is available in your browser.
  76850. * @param engine Defines the Babylon Engine.
  76851. * @returns true if supported otherwise false.
  76852. */
  76853. static IsSupported(engine: Engine): boolean;
  76854. private readonly _options;
  76855. private _canvas;
  76856. private _mediaRecorder;
  76857. private _recordedChunks;
  76858. private _fileName;
  76859. private _resolve;
  76860. private _reject;
  76861. /**
  76862. * True when a recording is already in progress.
  76863. */
  76864. get isRecording(): boolean;
  76865. /**
  76866. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  76867. * @param engine Defines the BabylonJS Engine you wish to record.
  76868. * @param options Defines options that can be used to customize the capture.
  76869. */
  76870. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  76871. /**
  76872. * Stops the current recording before the default capture timeout passed in the startRecording function.
  76873. */
  76874. stopRecording(): void;
  76875. /**
  76876. * Starts recording the canvas for a max duration specified in parameters.
  76877. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  76878. * If null no automatic download will start and you can rely on the promise to get the data back.
  76879. * @param maxDuration Defines the maximum recording time in seconds.
  76880. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  76881. * @return A promise callback at the end of the recording with the video data in Blob.
  76882. */
  76883. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  76884. /**
  76885. * Releases internal resources used during the recording.
  76886. */
  76887. dispose(): void;
  76888. private _handleDataAvailable;
  76889. private _handleError;
  76890. private _handleStop;
  76891. }
  76892. }
  76893. declare module "babylonjs/Misc/screenshotTools" {
  76894. import { Camera } from "babylonjs/Cameras/camera";
  76895. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  76896. import { Engine } from "babylonjs/Engines/engine";
  76897. /**
  76898. * Class containing a set of static utilities functions for screenshots
  76899. */
  76900. export class ScreenshotTools {
  76901. /**
  76902. * Captures a screenshot of the current rendering
  76903. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76904. * @param engine defines the rendering engine
  76905. * @param camera defines the source camera
  76906. * @param size This parameter can be set to a single number or to an object with the
  76907. * following (optional) properties: precision, width, height. If a single number is passed,
  76908. * it will be used for both width and height. If an object is passed, the screenshot size
  76909. * will be derived from the parameters. The precision property is a multiplier allowing
  76910. * rendering at a higher or lower resolution
  76911. * @param successCallback defines the callback receives a single parameter which contains the
  76912. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76913. * src parameter of an <img> to display it
  76914. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76915. * Check your browser for supported MIME types
  76916. */
  76917. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  76918. /**
  76919. * Captures a screenshot of the current rendering
  76920. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76921. * @param engine defines the rendering engine
  76922. * @param camera defines the source camera
  76923. * @param size This parameter can be set to a single number or to an object with the
  76924. * following (optional) properties: precision, width, height. If a single number is passed,
  76925. * it will be used for both width and height. If an object is passed, the screenshot size
  76926. * will be derived from the parameters. The precision property is a multiplier allowing
  76927. * rendering at a higher or lower resolution
  76928. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76929. * Check your browser for supported MIME types
  76930. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76931. * to the src parameter of an <img> to display it
  76932. */
  76933. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  76934. /**
  76935. * Generates an image screenshot from the specified camera.
  76936. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76937. * @param engine The engine to use for rendering
  76938. * @param camera The camera to use for rendering
  76939. * @param size This parameter can be set to a single number or to an object with the
  76940. * following (optional) properties: precision, width, height. If a single number is passed,
  76941. * it will be used for both width and height. If an object is passed, the screenshot size
  76942. * will be derived from the parameters. The precision property is a multiplier allowing
  76943. * rendering at a higher or lower resolution
  76944. * @param successCallback The callback receives a single parameter which contains the
  76945. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76946. * src parameter of an <img> to display it
  76947. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76948. * Check your browser for supported MIME types
  76949. * @param samples Texture samples (default: 1)
  76950. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76951. * @param fileName A name for for the downloaded file.
  76952. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76953. */
  76954. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  76955. /**
  76956. * Generates an image screenshot from the specified camera.
  76957. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76958. * @param engine The engine to use for rendering
  76959. * @param camera The camera to use for rendering
  76960. * @param size This parameter can be set to a single number or to an object with the
  76961. * following (optional) properties: precision, width, height. If a single number is passed,
  76962. * it will be used for both width and height. If an object is passed, the screenshot size
  76963. * will be derived from the parameters. The precision property is a multiplier allowing
  76964. * rendering at a higher or lower resolution
  76965. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76966. * Check your browser for supported MIME types
  76967. * @param samples Texture samples (default: 1)
  76968. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76969. * @param fileName A name for for the downloaded file.
  76970. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76971. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76972. * to the src parameter of an <img> to display it
  76973. */
  76974. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  76975. /**
  76976. * Gets height and width for screenshot size
  76977. * @private
  76978. */
  76979. private static _getScreenshotSize;
  76980. }
  76981. }
  76982. declare module "babylonjs/Misc/dataReader" {
  76983. /**
  76984. * Interface for a data buffer
  76985. */
  76986. export interface IDataBuffer {
  76987. /**
  76988. * Reads bytes from the data buffer.
  76989. * @param byteOffset The byte offset to read
  76990. * @param byteLength The byte length to read
  76991. * @returns A promise that resolves when the bytes are read
  76992. */
  76993. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  76994. /**
  76995. * The byte length of the buffer.
  76996. */
  76997. readonly byteLength: number;
  76998. }
  76999. /**
  77000. * Utility class for reading from a data buffer
  77001. */
  77002. export class DataReader {
  77003. /**
  77004. * The data buffer associated with this data reader.
  77005. */
  77006. readonly buffer: IDataBuffer;
  77007. /**
  77008. * The current byte offset from the beginning of the data buffer.
  77009. */
  77010. byteOffset: number;
  77011. private _dataView;
  77012. private _dataByteOffset;
  77013. /**
  77014. * Constructor
  77015. * @param buffer The buffer to read
  77016. */
  77017. constructor(buffer: IDataBuffer);
  77018. /**
  77019. * Loads the given byte length.
  77020. * @param byteLength The byte length to load
  77021. * @returns A promise that resolves when the load is complete
  77022. */
  77023. loadAsync(byteLength: number): Promise<void>;
  77024. /**
  77025. * Read a unsigned 32-bit integer from the currently loaded data range.
  77026. * @returns The 32-bit integer read
  77027. */
  77028. readUint32(): number;
  77029. /**
  77030. * Read a byte array from the currently loaded data range.
  77031. * @param byteLength The byte length to read
  77032. * @returns The byte array read
  77033. */
  77034. readUint8Array(byteLength: number): Uint8Array;
  77035. /**
  77036. * Read a string from the currently loaded data range.
  77037. * @param byteLength The byte length to read
  77038. * @returns The string read
  77039. */
  77040. readString(byteLength: number): string;
  77041. /**
  77042. * Skips the given byte length the currently loaded data range.
  77043. * @param byteLength The byte length to skip
  77044. */
  77045. skipBytes(byteLength: number): void;
  77046. }
  77047. }
  77048. declare module "babylonjs/Misc/dataStorage" {
  77049. /**
  77050. * Class for storing data to local storage if available or in-memory storage otherwise
  77051. */
  77052. export class DataStorage {
  77053. private static _Storage;
  77054. private static _GetStorage;
  77055. /**
  77056. * Reads a string from the data storage
  77057. * @param key The key to read
  77058. * @param defaultValue The value if the key doesn't exist
  77059. * @returns The string value
  77060. */
  77061. static ReadString(key: string, defaultValue: string): string;
  77062. /**
  77063. * Writes a string to the data storage
  77064. * @param key The key to write
  77065. * @param value The value to write
  77066. */
  77067. static WriteString(key: string, value: string): void;
  77068. /**
  77069. * Reads a boolean from the data storage
  77070. * @param key The key to read
  77071. * @param defaultValue The value if the key doesn't exist
  77072. * @returns The boolean value
  77073. */
  77074. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77075. /**
  77076. * Writes a boolean to the data storage
  77077. * @param key The key to write
  77078. * @param value The value to write
  77079. */
  77080. static WriteBoolean(key: string, value: boolean): void;
  77081. /**
  77082. * Reads a number from the data storage
  77083. * @param key The key to read
  77084. * @param defaultValue The value if the key doesn't exist
  77085. * @returns The number value
  77086. */
  77087. static ReadNumber(key: string, defaultValue: number): number;
  77088. /**
  77089. * Writes a number to the data storage
  77090. * @param key The key to write
  77091. * @param value The value to write
  77092. */
  77093. static WriteNumber(key: string, value: number): void;
  77094. }
  77095. }
  77096. declare module "babylonjs/Misc/index" {
  77097. export * from "babylonjs/Misc/andOrNotEvaluator";
  77098. export * from "babylonjs/Misc/assetsManager";
  77099. export * from "babylonjs/Misc/basis";
  77100. export * from "babylonjs/Misc/dds";
  77101. export * from "babylonjs/Misc/decorators";
  77102. export * from "babylonjs/Misc/deferred";
  77103. export * from "babylonjs/Misc/environmentTextureTools";
  77104. export * from "babylonjs/Misc/meshExploder";
  77105. export * from "babylonjs/Misc/filesInput";
  77106. export * from "babylonjs/Misc/HighDynamicRange/index";
  77107. export * from "babylonjs/Misc/khronosTextureContainer";
  77108. export * from "babylonjs/Misc/observable";
  77109. export * from "babylonjs/Misc/performanceMonitor";
  77110. export * from "babylonjs/Misc/promise";
  77111. export * from "babylonjs/Misc/sceneOptimizer";
  77112. export * from "babylonjs/Misc/sceneSerializer";
  77113. export * from "babylonjs/Misc/smartArray";
  77114. export * from "babylonjs/Misc/stringDictionary";
  77115. export * from "babylonjs/Misc/tags";
  77116. export * from "babylonjs/Misc/textureTools";
  77117. export * from "babylonjs/Misc/tga";
  77118. export * from "babylonjs/Misc/tools";
  77119. export * from "babylonjs/Misc/videoRecorder";
  77120. export * from "babylonjs/Misc/virtualJoystick";
  77121. export * from "babylonjs/Misc/workerPool";
  77122. export * from "babylonjs/Misc/logger";
  77123. export * from "babylonjs/Misc/typeStore";
  77124. export * from "babylonjs/Misc/filesInputStore";
  77125. export * from "babylonjs/Misc/deepCopier";
  77126. export * from "babylonjs/Misc/pivotTools";
  77127. export * from "babylonjs/Misc/precisionDate";
  77128. export * from "babylonjs/Misc/screenshotTools";
  77129. export * from "babylonjs/Misc/typeStore";
  77130. export * from "babylonjs/Misc/webRequest";
  77131. export * from "babylonjs/Misc/iInspectable";
  77132. export * from "babylonjs/Misc/brdfTextureTools";
  77133. export * from "babylonjs/Misc/rgbdTextureTools";
  77134. export * from "babylonjs/Misc/gradients";
  77135. export * from "babylonjs/Misc/perfCounter";
  77136. export * from "babylonjs/Misc/fileRequest";
  77137. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77138. export * from "babylonjs/Misc/retryStrategy";
  77139. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77140. export * from "babylonjs/Misc/canvasGenerator";
  77141. export * from "babylonjs/Misc/fileTools";
  77142. export * from "babylonjs/Misc/stringTools";
  77143. export * from "babylonjs/Misc/dataReader";
  77144. export * from "babylonjs/Misc/minMaxReducer";
  77145. export * from "babylonjs/Misc/depthReducer";
  77146. export * from "babylonjs/Misc/dataStorage";
  77147. }
  77148. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77149. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77150. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77151. import { Observable } from "babylonjs/Misc/observable";
  77152. import { Matrix } from "babylonjs/Maths/math.vector";
  77153. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77154. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77155. /**
  77156. * An interface for all Hit test features
  77157. */
  77158. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77159. /**
  77160. * Triggered when new babylon (transformed) hit test results are available
  77161. */
  77162. onHitTestResultObservable: Observable<T[]>;
  77163. }
  77164. /**
  77165. * Options used for hit testing
  77166. */
  77167. export interface IWebXRLegacyHitTestOptions {
  77168. /**
  77169. * Only test when user interacted with the scene. Default - hit test every frame
  77170. */
  77171. testOnPointerDownOnly?: boolean;
  77172. /**
  77173. * The node to use to transform the local results to world coordinates
  77174. */
  77175. worldParentNode?: TransformNode;
  77176. }
  77177. /**
  77178. * Interface defining the babylon result of raycasting/hit-test
  77179. */
  77180. export interface IWebXRLegacyHitResult {
  77181. /**
  77182. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77183. */
  77184. transformationMatrix: Matrix;
  77185. /**
  77186. * The native hit test result
  77187. */
  77188. xrHitResult: XRHitResult | XRHitTestResult;
  77189. }
  77190. /**
  77191. * The currently-working hit-test module.
  77192. * Hit test (or Ray-casting) is used to interact with the real world.
  77193. * For further information read here - https://github.com/immersive-web/hit-test
  77194. */
  77195. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  77196. /**
  77197. * options to use when constructing this feature
  77198. */
  77199. readonly options: IWebXRLegacyHitTestOptions;
  77200. private _direction;
  77201. private _mat;
  77202. private _onSelectEnabled;
  77203. private _origin;
  77204. /**
  77205. * The module's name
  77206. */
  77207. static readonly Name: string;
  77208. /**
  77209. * The (Babylon) version of this module.
  77210. * This is an integer representing the implementation version.
  77211. * This number does not correspond to the WebXR specs version
  77212. */
  77213. static readonly Version: number;
  77214. /**
  77215. * Populated with the last native XR Hit Results
  77216. */
  77217. lastNativeXRHitResults: XRHitResult[];
  77218. /**
  77219. * Triggered when new babylon (transformed) hit test results are available
  77220. */
  77221. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  77222. /**
  77223. * Creates a new instance of the (legacy version) hit test feature
  77224. * @param _xrSessionManager an instance of WebXRSessionManager
  77225. * @param options options to use when constructing this feature
  77226. */
  77227. constructor(_xrSessionManager: WebXRSessionManager,
  77228. /**
  77229. * options to use when constructing this feature
  77230. */
  77231. options?: IWebXRLegacyHitTestOptions);
  77232. /**
  77233. * execute a hit test with an XR Ray
  77234. *
  77235. * @param xrSession a native xrSession that will execute this hit test
  77236. * @param xrRay the ray (position and direction) to use for ray-casting
  77237. * @param referenceSpace native XR reference space to use for the hit-test
  77238. * @param filter filter function that will filter the results
  77239. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77240. */
  77241. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  77242. /**
  77243. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  77244. * @param event the (select) event to use to select with
  77245. * @param referenceSpace the reference space to use for this hit test
  77246. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77247. */
  77248. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77249. /**
  77250. * attach this feature
  77251. * Will usually be called by the features manager
  77252. *
  77253. * @returns true if successful.
  77254. */
  77255. attach(): boolean;
  77256. /**
  77257. * detach this feature.
  77258. * Will usually be called by the features manager
  77259. *
  77260. * @returns true if successful.
  77261. */
  77262. detach(): boolean;
  77263. /**
  77264. * Dispose this feature and all of the resources attached
  77265. */
  77266. dispose(): void;
  77267. protected _onXRFrame(frame: XRFrame): void;
  77268. private _onHitTestResults;
  77269. private _onSelect;
  77270. }
  77271. }
  77272. declare module "babylonjs/XR/features/WebXRHitTest" {
  77273. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77274. import { Observable } from "babylonjs/Misc/observable";
  77275. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77276. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77277. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  77278. /**
  77279. * Options used for hit testing (version 2)
  77280. */
  77281. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  77282. /**
  77283. * Do not create a permanent hit test. Will usually be used when only
  77284. * transient inputs are needed.
  77285. */
  77286. disablePermanentHitTest?: boolean;
  77287. /**
  77288. * Enable transient (for example touch-based) hit test inspections
  77289. */
  77290. enableTransientHitTest?: boolean;
  77291. /**
  77292. * Offset ray for the permanent hit test
  77293. */
  77294. offsetRay?: Vector3;
  77295. /**
  77296. * Offset ray for the transient hit test
  77297. */
  77298. transientOffsetRay?: Vector3;
  77299. /**
  77300. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  77301. */
  77302. useReferenceSpace?: boolean;
  77303. }
  77304. /**
  77305. * Interface defining the babylon result of hit-test
  77306. */
  77307. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  77308. /**
  77309. * The input source that generated this hit test (if transient)
  77310. */
  77311. inputSource?: XRInputSource;
  77312. /**
  77313. * Is this a transient hit test
  77314. */
  77315. isTransient?: boolean;
  77316. /**
  77317. * Position of the hit test result
  77318. */
  77319. position: Vector3;
  77320. /**
  77321. * Rotation of the hit test result
  77322. */
  77323. rotationQuaternion: Quaternion;
  77324. /**
  77325. * The native hit test result
  77326. */
  77327. xrHitResult: XRHitTestResult;
  77328. }
  77329. /**
  77330. * The currently-working hit-test module.
  77331. * Hit test (or Ray-casting) is used to interact with the real world.
  77332. * For further information read here - https://github.com/immersive-web/hit-test
  77333. *
  77334. * Tested on chrome (mobile) 80.
  77335. */
  77336. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  77337. /**
  77338. * options to use when constructing this feature
  77339. */
  77340. readonly options: IWebXRHitTestOptions;
  77341. private _tmpMat;
  77342. private _tmpPos;
  77343. private _tmpQuat;
  77344. private _transientXrHitTestSource;
  77345. private _xrHitTestSource;
  77346. private initHitTestSource;
  77347. /**
  77348. * The module's name
  77349. */
  77350. static readonly Name: string;
  77351. /**
  77352. * The (Babylon) version of this module.
  77353. * This is an integer representing the implementation version.
  77354. * This number does not correspond to the WebXR specs version
  77355. */
  77356. static readonly Version: number;
  77357. /**
  77358. * When set to true, each hit test will have its own position/rotation objects
  77359. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  77360. * the developers will clone them or copy them as they see fit.
  77361. */
  77362. autoCloneTransformation: boolean;
  77363. /**
  77364. * Triggered when new babylon (transformed) hit test results are available
  77365. */
  77366. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  77367. /**
  77368. * Use this to temporarily pause hit test checks.
  77369. */
  77370. paused: boolean;
  77371. /**
  77372. * Creates a new instance of the hit test feature
  77373. * @param _xrSessionManager an instance of WebXRSessionManager
  77374. * @param options options to use when constructing this feature
  77375. */
  77376. constructor(_xrSessionManager: WebXRSessionManager,
  77377. /**
  77378. * options to use when constructing this feature
  77379. */
  77380. options?: IWebXRHitTestOptions);
  77381. /**
  77382. * attach this feature
  77383. * Will usually be called by the features manager
  77384. *
  77385. * @returns true if successful.
  77386. */
  77387. attach(): boolean;
  77388. /**
  77389. * detach this feature.
  77390. * Will usually be called by the features manager
  77391. *
  77392. * @returns true if successful.
  77393. */
  77394. detach(): boolean;
  77395. /**
  77396. * Dispose this feature and all of the resources attached
  77397. */
  77398. dispose(): void;
  77399. protected _onXRFrame(frame: XRFrame): void;
  77400. private _processWebXRHitTestResult;
  77401. }
  77402. }
  77403. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  77404. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77405. import { Observable } from "babylonjs/Misc/observable";
  77406. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77407. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77408. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77409. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  77410. /**
  77411. * Configuration options of the anchor system
  77412. */
  77413. export interface IWebXRAnchorSystemOptions {
  77414. /**
  77415. * a node that will be used to convert local to world coordinates
  77416. */
  77417. worldParentNode?: TransformNode;
  77418. /**
  77419. * If set to true a reference of the created anchors will be kept until the next session starts
  77420. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  77421. */
  77422. doNotRemoveAnchorsOnSessionEnded?: boolean;
  77423. }
  77424. /**
  77425. * A babylon container for an XR Anchor
  77426. */
  77427. export interface IWebXRAnchor {
  77428. /**
  77429. * A babylon-assigned ID for this anchor
  77430. */
  77431. id: number;
  77432. /**
  77433. * Transformation matrix to apply to an object attached to this anchor
  77434. */
  77435. transformationMatrix: Matrix;
  77436. /**
  77437. * The native anchor object
  77438. */
  77439. xrAnchor: XRAnchor;
  77440. /**
  77441. * if defined, this object will be constantly updated by the anchor's position and rotation
  77442. */
  77443. attachedNode?: TransformNode;
  77444. }
  77445. /**
  77446. * An implementation of the anchor system for WebXR.
  77447. * For further information see https://github.com/immersive-web/anchors/
  77448. */
  77449. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  77450. private _options;
  77451. private _lastFrameDetected;
  77452. private _trackedAnchors;
  77453. private _referenceSpaceForFrameAnchors;
  77454. private _futureAnchors;
  77455. /**
  77456. * The module's name
  77457. */
  77458. static readonly Name: string;
  77459. /**
  77460. * The (Babylon) version of this module.
  77461. * This is an integer representing the implementation version.
  77462. * This number does not correspond to the WebXR specs version
  77463. */
  77464. static readonly Version: number;
  77465. /**
  77466. * Observers registered here will be executed when a new anchor was added to the session
  77467. */
  77468. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  77469. /**
  77470. * Observers registered here will be executed when an anchor was removed from the session
  77471. */
  77472. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  77473. /**
  77474. * Observers registered here will be executed when an existing anchor updates
  77475. * This can execute N times every frame
  77476. */
  77477. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  77478. /**
  77479. * Set the reference space to use for anchor creation, when not using a hit test.
  77480. * Will default to the session's reference space if not defined
  77481. */
  77482. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  77483. /**
  77484. * constructs a new anchor system
  77485. * @param _xrSessionManager an instance of WebXRSessionManager
  77486. * @param _options configuration object for this feature
  77487. */
  77488. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  77489. private _tmpVector;
  77490. private _tmpQuaternion;
  77491. private _populateTmpTransformation;
  77492. /**
  77493. * Create a new anchor point using a hit test result at a specific point in the scene
  77494. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77495. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77496. *
  77497. * @param hitTestResult The hit test result to use for this anchor creation
  77498. * @param position an optional position offset for this anchor
  77499. * @param rotationQuaternion an optional rotation offset for this anchor
  77500. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77501. */
  77502. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  77503. /**
  77504. * Add a new anchor at a specific position and rotation
  77505. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  77506. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  77507. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77508. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77509. *
  77510. * @param position the position in which to add an anchor
  77511. * @param rotationQuaternion an optional rotation for the anchor transformation
  77512. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  77513. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77514. */
  77515. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  77516. /**
  77517. * detach this feature.
  77518. * Will usually be called by the features manager
  77519. *
  77520. * @returns true if successful.
  77521. */
  77522. detach(): boolean;
  77523. /**
  77524. * Dispose this feature and all of the resources attached
  77525. */
  77526. dispose(): void;
  77527. protected _onXRFrame(frame: XRFrame): void;
  77528. /**
  77529. * avoiding using Array.find for global support.
  77530. * @param xrAnchor the plane to find in the array
  77531. */
  77532. private _findIndexInAnchorArray;
  77533. private _updateAnchorWithXRFrame;
  77534. private _createAnchorAtTransformation;
  77535. }
  77536. }
  77537. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  77538. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77539. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77540. import { Observable } from "babylonjs/Misc/observable";
  77541. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  77542. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77543. /**
  77544. * Options used in the plane detector module
  77545. */
  77546. export interface IWebXRPlaneDetectorOptions {
  77547. /**
  77548. * The node to use to transform the local results to world coordinates
  77549. */
  77550. worldParentNode?: TransformNode;
  77551. /**
  77552. * If set to true a reference of the created planes will be kept until the next session starts
  77553. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  77554. */
  77555. doNotRemovePlanesOnSessionEnded?: boolean;
  77556. }
  77557. /**
  77558. * A babylon interface for a WebXR plane.
  77559. * A Plane is actually a polygon, built from N points in space
  77560. *
  77561. * Supported in chrome 79, not supported in canary 81 ATM
  77562. */
  77563. export interface IWebXRPlane {
  77564. /**
  77565. * a babylon-assigned ID for this polygon
  77566. */
  77567. id: number;
  77568. /**
  77569. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  77570. */
  77571. polygonDefinition: Array<Vector3>;
  77572. /**
  77573. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  77574. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  77575. */
  77576. transformationMatrix: Matrix;
  77577. /**
  77578. * the native xr-plane object
  77579. */
  77580. xrPlane: XRPlane;
  77581. }
  77582. /**
  77583. * The plane detector is used to detect planes in the real world when in AR
  77584. * For more information see https://github.com/immersive-web/real-world-geometry/
  77585. */
  77586. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  77587. private _options;
  77588. private _detectedPlanes;
  77589. private _enabled;
  77590. private _lastFrameDetected;
  77591. /**
  77592. * The module's name
  77593. */
  77594. static readonly Name: string;
  77595. /**
  77596. * The (Babylon) version of this module.
  77597. * This is an integer representing the implementation version.
  77598. * This number does not correspond to the WebXR specs version
  77599. */
  77600. static readonly Version: number;
  77601. /**
  77602. * Observers registered here will be executed when a new plane was added to the session
  77603. */
  77604. onPlaneAddedObservable: Observable<IWebXRPlane>;
  77605. /**
  77606. * Observers registered here will be executed when a plane is no longer detected in the session
  77607. */
  77608. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  77609. /**
  77610. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  77611. * This can execute N times every frame
  77612. */
  77613. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  77614. /**
  77615. * construct a new Plane Detector
  77616. * @param _xrSessionManager an instance of xr Session manager
  77617. * @param _options configuration to use when constructing this feature
  77618. */
  77619. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  77620. /**
  77621. * detach this feature.
  77622. * Will usually be called by the features manager
  77623. *
  77624. * @returns true if successful.
  77625. */
  77626. detach(): boolean;
  77627. /**
  77628. * Dispose this feature and all of the resources attached
  77629. */
  77630. dispose(): void;
  77631. protected _onXRFrame(frame: XRFrame): void;
  77632. private _init;
  77633. private _updatePlaneWithXRPlane;
  77634. /**
  77635. * avoiding using Array.find for global support.
  77636. * @param xrPlane the plane to find in the array
  77637. */
  77638. private findIndexInPlaneArray;
  77639. }
  77640. }
  77641. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  77642. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77644. import { Observable } from "babylonjs/Misc/observable";
  77645. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77646. /**
  77647. * Options interface for the background remover plugin
  77648. */
  77649. export interface IWebXRBackgroundRemoverOptions {
  77650. /**
  77651. * Further background meshes to disable when entering AR
  77652. */
  77653. backgroundMeshes?: AbstractMesh[];
  77654. /**
  77655. * flags to configure the removal of the environment helper.
  77656. * If not set, the entire background will be removed. If set, flags should be set as well.
  77657. */
  77658. environmentHelperRemovalFlags?: {
  77659. /**
  77660. * Should the skybox be removed (default false)
  77661. */
  77662. skyBox?: boolean;
  77663. /**
  77664. * Should the ground be removed (default false)
  77665. */
  77666. ground?: boolean;
  77667. };
  77668. /**
  77669. * don't disable the environment helper
  77670. */
  77671. ignoreEnvironmentHelper?: boolean;
  77672. }
  77673. /**
  77674. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  77675. */
  77676. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  77677. /**
  77678. * read-only options to be used in this module
  77679. */
  77680. readonly options: IWebXRBackgroundRemoverOptions;
  77681. /**
  77682. * The module's name
  77683. */
  77684. static readonly Name: string;
  77685. /**
  77686. * The (Babylon) version of this module.
  77687. * This is an integer representing the implementation version.
  77688. * This number does not correspond to the WebXR specs version
  77689. */
  77690. static readonly Version: number;
  77691. /**
  77692. * registered observers will be triggered when the background state changes
  77693. */
  77694. onBackgroundStateChangedObservable: Observable<boolean>;
  77695. /**
  77696. * constructs a new background remover module
  77697. * @param _xrSessionManager the session manager for this module
  77698. * @param options read-only options to be used in this module
  77699. */
  77700. constructor(_xrSessionManager: WebXRSessionManager,
  77701. /**
  77702. * read-only options to be used in this module
  77703. */
  77704. options?: IWebXRBackgroundRemoverOptions);
  77705. /**
  77706. * attach this feature
  77707. * Will usually be called by the features manager
  77708. *
  77709. * @returns true if successful.
  77710. */
  77711. attach(): boolean;
  77712. /**
  77713. * detach this feature.
  77714. * Will usually be called by the features manager
  77715. *
  77716. * @returns true if successful.
  77717. */
  77718. detach(): boolean;
  77719. /**
  77720. * Dispose this feature and all of the resources attached
  77721. */
  77722. dispose(): void;
  77723. protected _onXRFrame(_xrFrame: XRFrame): void;
  77724. private _setBackgroundState;
  77725. }
  77726. }
  77727. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  77728. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77729. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  77730. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77731. import { WebXRInput } from "babylonjs/XR/webXRInput";
  77732. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77733. import { Nullable } from "babylonjs/types";
  77734. /**
  77735. * Options for the controller physics feature
  77736. */
  77737. export class IWebXRControllerPhysicsOptions {
  77738. /**
  77739. * Should the headset get its own impostor
  77740. */
  77741. enableHeadsetImpostor?: boolean;
  77742. /**
  77743. * Optional parameters for the headset impostor
  77744. */
  77745. headsetImpostorParams?: {
  77746. /**
  77747. * The type of impostor to create. Default is sphere
  77748. */
  77749. impostorType: number;
  77750. /**
  77751. * the size of the impostor. Defaults to 10cm
  77752. */
  77753. impostorSize?: number | {
  77754. width: number;
  77755. height: number;
  77756. depth: number;
  77757. };
  77758. /**
  77759. * Friction definitions
  77760. */
  77761. friction?: number;
  77762. /**
  77763. * Restitution
  77764. */
  77765. restitution?: number;
  77766. };
  77767. /**
  77768. * The physics properties of the future impostors
  77769. */
  77770. physicsProperties?: {
  77771. /**
  77772. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  77773. * Note that this requires a physics engine that supports mesh impostors!
  77774. */
  77775. useControllerMesh?: boolean;
  77776. /**
  77777. * The type of impostor to create. Default is sphere
  77778. */
  77779. impostorType?: number;
  77780. /**
  77781. * the size of the impostor. Defaults to 10cm
  77782. */
  77783. impostorSize?: number | {
  77784. width: number;
  77785. height: number;
  77786. depth: number;
  77787. };
  77788. /**
  77789. * Friction definitions
  77790. */
  77791. friction?: number;
  77792. /**
  77793. * Restitution
  77794. */
  77795. restitution?: number;
  77796. };
  77797. /**
  77798. * the xr input to use with this pointer selection
  77799. */
  77800. xrInput: WebXRInput;
  77801. }
  77802. /**
  77803. * Add physics impostor to your webxr controllers,
  77804. * including naive calculation of their linear and angular velocity
  77805. */
  77806. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  77807. private readonly _options;
  77808. private _attachController;
  77809. private _controllers;
  77810. private _debugMode;
  77811. private _delta;
  77812. private _headsetImpostor?;
  77813. private _headsetMesh?;
  77814. private _lastTimestamp;
  77815. private _tmpQuaternion;
  77816. private _tmpVector;
  77817. /**
  77818. * The module's name
  77819. */
  77820. static readonly Name: string;
  77821. /**
  77822. * The (Babylon) version of this module.
  77823. * This is an integer representing the implementation version.
  77824. * This number does not correspond to the webxr specs version
  77825. */
  77826. static readonly Version: number;
  77827. /**
  77828. * Construct a new Controller Physics Feature
  77829. * @param _xrSessionManager the corresponding xr session manager
  77830. * @param _options options to create this feature with
  77831. */
  77832. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  77833. /**
  77834. * @hidden
  77835. * enable debugging - will show console outputs and the impostor mesh
  77836. */
  77837. _enablePhysicsDebug(): void;
  77838. /**
  77839. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  77840. * @param xrController the controller to add
  77841. */
  77842. addController(xrController: WebXRInputSource): void;
  77843. /**
  77844. * attach this feature
  77845. * Will usually be called by the features manager
  77846. *
  77847. * @returns true if successful.
  77848. */
  77849. attach(): boolean;
  77850. /**
  77851. * detach this feature.
  77852. * Will usually be called by the features manager
  77853. *
  77854. * @returns true if successful.
  77855. */
  77856. detach(): boolean;
  77857. /**
  77858. * Get the headset impostor, if enabled
  77859. * @returns the impostor
  77860. */
  77861. getHeadsetImpostor(): PhysicsImpostor | undefined;
  77862. /**
  77863. * Get the physics impostor of a specific controller.
  77864. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  77865. * @param controller the controller or the controller id of which to get the impostor
  77866. * @returns the impostor or null
  77867. */
  77868. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  77869. /**
  77870. * Update the physics properties provided in the constructor
  77871. * @param newProperties the new properties object
  77872. */
  77873. setPhysicsProperties(newProperties: {
  77874. impostorType?: number;
  77875. impostorSize?: number | {
  77876. width: number;
  77877. height: number;
  77878. depth: number;
  77879. };
  77880. friction?: number;
  77881. restitution?: number;
  77882. }): void;
  77883. protected _onXRFrame(_xrFrame: any): void;
  77884. private _detachController;
  77885. }
  77886. }
  77887. declare module "babylonjs/XR/features/index" {
  77888. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  77889. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  77890. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  77891. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  77892. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  77893. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  77894. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  77895. export * from "babylonjs/XR/features/WebXRHitTest";
  77896. }
  77897. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  77898. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77900. import { Scene } from "babylonjs/scene";
  77901. /**
  77902. * The motion controller class for all microsoft mixed reality controllers
  77903. */
  77904. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77905. protected readonly _mapping: {
  77906. defaultButton: {
  77907. valueNodeName: string;
  77908. unpressedNodeName: string;
  77909. pressedNodeName: string;
  77910. };
  77911. defaultAxis: {
  77912. valueNodeName: string;
  77913. minNodeName: string;
  77914. maxNodeName: string;
  77915. };
  77916. buttons: {
  77917. "xr-standard-trigger": {
  77918. rootNodeName: string;
  77919. componentProperty: string;
  77920. states: string[];
  77921. };
  77922. "xr-standard-squeeze": {
  77923. rootNodeName: string;
  77924. componentProperty: string;
  77925. states: string[];
  77926. };
  77927. "xr-standard-touchpad": {
  77928. rootNodeName: string;
  77929. labelAnchorNodeName: string;
  77930. touchPointNodeName: string;
  77931. };
  77932. "xr-standard-thumbstick": {
  77933. rootNodeName: string;
  77934. componentProperty: string;
  77935. states: string[];
  77936. };
  77937. };
  77938. axes: {
  77939. "xr-standard-touchpad": {
  77940. "x-axis": {
  77941. rootNodeName: string;
  77942. };
  77943. "y-axis": {
  77944. rootNodeName: string;
  77945. };
  77946. };
  77947. "xr-standard-thumbstick": {
  77948. "x-axis": {
  77949. rootNodeName: string;
  77950. };
  77951. "y-axis": {
  77952. rootNodeName: string;
  77953. };
  77954. };
  77955. };
  77956. };
  77957. /**
  77958. * The base url used to load the left and right controller models
  77959. */
  77960. static MODEL_BASE_URL: string;
  77961. /**
  77962. * The name of the left controller model file
  77963. */
  77964. static MODEL_LEFT_FILENAME: string;
  77965. /**
  77966. * The name of the right controller model file
  77967. */
  77968. static MODEL_RIGHT_FILENAME: string;
  77969. profileId: string;
  77970. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77971. protected _getFilenameAndPath(): {
  77972. filename: string;
  77973. path: string;
  77974. };
  77975. protected _getModelLoadingConstraints(): boolean;
  77976. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77977. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77978. protected _updateModel(): void;
  77979. }
  77980. }
  77981. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  77982. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77984. import { Scene } from "babylonjs/scene";
  77985. /**
  77986. * The motion controller class for oculus touch (quest, rift).
  77987. * This class supports legacy mapping as well the standard xr mapping
  77988. */
  77989. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77990. private _forceLegacyControllers;
  77991. private _modelRootNode;
  77992. /**
  77993. * The base url used to load the left and right controller models
  77994. */
  77995. static MODEL_BASE_URL: string;
  77996. /**
  77997. * The name of the left controller model file
  77998. */
  77999. static MODEL_LEFT_FILENAME: string;
  78000. /**
  78001. * The name of the right controller model file
  78002. */
  78003. static MODEL_RIGHT_FILENAME: string;
  78004. /**
  78005. * Base Url for the Quest controller model.
  78006. */
  78007. static QUEST_MODEL_BASE_URL: string;
  78008. profileId: string;
  78009. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  78010. protected _getFilenameAndPath(): {
  78011. filename: string;
  78012. path: string;
  78013. };
  78014. protected _getModelLoadingConstraints(): boolean;
  78015. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78016. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78017. protected _updateModel(): void;
  78018. /**
  78019. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78020. * between the touch and touch 2.
  78021. */
  78022. private _isQuest;
  78023. }
  78024. }
  78025. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78026. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78027. import { Scene } from "babylonjs/scene";
  78028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78029. /**
  78030. * The motion controller class for the standard HTC-Vive controllers
  78031. */
  78032. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78033. private _modelRootNode;
  78034. /**
  78035. * The base url used to load the left and right controller models
  78036. */
  78037. static MODEL_BASE_URL: string;
  78038. /**
  78039. * File name for the controller model.
  78040. */
  78041. static MODEL_FILENAME: string;
  78042. profileId: string;
  78043. /**
  78044. * Create a new Vive motion controller object
  78045. * @param scene the scene to use to create this controller
  78046. * @param gamepadObject the corresponding gamepad object
  78047. * @param handedness the handedness of the controller
  78048. */
  78049. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78050. protected _getFilenameAndPath(): {
  78051. filename: string;
  78052. path: string;
  78053. };
  78054. protected _getModelLoadingConstraints(): boolean;
  78055. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78056. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78057. protected _updateModel(): void;
  78058. }
  78059. }
  78060. declare module "babylonjs/XR/motionController/index" {
  78061. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78062. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78063. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78064. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78065. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78066. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78067. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78068. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78069. }
  78070. declare module "babylonjs/XR/index" {
  78071. export * from "babylonjs/XR/webXRCamera";
  78072. export * from "babylonjs/XR/webXREnterExitUI";
  78073. export * from "babylonjs/XR/webXRExperienceHelper";
  78074. export * from "babylonjs/XR/webXRInput";
  78075. export * from "babylonjs/XR/webXRInputSource";
  78076. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78077. export * from "babylonjs/XR/webXRTypes";
  78078. export * from "babylonjs/XR/webXRSessionManager";
  78079. export * from "babylonjs/XR/webXRDefaultExperience";
  78080. export * from "babylonjs/XR/webXRFeaturesManager";
  78081. export * from "babylonjs/XR/features/index";
  78082. export * from "babylonjs/XR/motionController/index";
  78083. }
  78084. declare module "babylonjs/index" {
  78085. export * from "babylonjs/abstractScene";
  78086. export * from "babylonjs/Actions/index";
  78087. export * from "babylonjs/Animations/index";
  78088. export * from "babylonjs/assetContainer";
  78089. export * from "babylonjs/Audio/index";
  78090. export * from "babylonjs/Behaviors/index";
  78091. export * from "babylonjs/Bones/index";
  78092. export * from "babylonjs/Cameras/index";
  78093. export * from "babylonjs/Collisions/index";
  78094. export * from "babylonjs/Culling/index";
  78095. export * from "babylonjs/Debug/index";
  78096. export * from "babylonjs/DeviceInput/index";
  78097. export * from "babylonjs/Engines/index";
  78098. export * from "babylonjs/Events/index";
  78099. export * from "babylonjs/Gamepads/index";
  78100. export * from "babylonjs/Gizmos/index";
  78101. export * from "babylonjs/Helpers/index";
  78102. export * from "babylonjs/Instrumentation/index";
  78103. export * from "babylonjs/Layers/index";
  78104. export * from "babylonjs/LensFlares/index";
  78105. export * from "babylonjs/Lights/index";
  78106. export * from "babylonjs/Loading/index";
  78107. export * from "babylonjs/Materials/index";
  78108. export * from "babylonjs/Maths/index";
  78109. export * from "babylonjs/Meshes/index";
  78110. export * from "babylonjs/Morph/index";
  78111. export * from "babylonjs/Navigation/index";
  78112. export * from "babylonjs/node";
  78113. export * from "babylonjs/Offline/index";
  78114. export * from "babylonjs/Particles/index";
  78115. export * from "babylonjs/Physics/index";
  78116. export * from "babylonjs/PostProcesses/index";
  78117. export * from "babylonjs/Probes/index";
  78118. export * from "babylonjs/Rendering/index";
  78119. export * from "babylonjs/scene";
  78120. export * from "babylonjs/sceneComponent";
  78121. export * from "babylonjs/Sprites/index";
  78122. export * from "babylonjs/States/index";
  78123. export * from "babylonjs/Misc/index";
  78124. export * from "babylonjs/XR/index";
  78125. export * from "babylonjs/types";
  78126. }
  78127. declare module "babylonjs/Animations/pathCursor" {
  78128. import { Vector3 } from "babylonjs/Maths/math.vector";
  78129. import { Path2 } from "babylonjs/Maths/math.path";
  78130. /**
  78131. * A cursor which tracks a point on a path
  78132. */
  78133. export class PathCursor {
  78134. private path;
  78135. /**
  78136. * Stores path cursor callbacks for when an onchange event is triggered
  78137. */
  78138. private _onchange;
  78139. /**
  78140. * The value of the path cursor
  78141. */
  78142. value: number;
  78143. /**
  78144. * The animation array of the path cursor
  78145. */
  78146. animations: Animation[];
  78147. /**
  78148. * Initializes the path cursor
  78149. * @param path The path to track
  78150. */
  78151. constructor(path: Path2);
  78152. /**
  78153. * Gets the cursor point on the path
  78154. * @returns A point on the path cursor at the cursor location
  78155. */
  78156. getPoint(): Vector3;
  78157. /**
  78158. * Moves the cursor ahead by the step amount
  78159. * @param step The amount to move the cursor forward
  78160. * @returns This path cursor
  78161. */
  78162. moveAhead(step?: number): PathCursor;
  78163. /**
  78164. * Moves the cursor behind by the step amount
  78165. * @param step The amount to move the cursor back
  78166. * @returns This path cursor
  78167. */
  78168. moveBack(step?: number): PathCursor;
  78169. /**
  78170. * Moves the cursor by the step amount
  78171. * If the step amount is greater than one, an exception is thrown
  78172. * @param step The amount to move the cursor
  78173. * @returns This path cursor
  78174. */
  78175. move(step: number): PathCursor;
  78176. /**
  78177. * Ensures that the value is limited between zero and one
  78178. * @returns This path cursor
  78179. */
  78180. private ensureLimits;
  78181. /**
  78182. * Runs onchange callbacks on change (used by the animation engine)
  78183. * @returns This path cursor
  78184. */
  78185. private raiseOnChange;
  78186. /**
  78187. * Executes a function on change
  78188. * @param f A path cursor onchange callback
  78189. * @returns This path cursor
  78190. */
  78191. onchange(f: (cursor: PathCursor) => void): PathCursor;
  78192. }
  78193. }
  78194. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  78195. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  78196. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  78197. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  78198. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  78199. }
  78200. declare module "babylonjs/Engines/Processors/Expressions/index" {
  78201. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  78202. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  78203. }
  78204. declare module "babylonjs/Engines/Processors/index" {
  78205. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  78206. export * from "babylonjs/Engines/Processors/Expressions/index";
  78207. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  78208. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  78209. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  78210. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  78211. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  78212. export * from "babylonjs/Engines/Processors/shaderProcessor";
  78213. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  78214. }
  78215. declare module "babylonjs/Legacy/legacy" {
  78216. import * as Babylon from "babylonjs/index";
  78217. export * from "babylonjs/index";
  78218. }
  78219. declare module "babylonjs/Shaders/blur.fragment" {
  78220. /** @hidden */
  78221. export var blurPixelShader: {
  78222. name: string;
  78223. shader: string;
  78224. };
  78225. }
  78226. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  78227. /** @hidden */
  78228. export var pointCloudVertexDeclaration: {
  78229. name: string;
  78230. shader: string;
  78231. };
  78232. }
  78233. declare module "babylonjs" {
  78234. export * from "babylonjs/Legacy/legacy";
  78235. }
  78236. declare module BABYLON {
  78237. /** Alias type for value that can be null */
  78238. export type Nullable<T> = T | null;
  78239. /**
  78240. * Alias type for number that are floats
  78241. * @ignorenaming
  78242. */
  78243. export type float = number;
  78244. /**
  78245. * Alias type for number that are doubles.
  78246. * @ignorenaming
  78247. */
  78248. export type double = number;
  78249. /**
  78250. * Alias type for number that are integer
  78251. * @ignorenaming
  78252. */
  78253. export type int = number;
  78254. /** Alias type for number array or Float32Array */
  78255. export type FloatArray = number[] | Float32Array;
  78256. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  78257. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  78258. /**
  78259. * Alias for types that can be used by a Buffer or VertexBuffer.
  78260. */
  78261. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  78262. /**
  78263. * Alias type for primitive types
  78264. * @ignorenaming
  78265. */
  78266. type Primitive = undefined | null | boolean | string | number | Function;
  78267. /**
  78268. * Type modifier to make all the properties of an object Readonly
  78269. */
  78270. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  78271. /**
  78272. * Type modifier to make all the properties of an object Readonly recursively
  78273. */
  78274. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  78275. /**
  78276. * Type modifier to make object properties readonly.
  78277. */
  78278. export type DeepImmutableObject<T> = {
  78279. readonly [K in keyof T]: DeepImmutable<T[K]>;
  78280. };
  78281. /** @hidden */
  78282. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  78283. }
  78284. }
  78285. declare module BABYLON {
  78286. /**
  78287. * A class serves as a medium between the observable and its observers
  78288. */
  78289. export class EventState {
  78290. /**
  78291. * Create a new EventState
  78292. * @param mask defines the mask associated with this state
  78293. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78294. * @param target defines the original target of the state
  78295. * @param currentTarget defines the current target of the state
  78296. */
  78297. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  78298. /**
  78299. * Initialize the current event state
  78300. * @param mask defines the mask associated with this state
  78301. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78302. * @param target defines the original target of the state
  78303. * @param currentTarget defines the current target of the state
  78304. * @returns the current event state
  78305. */
  78306. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  78307. /**
  78308. * An Observer can set this property to true to prevent subsequent observers of being notified
  78309. */
  78310. skipNextObservers: boolean;
  78311. /**
  78312. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78313. */
  78314. mask: number;
  78315. /**
  78316. * The object that originally notified the event
  78317. */
  78318. target?: any;
  78319. /**
  78320. * The current object in the bubbling phase
  78321. */
  78322. currentTarget?: any;
  78323. /**
  78324. * This will be populated with the return value of the last function that was executed.
  78325. * If it is the first function in the callback chain it will be the event data.
  78326. */
  78327. lastReturnValue?: any;
  78328. }
  78329. /**
  78330. * Represent an Observer registered to a given Observable object.
  78331. */
  78332. export class Observer<T> {
  78333. /**
  78334. * Defines the callback to call when the observer is notified
  78335. */
  78336. callback: (eventData: T, eventState: EventState) => void;
  78337. /**
  78338. * Defines the mask of the observer (used to filter notifications)
  78339. */
  78340. mask: number;
  78341. /**
  78342. * Defines the current scope used to restore the JS context
  78343. */
  78344. scope: any;
  78345. /** @hidden */
  78346. _willBeUnregistered: boolean;
  78347. /**
  78348. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  78349. */
  78350. unregisterOnNextCall: boolean;
  78351. /**
  78352. * Creates a new observer
  78353. * @param callback defines the callback to call when the observer is notified
  78354. * @param mask defines the mask of the observer (used to filter notifications)
  78355. * @param scope defines the current scope used to restore the JS context
  78356. */
  78357. constructor(
  78358. /**
  78359. * Defines the callback to call when the observer is notified
  78360. */
  78361. callback: (eventData: T, eventState: EventState) => void,
  78362. /**
  78363. * Defines the mask of the observer (used to filter notifications)
  78364. */
  78365. mask: number,
  78366. /**
  78367. * Defines the current scope used to restore the JS context
  78368. */
  78369. scope?: any);
  78370. }
  78371. /**
  78372. * Represent a list of observers registered to multiple Observables object.
  78373. */
  78374. export class MultiObserver<T> {
  78375. private _observers;
  78376. private _observables;
  78377. /**
  78378. * Release associated resources
  78379. */
  78380. dispose(): void;
  78381. /**
  78382. * Raise a callback when one of the observable will notify
  78383. * @param observables defines a list of observables to watch
  78384. * @param callback defines the callback to call on notification
  78385. * @param mask defines the mask used to filter notifications
  78386. * @param scope defines the current scope used to restore the JS context
  78387. * @returns the new MultiObserver
  78388. */
  78389. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  78390. }
  78391. /**
  78392. * The Observable class is a simple implementation of the Observable pattern.
  78393. *
  78394. * 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.
  78395. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  78396. * 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).
  78397. * 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.
  78398. */
  78399. export class Observable<T> {
  78400. private _observers;
  78401. private _eventState;
  78402. private _onObserverAdded;
  78403. /**
  78404. * Gets the list of observers
  78405. */
  78406. get observers(): Array<Observer<T>>;
  78407. /**
  78408. * Creates a new observable
  78409. * @param onObserverAdded defines a callback to call when a new observer is added
  78410. */
  78411. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  78412. /**
  78413. * Create a new Observer with the specified callback
  78414. * @param callback the callback that will be executed for that Observer
  78415. * @param mask the mask used to filter observers
  78416. * @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.
  78417. * @param scope optional scope for the callback to be called from
  78418. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  78419. * @returns the new observer created for the callback
  78420. */
  78421. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  78422. /**
  78423. * Create a new Observer with the specified callback and unregisters after the next notification
  78424. * @param callback the callback that will be executed for that Observer
  78425. * @returns the new observer created for the callback
  78426. */
  78427. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  78428. /**
  78429. * Remove an Observer from the Observable object
  78430. * @param observer the instance of the Observer to remove
  78431. * @returns false if it doesn't belong to this Observable
  78432. */
  78433. remove(observer: Nullable<Observer<T>>): boolean;
  78434. /**
  78435. * Remove a callback from the Observable object
  78436. * @param callback the callback to remove
  78437. * @param scope optional scope. If used only the callbacks with this scope will be removed
  78438. * @returns false if it doesn't belong to this Observable
  78439. */
  78440. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  78441. private _deferUnregister;
  78442. private _remove;
  78443. /**
  78444. * Moves the observable to the top of the observer list making it get called first when notified
  78445. * @param observer the observer to move
  78446. */
  78447. makeObserverTopPriority(observer: Observer<T>): void;
  78448. /**
  78449. * Moves the observable to the bottom of the observer list making it get called last when notified
  78450. * @param observer the observer to move
  78451. */
  78452. makeObserverBottomPriority(observer: Observer<T>): void;
  78453. /**
  78454. * Notify all Observers by calling their respective callback with the given data
  78455. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  78456. * @param eventData defines the data to send to all observers
  78457. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  78458. * @param target defines the original target of the state
  78459. * @param currentTarget defines the current target of the state
  78460. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  78461. */
  78462. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  78463. /**
  78464. * Calling this will execute each callback, expecting it to be a promise or return a value.
  78465. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  78466. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  78467. * and it is crucial that all callbacks will be executed.
  78468. * The order of the callbacks is kept, callbacks are not executed parallel.
  78469. *
  78470. * @param eventData The data to be sent to each callback
  78471. * @param mask is used to filter observers defaults to -1
  78472. * @param target defines the callback target (see EventState)
  78473. * @param currentTarget defines he current object in the bubbling phase
  78474. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  78475. */
  78476. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  78477. /**
  78478. * Notify a specific observer
  78479. * @param observer defines the observer to notify
  78480. * @param eventData defines the data to be sent to each callback
  78481. * @param mask is used to filter observers defaults to -1
  78482. */
  78483. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  78484. /**
  78485. * Gets a boolean indicating if the observable has at least one observer
  78486. * @returns true is the Observable has at least one Observer registered
  78487. */
  78488. hasObservers(): boolean;
  78489. /**
  78490. * Clear the list of observers
  78491. */
  78492. clear(): void;
  78493. /**
  78494. * Clone the current observable
  78495. * @returns a new observable
  78496. */
  78497. clone(): Observable<T>;
  78498. /**
  78499. * Does this observable handles observer registered with a given mask
  78500. * @param mask defines the mask to be tested
  78501. * @return whether or not one observer registered with the given mask is handeled
  78502. **/
  78503. hasSpecificMask(mask?: number): boolean;
  78504. }
  78505. }
  78506. declare module BABYLON {
  78507. /**
  78508. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  78509. * Babylon.js
  78510. */
  78511. export class DomManagement {
  78512. /**
  78513. * Checks if the window object exists
  78514. * @returns true if the window object exists
  78515. */
  78516. static IsWindowObjectExist(): boolean;
  78517. /**
  78518. * Checks if the navigator object exists
  78519. * @returns true if the navigator object exists
  78520. */
  78521. static IsNavigatorAvailable(): boolean;
  78522. /**
  78523. * Check if the document object exists
  78524. * @returns true if the document object exists
  78525. */
  78526. static IsDocumentAvailable(): boolean;
  78527. /**
  78528. * Extracts text content from a DOM element hierarchy
  78529. * @param element defines the root element
  78530. * @returns a string
  78531. */
  78532. static GetDOMTextContent(element: HTMLElement): string;
  78533. }
  78534. }
  78535. declare module BABYLON {
  78536. /**
  78537. * Logger used througouht the application to allow configuration of
  78538. * the log level required for the messages.
  78539. */
  78540. export class Logger {
  78541. /**
  78542. * No log
  78543. */
  78544. static readonly NoneLogLevel: number;
  78545. /**
  78546. * Only message logs
  78547. */
  78548. static readonly MessageLogLevel: number;
  78549. /**
  78550. * Only warning logs
  78551. */
  78552. static readonly WarningLogLevel: number;
  78553. /**
  78554. * Only error logs
  78555. */
  78556. static readonly ErrorLogLevel: number;
  78557. /**
  78558. * All logs
  78559. */
  78560. static readonly AllLogLevel: number;
  78561. private static _LogCache;
  78562. /**
  78563. * Gets a value indicating the number of loading errors
  78564. * @ignorenaming
  78565. */
  78566. static errorsCount: number;
  78567. /**
  78568. * Callback called when a new log is added
  78569. */
  78570. static OnNewCacheEntry: (entry: string) => void;
  78571. private static _AddLogEntry;
  78572. private static _FormatMessage;
  78573. private static _LogDisabled;
  78574. private static _LogEnabled;
  78575. private static _WarnDisabled;
  78576. private static _WarnEnabled;
  78577. private static _ErrorDisabled;
  78578. private static _ErrorEnabled;
  78579. /**
  78580. * Log a message to the console
  78581. */
  78582. static Log: (message: string) => void;
  78583. /**
  78584. * Write a warning message to the console
  78585. */
  78586. static Warn: (message: string) => void;
  78587. /**
  78588. * Write an error message to the console
  78589. */
  78590. static Error: (message: string) => void;
  78591. /**
  78592. * Gets current log cache (list of logs)
  78593. */
  78594. static get LogCache(): string;
  78595. /**
  78596. * Clears the log cache
  78597. */
  78598. static ClearLogCache(): void;
  78599. /**
  78600. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  78601. */
  78602. static set LogLevels(level: number);
  78603. }
  78604. }
  78605. declare module BABYLON {
  78606. /** @hidden */
  78607. export class _TypeStore {
  78608. /** @hidden */
  78609. static RegisteredTypes: {
  78610. [key: string]: Object;
  78611. };
  78612. /** @hidden */
  78613. static GetClass(fqdn: string): any;
  78614. }
  78615. }
  78616. declare module BABYLON {
  78617. /**
  78618. * Helper to manipulate strings
  78619. */
  78620. export class StringTools {
  78621. /**
  78622. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  78623. * @param str Source string
  78624. * @param suffix Suffix to search for in the source string
  78625. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78626. */
  78627. static EndsWith(str: string, suffix: string): boolean;
  78628. /**
  78629. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  78630. * @param str Source string
  78631. * @param suffix Suffix to search for in the source string
  78632. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78633. */
  78634. static StartsWith(str: string, suffix: string): boolean;
  78635. /**
  78636. * Decodes a buffer into a string
  78637. * @param buffer The buffer to decode
  78638. * @returns The decoded string
  78639. */
  78640. static Decode(buffer: Uint8Array | Uint16Array): string;
  78641. /**
  78642. * Encode a buffer to a base64 string
  78643. * @param buffer defines the buffer to encode
  78644. * @returns the encoded string
  78645. */
  78646. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  78647. /**
  78648. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  78649. * @param num the number to convert and pad
  78650. * @param length the expected length of the string
  78651. * @returns the padded string
  78652. */
  78653. static PadNumber(num: number, length: number): string;
  78654. }
  78655. }
  78656. declare module BABYLON {
  78657. /**
  78658. * Class containing a set of static utilities functions for deep copy.
  78659. */
  78660. export class DeepCopier {
  78661. /**
  78662. * Tries to copy an object by duplicating every property
  78663. * @param source defines the source object
  78664. * @param destination defines the target object
  78665. * @param doNotCopyList defines a list of properties to avoid
  78666. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  78667. */
  78668. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  78669. }
  78670. }
  78671. declare module BABYLON {
  78672. /**
  78673. * Class containing a set of static utilities functions for precision date
  78674. */
  78675. export class PrecisionDate {
  78676. /**
  78677. * Gets either window.performance.now() if supported or Date.now() else
  78678. */
  78679. static get Now(): number;
  78680. }
  78681. }
  78682. declare module BABYLON {
  78683. /** @hidden */
  78684. export class _DevTools {
  78685. static WarnImport(name: string): string;
  78686. }
  78687. }
  78688. declare module BABYLON {
  78689. /**
  78690. * Interface used to define the mechanism to get data from the network
  78691. */
  78692. export interface IWebRequest {
  78693. /**
  78694. * Returns client's response url
  78695. */
  78696. responseURL: string;
  78697. /**
  78698. * Returns client's status
  78699. */
  78700. status: number;
  78701. /**
  78702. * Returns client's status as a text
  78703. */
  78704. statusText: string;
  78705. }
  78706. }
  78707. declare module BABYLON {
  78708. /**
  78709. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  78710. */
  78711. export class WebRequest implements IWebRequest {
  78712. private _xhr;
  78713. /**
  78714. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  78715. * i.e. when loading files, where the server/service expects an Authorization header
  78716. */
  78717. static CustomRequestHeaders: {
  78718. [key: string]: string;
  78719. };
  78720. /**
  78721. * Add callback functions in this array to update all the requests before they get sent to the network
  78722. */
  78723. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  78724. private _injectCustomRequestHeaders;
  78725. /**
  78726. * Gets or sets a function to be called when loading progress changes
  78727. */
  78728. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  78729. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  78730. /**
  78731. * Returns client's state
  78732. */
  78733. get readyState(): number;
  78734. /**
  78735. * Returns client's status
  78736. */
  78737. get status(): number;
  78738. /**
  78739. * Returns client's status as a text
  78740. */
  78741. get statusText(): string;
  78742. /**
  78743. * Returns client's response
  78744. */
  78745. get response(): any;
  78746. /**
  78747. * Returns client's response url
  78748. */
  78749. get responseURL(): string;
  78750. /**
  78751. * Returns client's response as text
  78752. */
  78753. get responseText(): string;
  78754. /**
  78755. * Gets or sets the expected response type
  78756. */
  78757. get responseType(): XMLHttpRequestResponseType;
  78758. set responseType(value: XMLHttpRequestResponseType);
  78759. /** @hidden */
  78760. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  78761. /** @hidden */
  78762. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  78763. /**
  78764. * Cancels any network activity
  78765. */
  78766. abort(): void;
  78767. /**
  78768. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  78769. * @param body defines an optional request body
  78770. */
  78771. send(body?: Document | BodyInit | null): void;
  78772. /**
  78773. * Sets the request method, request URL
  78774. * @param method defines the method to use (GET, POST, etc..)
  78775. * @param url defines the url to connect with
  78776. */
  78777. open(method: string, url: string): void;
  78778. /**
  78779. * Sets the value of a request header.
  78780. * @param name The name of the header whose value is to be set
  78781. * @param value The value to set as the body of the header
  78782. */
  78783. setRequestHeader(name: string, value: string): void;
  78784. /**
  78785. * Get the string containing the text of a particular header's value.
  78786. * @param name The name of the header
  78787. * @returns The string containing the text of the given header name
  78788. */
  78789. getResponseHeader(name: string): Nullable<string>;
  78790. }
  78791. }
  78792. declare module BABYLON {
  78793. /**
  78794. * File request interface
  78795. */
  78796. export interface IFileRequest {
  78797. /**
  78798. * Raised when the request is complete (success or error).
  78799. */
  78800. onCompleteObservable: Observable<IFileRequest>;
  78801. /**
  78802. * Aborts the request for a file.
  78803. */
  78804. abort: () => void;
  78805. }
  78806. }
  78807. declare module BABYLON {
  78808. /**
  78809. * Define options used to create a render target texture
  78810. */
  78811. export class RenderTargetCreationOptions {
  78812. /**
  78813. * Specifies is mipmaps must be generated
  78814. */
  78815. generateMipMaps?: boolean;
  78816. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  78817. generateDepthBuffer?: boolean;
  78818. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  78819. generateStencilBuffer?: boolean;
  78820. /** Defines texture type (int by default) */
  78821. type?: number;
  78822. /** Defines sampling mode (trilinear by default) */
  78823. samplingMode?: number;
  78824. /** Defines format (RGBA by default) */
  78825. format?: number;
  78826. }
  78827. }
  78828. declare module BABYLON {
  78829. /** Defines the cross module used constants to avoid circular dependncies */
  78830. export class Constants {
  78831. /** Defines that alpha blending is disabled */
  78832. static readonly ALPHA_DISABLE: number;
  78833. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  78834. static readonly ALPHA_ADD: number;
  78835. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  78836. static readonly ALPHA_COMBINE: number;
  78837. /** Defines that alpha blending is DEST - SRC * DEST */
  78838. static readonly ALPHA_SUBTRACT: number;
  78839. /** Defines that alpha blending is SRC * DEST */
  78840. static readonly ALPHA_MULTIPLY: number;
  78841. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  78842. static readonly ALPHA_MAXIMIZED: number;
  78843. /** Defines that alpha blending is SRC + DEST */
  78844. static readonly ALPHA_ONEONE: number;
  78845. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  78846. static readonly ALPHA_PREMULTIPLIED: number;
  78847. /**
  78848. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  78849. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  78850. */
  78851. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  78852. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  78853. static readonly ALPHA_INTERPOLATE: number;
  78854. /**
  78855. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  78856. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  78857. */
  78858. static readonly ALPHA_SCREENMODE: number;
  78859. /**
  78860. * Defines that alpha blending is SRC + DST
  78861. * Alpha will be set to SRC ALPHA + DST ALPHA
  78862. */
  78863. static readonly ALPHA_ONEONE_ONEONE: number;
  78864. /**
  78865. * Defines that alpha blending is SRC * DST ALPHA + DST
  78866. * Alpha will be set to 0
  78867. */
  78868. static readonly ALPHA_ALPHATOCOLOR: number;
  78869. /**
  78870. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78871. */
  78872. static readonly ALPHA_REVERSEONEMINUS: number;
  78873. /**
  78874. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  78875. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  78876. */
  78877. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  78878. /**
  78879. * Defines that alpha blending is SRC + DST
  78880. * Alpha will be set to SRC ALPHA
  78881. */
  78882. static readonly ALPHA_ONEONE_ONEZERO: number;
  78883. /**
  78884. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78885. * Alpha will be set to DST ALPHA
  78886. */
  78887. static readonly ALPHA_EXCLUSION: number;
  78888. /** Defines that alpha blending equation a SUM */
  78889. static readonly ALPHA_EQUATION_ADD: number;
  78890. /** Defines that alpha blending equation a SUBSTRACTION */
  78891. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  78892. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  78893. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  78894. /** Defines that alpha blending equation a MAX operation */
  78895. static readonly ALPHA_EQUATION_MAX: number;
  78896. /** Defines that alpha blending equation a MIN operation */
  78897. static readonly ALPHA_EQUATION_MIN: number;
  78898. /**
  78899. * Defines that alpha blending equation a DARKEN operation:
  78900. * It takes the min of the src and sums the alpha channels.
  78901. */
  78902. static readonly ALPHA_EQUATION_DARKEN: number;
  78903. /** Defines that the ressource is not delayed*/
  78904. static readonly DELAYLOADSTATE_NONE: number;
  78905. /** Defines that the ressource was successfully delay loaded */
  78906. static readonly DELAYLOADSTATE_LOADED: number;
  78907. /** Defines that the ressource is currently delay loading */
  78908. static readonly DELAYLOADSTATE_LOADING: number;
  78909. /** Defines that the ressource is delayed and has not started loading */
  78910. static readonly DELAYLOADSTATE_NOTLOADED: number;
  78911. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  78912. static readonly NEVER: number;
  78913. /** 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 */
  78914. static readonly ALWAYS: number;
  78915. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  78916. static readonly LESS: number;
  78917. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  78918. static readonly EQUAL: number;
  78919. /** 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 */
  78920. static readonly LEQUAL: number;
  78921. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  78922. static readonly GREATER: number;
  78923. /** 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 */
  78924. static readonly GEQUAL: number;
  78925. /** 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 */
  78926. static readonly NOTEQUAL: number;
  78927. /** Passed to stencilOperation to specify that stencil value must be kept */
  78928. static readonly KEEP: number;
  78929. /** Passed to stencilOperation to specify that stencil value must be replaced */
  78930. static readonly REPLACE: number;
  78931. /** Passed to stencilOperation to specify that stencil value must be incremented */
  78932. static readonly INCR: number;
  78933. /** Passed to stencilOperation to specify that stencil value must be decremented */
  78934. static readonly DECR: number;
  78935. /** Passed to stencilOperation to specify that stencil value must be inverted */
  78936. static readonly INVERT: number;
  78937. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  78938. static readonly INCR_WRAP: number;
  78939. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  78940. static readonly DECR_WRAP: number;
  78941. /** Texture is not repeating outside of 0..1 UVs */
  78942. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  78943. /** Texture is repeating outside of 0..1 UVs */
  78944. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  78945. /** Texture is repeating and mirrored */
  78946. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  78947. /** ALPHA */
  78948. static readonly TEXTUREFORMAT_ALPHA: number;
  78949. /** LUMINANCE */
  78950. static readonly TEXTUREFORMAT_LUMINANCE: number;
  78951. /** LUMINANCE_ALPHA */
  78952. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  78953. /** RGB */
  78954. static readonly TEXTUREFORMAT_RGB: number;
  78955. /** RGBA */
  78956. static readonly TEXTUREFORMAT_RGBA: number;
  78957. /** RED */
  78958. static readonly TEXTUREFORMAT_RED: number;
  78959. /** RED (2nd reference) */
  78960. static readonly TEXTUREFORMAT_R: number;
  78961. /** RG */
  78962. static readonly TEXTUREFORMAT_RG: number;
  78963. /** RED_INTEGER */
  78964. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  78965. /** RED_INTEGER (2nd reference) */
  78966. static readonly TEXTUREFORMAT_R_INTEGER: number;
  78967. /** RG_INTEGER */
  78968. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  78969. /** RGB_INTEGER */
  78970. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  78971. /** RGBA_INTEGER */
  78972. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  78973. /** UNSIGNED_BYTE */
  78974. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  78975. /** UNSIGNED_BYTE (2nd reference) */
  78976. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  78977. /** FLOAT */
  78978. static readonly TEXTURETYPE_FLOAT: number;
  78979. /** HALF_FLOAT */
  78980. static readonly TEXTURETYPE_HALF_FLOAT: number;
  78981. /** BYTE */
  78982. static readonly TEXTURETYPE_BYTE: number;
  78983. /** SHORT */
  78984. static readonly TEXTURETYPE_SHORT: number;
  78985. /** UNSIGNED_SHORT */
  78986. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  78987. /** INT */
  78988. static readonly TEXTURETYPE_INT: number;
  78989. /** UNSIGNED_INT */
  78990. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  78991. /** UNSIGNED_SHORT_4_4_4_4 */
  78992. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  78993. /** UNSIGNED_SHORT_5_5_5_1 */
  78994. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  78995. /** UNSIGNED_SHORT_5_6_5 */
  78996. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  78997. /** UNSIGNED_INT_2_10_10_10_REV */
  78998. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  78999. /** UNSIGNED_INT_24_8 */
  79000. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  79001. /** UNSIGNED_INT_10F_11F_11F_REV */
  79002. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  79003. /** UNSIGNED_INT_5_9_9_9_REV */
  79004. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  79005. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  79006. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  79007. /** nearest is mag = nearest and min = nearest and no mip */
  79008. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  79009. /** mag = nearest and min = nearest and mip = none */
  79010. static readonly TEXTURE_NEAREST_NEAREST: number;
  79011. /** Bilinear is mag = linear and min = linear and no mip */
  79012. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79013. /** mag = linear and min = linear and mip = none */
  79014. static readonly TEXTURE_LINEAR_LINEAR: number;
  79015. /** Trilinear is mag = linear and min = linear and mip = linear */
  79016. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79017. /** Trilinear is mag = linear and min = linear and mip = linear */
  79018. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79019. /** mag = nearest and min = nearest and mip = nearest */
  79020. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79021. /** mag = nearest and min = linear and mip = nearest */
  79022. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79023. /** mag = nearest and min = linear and mip = linear */
  79024. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79025. /** mag = nearest and min = linear and mip = none */
  79026. static readonly TEXTURE_NEAREST_LINEAR: number;
  79027. /** nearest is mag = nearest and min = nearest and mip = linear */
  79028. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79029. /** mag = linear and min = nearest and mip = nearest */
  79030. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79031. /** mag = linear and min = nearest and mip = linear */
  79032. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79033. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79034. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79035. /** mag = linear and min = nearest and mip = none */
  79036. static readonly TEXTURE_LINEAR_NEAREST: number;
  79037. /** Explicit coordinates mode */
  79038. static readonly TEXTURE_EXPLICIT_MODE: number;
  79039. /** Spherical coordinates mode */
  79040. static readonly TEXTURE_SPHERICAL_MODE: number;
  79041. /** Planar coordinates mode */
  79042. static readonly TEXTURE_PLANAR_MODE: number;
  79043. /** Cubic coordinates mode */
  79044. static readonly TEXTURE_CUBIC_MODE: number;
  79045. /** Projection coordinates mode */
  79046. static readonly TEXTURE_PROJECTION_MODE: number;
  79047. /** Skybox coordinates mode */
  79048. static readonly TEXTURE_SKYBOX_MODE: number;
  79049. /** Inverse Cubic coordinates mode */
  79050. static readonly TEXTURE_INVCUBIC_MODE: number;
  79051. /** Equirectangular coordinates mode */
  79052. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79053. /** Equirectangular Fixed coordinates mode */
  79054. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79055. /** Equirectangular Fixed Mirrored coordinates mode */
  79056. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79057. /** Offline (baking) quality for texture filtering */
  79058. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79059. /** High quality for texture filtering */
  79060. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79061. /** Medium quality for texture filtering */
  79062. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79063. /** Low quality for texture filtering */
  79064. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79065. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79066. static readonly SCALEMODE_FLOOR: number;
  79067. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79068. static readonly SCALEMODE_NEAREST: number;
  79069. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79070. static readonly SCALEMODE_CEILING: number;
  79071. /**
  79072. * The dirty texture flag value
  79073. */
  79074. static readonly MATERIAL_TextureDirtyFlag: number;
  79075. /**
  79076. * The dirty light flag value
  79077. */
  79078. static readonly MATERIAL_LightDirtyFlag: number;
  79079. /**
  79080. * The dirty fresnel flag value
  79081. */
  79082. static readonly MATERIAL_FresnelDirtyFlag: number;
  79083. /**
  79084. * The dirty attribute flag value
  79085. */
  79086. static readonly MATERIAL_AttributesDirtyFlag: number;
  79087. /**
  79088. * The dirty misc flag value
  79089. */
  79090. static readonly MATERIAL_MiscDirtyFlag: number;
  79091. /**
  79092. * The all dirty flag value
  79093. */
  79094. static readonly MATERIAL_AllDirtyFlag: number;
  79095. /**
  79096. * Returns the triangle fill mode
  79097. */
  79098. static readonly MATERIAL_TriangleFillMode: number;
  79099. /**
  79100. * Returns the wireframe mode
  79101. */
  79102. static readonly MATERIAL_WireFrameFillMode: number;
  79103. /**
  79104. * Returns the point fill mode
  79105. */
  79106. static readonly MATERIAL_PointFillMode: number;
  79107. /**
  79108. * Returns the point list draw mode
  79109. */
  79110. static readonly MATERIAL_PointListDrawMode: number;
  79111. /**
  79112. * Returns the line list draw mode
  79113. */
  79114. static readonly MATERIAL_LineListDrawMode: number;
  79115. /**
  79116. * Returns the line loop draw mode
  79117. */
  79118. static readonly MATERIAL_LineLoopDrawMode: number;
  79119. /**
  79120. * Returns the line strip draw mode
  79121. */
  79122. static readonly MATERIAL_LineStripDrawMode: number;
  79123. /**
  79124. * Returns the triangle strip draw mode
  79125. */
  79126. static readonly MATERIAL_TriangleStripDrawMode: number;
  79127. /**
  79128. * Returns the triangle fan draw mode
  79129. */
  79130. static readonly MATERIAL_TriangleFanDrawMode: number;
  79131. /**
  79132. * Stores the clock-wise side orientation
  79133. */
  79134. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79135. /**
  79136. * Stores the counter clock-wise side orientation
  79137. */
  79138. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79139. /**
  79140. * Nothing
  79141. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79142. */
  79143. static readonly ACTION_NothingTrigger: number;
  79144. /**
  79145. * On pick
  79146. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79147. */
  79148. static readonly ACTION_OnPickTrigger: number;
  79149. /**
  79150. * On left pick
  79151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79152. */
  79153. static readonly ACTION_OnLeftPickTrigger: number;
  79154. /**
  79155. * On right pick
  79156. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79157. */
  79158. static readonly ACTION_OnRightPickTrigger: number;
  79159. /**
  79160. * On center pick
  79161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79162. */
  79163. static readonly ACTION_OnCenterPickTrigger: number;
  79164. /**
  79165. * On pick down
  79166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79167. */
  79168. static readonly ACTION_OnPickDownTrigger: number;
  79169. /**
  79170. * On double pick
  79171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79172. */
  79173. static readonly ACTION_OnDoublePickTrigger: number;
  79174. /**
  79175. * On pick up
  79176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79177. */
  79178. static readonly ACTION_OnPickUpTrigger: number;
  79179. /**
  79180. * On pick out.
  79181. * This trigger will only be raised if you also declared a OnPickDown
  79182. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79183. */
  79184. static readonly ACTION_OnPickOutTrigger: number;
  79185. /**
  79186. * On long press
  79187. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79188. */
  79189. static readonly ACTION_OnLongPressTrigger: number;
  79190. /**
  79191. * On pointer over
  79192. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79193. */
  79194. static readonly ACTION_OnPointerOverTrigger: number;
  79195. /**
  79196. * On pointer out
  79197. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79198. */
  79199. static readonly ACTION_OnPointerOutTrigger: number;
  79200. /**
  79201. * On every frame
  79202. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79203. */
  79204. static readonly ACTION_OnEveryFrameTrigger: number;
  79205. /**
  79206. * On intersection enter
  79207. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79208. */
  79209. static readonly ACTION_OnIntersectionEnterTrigger: number;
  79210. /**
  79211. * On intersection exit
  79212. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79213. */
  79214. static readonly ACTION_OnIntersectionExitTrigger: number;
  79215. /**
  79216. * On key down
  79217. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79218. */
  79219. static readonly ACTION_OnKeyDownTrigger: number;
  79220. /**
  79221. * On key up
  79222. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79223. */
  79224. static readonly ACTION_OnKeyUpTrigger: number;
  79225. /**
  79226. * Billboard mode will only apply to Y axis
  79227. */
  79228. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  79229. /**
  79230. * Billboard mode will apply to all axes
  79231. */
  79232. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  79233. /**
  79234. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79235. */
  79236. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  79237. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79238. * Test order :
  79239. * Is the bounding sphere outside the frustum ?
  79240. * If not, are the bounding box vertices outside the frustum ?
  79241. * It not, then the cullable object is in the frustum.
  79242. */
  79243. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  79244. /** Culling strategy : Bounding Sphere Only.
  79245. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79246. * It's also less accurate than the standard because some not visible objects can still be selected.
  79247. * Test : is the bounding sphere outside the frustum ?
  79248. * If not, then the cullable object is in the frustum.
  79249. */
  79250. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79251. /** Culling strategy : Optimistic Inclusion.
  79252. * This in an inclusion test first, then the standard exclusion test.
  79253. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79254. * 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.
  79255. * Anyway, it's as accurate as the standard strategy.
  79256. * Test :
  79257. * Is the cullable object bounding sphere center in the frustum ?
  79258. * If not, apply the default culling strategy.
  79259. */
  79260. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79261. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79262. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79263. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79264. * 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.
  79265. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79266. * Test :
  79267. * Is the cullable object bounding sphere center in the frustum ?
  79268. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79269. */
  79270. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79271. /**
  79272. * No logging while loading
  79273. */
  79274. static readonly SCENELOADER_NO_LOGGING: number;
  79275. /**
  79276. * Minimal logging while loading
  79277. */
  79278. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  79279. /**
  79280. * Summary logging while loading
  79281. */
  79282. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  79283. /**
  79284. * Detailled logging while loading
  79285. */
  79286. static readonly SCENELOADER_DETAILED_LOGGING: number;
  79287. }
  79288. }
  79289. declare module BABYLON {
  79290. /**
  79291. * This represents the required contract to create a new type of texture loader.
  79292. */
  79293. export interface IInternalTextureLoader {
  79294. /**
  79295. * Defines wether the loader supports cascade loading the different faces.
  79296. */
  79297. supportCascades: boolean;
  79298. /**
  79299. * This returns if the loader support the current file information.
  79300. * @param extension defines the file extension of the file being loaded
  79301. * @param mimeType defines the optional mime type of the file being loaded
  79302. * @returns true if the loader can load the specified file
  79303. */
  79304. canLoad(extension: string, mimeType?: string): boolean;
  79305. /**
  79306. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  79307. * @param data contains the texture data
  79308. * @param texture defines the BabylonJS internal texture
  79309. * @param createPolynomials will be true if polynomials have been requested
  79310. * @param onLoad defines the callback to trigger once the texture is ready
  79311. * @param onError defines the callback to trigger in case of error
  79312. */
  79313. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  79314. /**
  79315. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  79316. * @param data contains the texture data
  79317. * @param texture defines the BabylonJS internal texture
  79318. * @param callback defines the method to call once ready to upload
  79319. */
  79320. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  79321. }
  79322. }
  79323. declare module BABYLON {
  79324. /**
  79325. * Class used to store and describe the pipeline context associated with an effect
  79326. */
  79327. export interface IPipelineContext {
  79328. /**
  79329. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  79330. */
  79331. isAsync: boolean;
  79332. /**
  79333. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  79334. */
  79335. isReady: boolean;
  79336. /** @hidden */
  79337. _getVertexShaderCode(): string | null;
  79338. /** @hidden */
  79339. _getFragmentShaderCode(): string | null;
  79340. /** @hidden */
  79341. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  79342. }
  79343. }
  79344. declare module BABYLON {
  79345. /**
  79346. * Class used to store gfx data (like WebGLBuffer)
  79347. */
  79348. export class DataBuffer {
  79349. /**
  79350. * Gets or sets the number of objects referencing this buffer
  79351. */
  79352. references: number;
  79353. /** Gets or sets the size of the underlying buffer */
  79354. capacity: number;
  79355. /**
  79356. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  79357. */
  79358. is32Bits: boolean;
  79359. /**
  79360. * Gets the underlying buffer
  79361. */
  79362. get underlyingResource(): any;
  79363. }
  79364. }
  79365. declare module BABYLON {
  79366. /** @hidden */
  79367. export interface IShaderProcessor {
  79368. attributeProcessor?: (attribute: string) => string;
  79369. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  79370. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  79371. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  79372. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  79373. lineProcessor?: (line: string, isFragment: boolean) => string;
  79374. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79375. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79376. }
  79377. }
  79378. declare module BABYLON {
  79379. /** @hidden */
  79380. export interface ProcessingOptions {
  79381. defines: string[];
  79382. indexParameters: any;
  79383. isFragment: boolean;
  79384. shouldUseHighPrecisionShader: boolean;
  79385. supportsUniformBuffers: boolean;
  79386. shadersRepository: string;
  79387. includesShadersStore: {
  79388. [key: string]: string;
  79389. };
  79390. processor?: IShaderProcessor;
  79391. version: string;
  79392. platformName: string;
  79393. lookForClosingBracketForUniformBuffer?: boolean;
  79394. }
  79395. }
  79396. declare module BABYLON {
  79397. /** @hidden */
  79398. export class ShaderCodeNode {
  79399. line: string;
  79400. children: ShaderCodeNode[];
  79401. additionalDefineKey?: string;
  79402. additionalDefineValue?: string;
  79403. isValid(preprocessors: {
  79404. [key: string]: string;
  79405. }): boolean;
  79406. process(preprocessors: {
  79407. [key: string]: string;
  79408. }, options: ProcessingOptions): string;
  79409. }
  79410. }
  79411. declare module BABYLON {
  79412. /** @hidden */
  79413. export class ShaderCodeCursor {
  79414. private _lines;
  79415. lineIndex: number;
  79416. get currentLine(): string;
  79417. get canRead(): boolean;
  79418. set lines(value: string[]);
  79419. }
  79420. }
  79421. declare module BABYLON {
  79422. /** @hidden */
  79423. export class ShaderCodeConditionNode extends ShaderCodeNode {
  79424. process(preprocessors: {
  79425. [key: string]: string;
  79426. }, options: ProcessingOptions): string;
  79427. }
  79428. }
  79429. declare module BABYLON {
  79430. /** @hidden */
  79431. export class ShaderDefineExpression {
  79432. isTrue(preprocessors: {
  79433. [key: string]: string;
  79434. }): boolean;
  79435. private static _OperatorPriority;
  79436. private static _Stack;
  79437. static postfixToInfix(postfix: string[]): string;
  79438. static infixToPostfix(infix: string): string[];
  79439. }
  79440. }
  79441. declare module BABYLON {
  79442. /** @hidden */
  79443. export class ShaderCodeTestNode extends ShaderCodeNode {
  79444. testExpression: ShaderDefineExpression;
  79445. isValid(preprocessors: {
  79446. [key: string]: string;
  79447. }): boolean;
  79448. }
  79449. }
  79450. declare module BABYLON {
  79451. /** @hidden */
  79452. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  79453. define: string;
  79454. not: boolean;
  79455. constructor(define: string, not?: boolean);
  79456. isTrue(preprocessors: {
  79457. [key: string]: string;
  79458. }): boolean;
  79459. }
  79460. }
  79461. declare module BABYLON {
  79462. /** @hidden */
  79463. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  79464. leftOperand: ShaderDefineExpression;
  79465. rightOperand: ShaderDefineExpression;
  79466. isTrue(preprocessors: {
  79467. [key: string]: string;
  79468. }): boolean;
  79469. }
  79470. }
  79471. declare module BABYLON {
  79472. /** @hidden */
  79473. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  79474. leftOperand: ShaderDefineExpression;
  79475. rightOperand: ShaderDefineExpression;
  79476. isTrue(preprocessors: {
  79477. [key: string]: string;
  79478. }): boolean;
  79479. }
  79480. }
  79481. declare module BABYLON {
  79482. /** @hidden */
  79483. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  79484. define: string;
  79485. operand: string;
  79486. testValue: string;
  79487. constructor(define: string, operand: string, testValue: string);
  79488. isTrue(preprocessors: {
  79489. [key: string]: string;
  79490. }): boolean;
  79491. }
  79492. }
  79493. declare module BABYLON {
  79494. /**
  79495. * Class used to enable access to offline support
  79496. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  79497. */
  79498. export interface IOfflineProvider {
  79499. /**
  79500. * Gets a boolean indicating if scene must be saved in the database
  79501. */
  79502. enableSceneOffline: boolean;
  79503. /**
  79504. * Gets a boolean indicating if textures must be saved in the database
  79505. */
  79506. enableTexturesOffline: boolean;
  79507. /**
  79508. * Open the offline support and make it available
  79509. * @param successCallback defines the callback to call on success
  79510. * @param errorCallback defines the callback to call on error
  79511. */
  79512. open(successCallback: () => void, errorCallback: () => void): void;
  79513. /**
  79514. * Loads an image from the offline support
  79515. * @param url defines the url to load from
  79516. * @param image defines the target DOM image
  79517. */
  79518. loadImage(url: string, image: HTMLImageElement): void;
  79519. /**
  79520. * Loads a file from offline support
  79521. * @param url defines the URL to load from
  79522. * @param sceneLoaded defines a callback to call on success
  79523. * @param progressCallBack defines a callback to call when progress changed
  79524. * @param errorCallback defines a callback to call on error
  79525. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  79526. */
  79527. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  79528. }
  79529. }
  79530. declare module BABYLON {
  79531. /**
  79532. * Class used to help managing file picking and drag'n'drop
  79533. * File Storage
  79534. */
  79535. export class FilesInputStore {
  79536. /**
  79537. * List of files ready to be loaded
  79538. */
  79539. static FilesToLoad: {
  79540. [key: string]: File;
  79541. };
  79542. }
  79543. }
  79544. declare module BABYLON {
  79545. /**
  79546. * Class used to define a retry strategy when error happens while loading assets
  79547. */
  79548. export class RetryStrategy {
  79549. /**
  79550. * Function used to defines an exponential back off strategy
  79551. * @param maxRetries defines the maximum number of retries (3 by default)
  79552. * @param baseInterval defines the interval between retries
  79553. * @returns the strategy function to use
  79554. */
  79555. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  79556. }
  79557. }
  79558. declare module BABYLON {
  79559. /**
  79560. * @ignore
  79561. * Application error to support additional information when loading a file
  79562. */
  79563. export abstract class BaseError extends Error {
  79564. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  79565. }
  79566. }
  79567. declare module BABYLON {
  79568. /** @ignore */
  79569. export class LoadFileError extends BaseError {
  79570. request?: WebRequest;
  79571. file?: File;
  79572. /**
  79573. * Creates a new LoadFileError
  79574. * @param message defines the message of the error
  79575. * @param request defines the optional web request
  79576. * @param file defines the optional file
  79577. */
  79578. constructor(message: string, object?: WebRequest | File);
  79579. }
  79580. /** @ignore */
  79581. export class RequestFileError extends BaseError {
  79582. request: WebRequest;
  79583. /**
  79584. * Creates a new LoadFileError
  79585. * @param message defines the message of the error
  79586. * @param request defines the optional web request
  79587. */
  79588. constructor(message: string, request: WebRequest);
  79589. }
  79590. /** @ignore */
  79591. export class ReadFileError extends BaseError {
  79592. file: File;
  79593. /**
  79594. * Creates a new ReadFileError
  79595. * @param message defines the message of the error
  79596. * @param file defines the optional file
  79597. */
  79598. constructor(message: string, file: File);
  79599. }
  79600. /**
  79601. * @hidden
  79602. */
  79603. export class FileTools {
  79604. /**
  79605. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  79606. */
  79607. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  79608. /**
  79609. * Gets or sets the base URL to use to load assets
  79610. */
  79611. static BaseUrl: string;
  79612. /**
  79613. * Default behaviour for cors in the application.
  79614. * It can be a string if the expected behavior is identical in the entire app.
  79615. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  79616. */
  79617. static CorsBehavior: string | ((url: string | string[]) => string);
  79618. /**
  79619. * Gets or sets a function used to pre-process url before using them to load assets
  79620. */
  79621. static PreprocessUrl: (url: string) => string;
  79622. /**
  79623. * Removes unwanted characters from an url
  79624. * @param url defines the url to clean
  79625. * @returns the cleaned url
  79626. */
  79627. private static _CleanUrl;
  79628. /**
  79629. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  79630. * @param url define the url we are trying
  79631. * @param element define the dom element where to configure the cors policy
  79632. */
  79633. static SetCorsBehavior(url: string | string[], element: {
  79634. crossOrigin: string | null;
  79635. }): void;
  79636. /**
  79637. * Loads an image as an HTMLImageElement.
  79638. * @param input url string, ArrayBuffer, or Blob to load
  79639. * @param onLoad callback called when the image successfully loads
  79640. * @param onError callback called when the image fails to load
  79641. * @param offlineProvider offline provider for caching
  79642. * @param mimeType optional mime type
  79643. * @returns the HTMLImageElement of the loaded image
  79644. */
  79645. 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>;
  79646. /**
  79647. * Reads a file from a File object
  79648. * @param file defines the file to load
  79649. * @param onSuccess defines the callback to call when data is loaded
  79650. * @param onProgress defines the callback to call during loading process
  79651. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  79652. * @param onError defines the callback to call when an error occurs
  79653. * @returns a file request object
  79654. */
  79655. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  79656. /**
  79657. * Loads a file from a url
  79658. * @param url url to load
  79659. * @param onSuccess callback called when the file successfully loads
  79660. * @param onProgress callback called while file is loading (if the server supports this mode)
  79661. * @param offlineProvider defines the offline provider for caching
  79662. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79663. * @param onError callback called when the file fails to load
  79664. * @returns a file request object
  79665. */
  79666. 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;
  79667. /**
  79668. * Loads a file
  79669. * @param url url to load
  79670. * @param onSuccess callback called when the file successfully loads
  79671. * @param onProgress callback called while file is loading (if the server supports this mode)
  79672. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79673. * @param onError callback called when the file fails to load
  79674. * @param onOpened callback called when the web request is opened
  79675. * @returns a file request object
  79676. */
  79677. 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;
  79678. /**
  79679. * Checks if the loaded document was accessed via `file:`-Protocol.
  79680. * @returns boolean
  79681. */
  79682. static IsFileURL(): boolean;
  79683. }
  79684. }
  79685. declare module BABYLON {
  79686. /** @hidden */
  79687. export class ShaderProcessor {
  79688. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  79689. private static _ProcessPrecision;
  79690. private static _ExtractOperation;
  79691. private static _BuildSubExpression;
  79692. private static _BuildExpression;
  79693. private static _MoveCursorWithinIf;
  79694. private static _MoveCursor;
  79695. private static _EvaluatePreProcessors;
  79696. private static _PreparePreProcessors;
  79697. private static _ProcessShaderConversion;
  79698. private static _ProcessIncludes;
  79699. /**
  79700. * Loads a file from a url
  79701. * @param url url to load
  79702. * @param onSuccess callback called when the file successfully loads
  79703. * @param onProgress callback called while file is loading (if the server supports this mode)
  79704. * @param offlineProvider defines the offline provider for caching
  79705. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79706. * @param onError callback called when the file fails to load
  79707. * @returns a file request object
  79708. * @hidden
  79709. */
  79710. 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;
  79711. }
  79712. }
  79713. declare module BABYLON {
  79714. /**
  79715. * @hidden
  79716. */
  79717. export interface IColor4Like {
  79718. r: float;
  79719. g: float;
  79720. b: float;
  79721. a: float;
  79722. }
  79723. /**
  79724. * @hidden
  79725. */
  79726. export interface IColor3Like {
  79727. r: float;
  79728. g: float;
  79729. b: float;
  79730. }
  79731. /**
  79732. * @hidden
  79733. */
  79734. export interface IVector4Like {
  79735. x: float;
  79736. y: float;
  79737. z: float;
  79738. w: float;
  79739. }
  79740. /**
  79741. * @hidden
  79742. */
  79743. export interface IVector3Like {
  79744. x: float;
  79745. y: float;
  79746. z: float;
  79747. }
  79748. /**
  79749. * @hidden
  79750. */
  79751. export interface IVector2Like {
  79752. x: float;
  79753. y: float;
  79754. }
  79755. /**
  79756. * @hidden
  79757. */
  79758. export interface IMatrixLike {
  79759. toArray(): DeepImmutable<Float32Array>;
  79760. updateFlag: int;
  79761. }
  79762. /**
  79763. * @hidden
  79764. */
  79765. export interface IViewportLike {
  79766. x: float;
  79767. y: float;
  79768. width: float;
  79769. height: float;
  79770. }
  79771. /**
  79772. * @hidden
  79773. */
  79774. export interface IPlaneLike {
  79775. normal: IVector3Like;
  79776. d: float;
  79777. normalize(): void;
  79778. }
  79779. }
  79780. declare module BABYLON {
  79781. /**
  79782. * Interface used to define common properties for effect fallbacks
  79783. */
  79784. export interface IEffectFallbacks {
  79785. /**
  79786. * Removes the defines that should be removed when falling back.
  79787. * @param currentDefines defines the current define statements for the shader.
  79788. * @param effect defines the current effect we try to compile
  79789. * @returns The resulting defines with defines of the current rank removed.
  79790. */
  79791. reduce(currentDefines: string, effect: Effect): string;
  79792. /**
  79793. * Removes the fallback from the bound mesh.
  79794. */
  79795. unBindMesh(): void;
  79796. /**
  79797. * Checks to see if more fallbacks are still availible.
  79798. */
  79799. hasMoreFallbacks: boolean;
  79800. }
  79801. }
  79802. declare module BABYLON {
  79803. /**
  79804. * Class used to evalaute queries containing `and` and `or` operators
  79805. */
  79806. export class AndOrNotEvaluator {
  79807. /**
  79808. * Evaluate a query
  79809. * @param query defines the query to evaluate
  79810. * @param evaluateCallback defines the callback used to filter result
  79811. * @returns true if the query matches
  79812. */
  79813. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  79814. private static _HandleParenthesisContent;
  79815. private static _SimplifyNegation;
  79816. }
  79817. }
  79818. declare module BABYLON {
  79819. /**
  79820. * Class used to store custom tags
  79821. */
  79822. export class Tags {
  79823. /**
  79824. * Adds support for tags on the given object
  79825. * @param obj defines the object to use
  79826. */
  79827. static EnableFor(obj: any): void;
  79828. /**
  79829. * Removes tags support
  79830. * @param obj defines the object to use
  79831. */
  79832. static DisableFor(obj: any): void;
  79833. /**
  79834. * Gets a boolean indicating if the given object has tags
  79835. * @param obj defines the object to use
  79836. * @returns a boolean
  79837. */
  79838. static HasTags(obj: any): boolean;
  79839. /**
  79840. * Gets the tags available on a given object
  79841. * @param obj defines the object to use
  79842. * @param asString defines if the tags must be returned as a string instead of an array of strings
  79843. * @returns the tags
  79844. */
  79845. static GetTags(obj: any, asString?: boolean): any;
  79846. /**
  79847. * Adds tags to an object
  79848. * @param obj defines the object to use
  79849. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  79850. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  79851. */
  79852. static AddTagsTo(obj: any, tagsString: string): void;
  79853. /**
  79854. * @hidden
  79855. */
  79856. static _AddTagTo(obj: any, tag: string): void;
  79857. /**
  79858. * Removes specific tags from a specific object
  79859. * @param obj defines the object to use
  79860. * @param tagsString defines the tags to remove
  79861. */
  79862. static RemoveTagsFrom(obj: any, tagsString: string): void;
  79863. /**
  79864. * @hidden
  79865. */
  79866. static _RemoveTagFrom(obj: any, tag: string): void;
  79867. /**
  79868. * Defines if tags hosted on an object match a given query
  79869. * @param obj defines the object to use
  79870. * @param tagsQuery defines the tag query
  79871. * @returns a boolean
  79872. */
  79873. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  79874. }
  79875. }
  79876. declare module BABYLON {
  79877. /**
  79878. * Scalar computation library
  79879. */
  79880. export class Scalar {
  79881. /**
  79882. * Two pi constants convenient for computation.
  79883. */
  79884. static TwoPi: number;
  79885. /**
  79886. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79887. * @param a number
  79888. * @param b number
  79889. * @param epsilon (default = 1.401298E-45)
  79890. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79891. */
  79892. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  79893. /**
  79894. * Returns a string : the upper case translation of the number i to hexadecimal.
  79895. * @param i number
  79896. * @returns the upper case translation of the number i to hexadecimal.
  79897. */
  79898. static ToHex(i: number): string;
  79899. /**
  79900. * Returns -1 if value is negative and +1 is value is positive.
  79901. * @param value the value
  79902. * @returns the value itself if it's equal to zero.
  79903. */
  79904. static Sign(value: number): number;
  79905. /**
  79906. * Returns the value itself if it's between min and max.
  79907. * Returns min if the value is lower than min.
  79908. * Returns max if the value is greater than max.
  79909. * @param value the value to clmap
  79910. * @param min the min value to clamp to (default: 0)
  79911. * @param max the max value to clamp to (default: 1)
  79912. * @returns the clamped value
  79913. */
  79914. static Clamp(value: number, min?: number, max?: number): number;
  79915. /**
  79916. * the log2 of value.
  79917. * @param value the value to compute log2 of
  79918. * @returns the log2 of value.
  79919. */
  79920. static Log2(value: number): number;
  79921. /**
  79922. * Loops the value, so that it is never larger than length and never smaller than 0.
  79923. *
  79924. * This is similar to the modulo operator but it works with floating point numbers.
  79925. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  79926. * With t = 5 and length = 2.5, the result would be 0.0.
  79927. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  79928. * @param value the value
  79929. * @param length the length
  79930. * @returns the looped value
  79931. */
  79932. static Repeat(value: number, length: number): number;
  79933. /**
  79934. * Normalize the value between 0.0 and 1.0 using min and max values
  79935. * @param value value to normalize
  79936. * @param min max to normalize between
  79937. * @param max min to normalize between
  79938. * @returns the normalized value
  79939. */
  79940. static Normalize(value: number, min: number, max: number): number;
  79941. /**
  79942. * Denormalize the value from 0.0 and 1.0 using min and max values
  79943. * @param normalized value to denormalize
  79944. * @param min max to denormalize between
  79945. * @param max min to denormalize between
  79946. * @returns the denormalized value
  79947. */
  79948. static Denormalize(normalized: number, min: number, max: number): number;
  79949. /**
  79950. * Calculates the shortest difference between two given angles given in degrees.
  79951. * @param current current angle in degrees
  79952. * @param target target angle in degrees
  79953. * @returns the delta
  79954. */
  79955. static DeltaAngle(current: number, target: number): number;
  79956. /**
  79957. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  79958. * @param tx value
  79959. * @param length length
  79960. * @returns The returned value will move back and forth between 0 and length
  79961. */
  79962. static PingPong(tx: number, length: number): number;
  79963. /**
  79964. * Interpolates between min and max with smoothing at the limits.
  79965. *
  79966. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  79967. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  79968. * @param from from
  79969. * @param to to
  79970. * @param tx value
  79971. * @returns the smooth stepped value
  79972. */
  79973. static SmoothStep(from: number, to: number, tx: number): number;
  79974. /**
  79975. * Moves a value current towards target.
  79976. *
  79977. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  79978. * Negative values of maxDelta pushes the value away from target.
  79979. * @param current current value
  79980. * @param target target value
  79981. * @param maxDelta max distance to move
  79982. * @returns resulting value
  79983. */
  79984. static MoveTowards(current: number, target: number, maxDelta: number): number;
  79985. /**
  79986. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79987. *
  79988. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  79989. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  79990. * @param current current value
  79991. * @param target target value
  79992. * @param maxDelta max distance to move
  79993. * @returns resulting angle
  79994. */
  79995. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  79996. /**
  79997. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  79998. * @param start start value
  79999. * @param end target value
  80000. * @param amount amount to lerp between
  80001. * @returns the lerped value
  80002. */
  80003. static Lerp(start: number, end: number, amount: number): number;
  80004. /**
  80005. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80006. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  80007. * @param start start value
  80008. * @param end target value
  80009. * @param amount amount to lerp between
  80010. * @returns the lerped value
  80011. */
  80012. static LerpAngle(start: number, end: number, amount: number): number;
  80013. /**
  80014. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80015. * @param a start value
  80016. * @param b target value
  80017. * @param value value between a and b
  80018. * @returns the inverseLerp value
  80019. */
  80020. static InverseLerp(a: number, b: number, value: number): number;
  80021. /**
  80022. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80023. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80024. * @param value1 spline value
  80025. * @param tangent1 spline value
  80026. * @param value2 spline value
  80027. * @param tangent2 spline value
  80028. * @param amount input value
  80029. * @returns hermite result
  80030. */
  80031. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80032. /**
  80033. * Returns a random float number between and min and max values
  80034. * @param min min value of random
  80035. * @param max max value of random
  80036. * @returns random value
  80037. */
  80038. static RandomRange(min: number, max: number): number;
  80039. /**
  80040. * This function returns percentage of a number in a given range.
  80041. *
  80042. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80043. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80044. * @param number to convert to percentage
  80045. * @param min min range
  80046. * @param max max range
  80047. * @returns the percentage
  80048. */
  80049. static RangeToPercent(number: number, min: number, max: number): number;
  80050. /**
  80051. * This function returns number that corresponds to the percentage in a given range.
  80052. *
  80053. * PercentToRange(0.34,0,100) will return 34.
  80054. * @param percent to convert to number
  80055. * @param min min range
  80056. * @param max max range
  80057. * @returns the number
  80058. */
  80059. static PercentToRange(percent: number, min: number, max: number): number;
  80060. /**
  80061. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80062. * @param angle The angle to normalize in radian.
  80063. * @return The converted angle.
  80064. */
  80065. static NormalizeRadians(angle: number): number;
  80066. }
  80067. }
  80068. declare module BABYLON {
  80069. /**
  80070. * Constant used to convert a value to gamma space
  80071. * @ignorenaming
  80072. */
  80073. export const ToGammaSpace: number;
  80074. /**
  80075. * Constant used to convert a value to linear space
  80076. * @ignorenaming
  80077. */
  80078. export const ToLinearSpace = 2.2;
  80079. /**
  80080. * Constant used to define the minimal number value in Babylon.js
  80081. * @ignorenaming
  80082. */
  80083. let Epsilon: number;
  80084. }
  80085. declare module BABYLON {
  80086. /**
  80087. * Class used to represent a viewport on screen
  80088. */
  80089. export class Viewport {
  80090. /** viewport left coordinate */
  80091. x: number;
  80092. /** viewport top coordinate */
  80093. y: number;
  80094. /**viewport width */
  80095. width: number;
  80096. /** viewport height */
  80097. height: number;
  80098. /**
  80099. * Creates a Viewport object located at (x, y) and sized (width, height)
  80100. * @param x defines viewport left coordinate
  80101. * @param y defines viewport top coordinate
  80102. * @param width defines the viewport width
  80103. * @param height defines the viewport height
  80104. */
  80105. constructor(
  80106. /** viewport left coordinate */
  80107. x: number,
  80108. /** viewport top coordinate */
  80109. y: number,
  80110. /**viewport width */
  80111. width: number,
  80112. /** viewport height */
  80113. height: number);
  80114. /**
  80115. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80116. * @param renderWidth defines the rendering width
  80117. * @param renderHeight defines the rendering height
  80118. * @returns a new Viewport
  80119. */
  80120. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80121. /**
  80122. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80123. * @param renderWidth defines the rendering width
  80124. * @param renderHeight defines the rendering height
  80125. * @param ref defines the target viewport
  80126. * @returns the current viewport
  80127. */
  80128. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80129. /**
  80130. * Returns a new Viewport copied from the current one
  80131. * @returns a new Viewport
  80132. */
  80133. clone(): Viewport;
  80134. }
  80135. }
  80136. declare module BABYLON {
  80137. /**
  80138. * Class containing a set of static utilities functions for arrays.
  80139. */
  80140. export class ArrayTools {
  80141. /**
  80142. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80143. * @param size the number of element to construct and put in the array
  80144. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80145. * @returns a new array filled with new objects
  80146. */
  80147. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80148. }
  80149. }
  80150. declare module BABYLON {
  80151. /**
  80152. * Represents a plane by the equation ax + by + cz + d = 0
  80153. */
  80154. export class Plane {
  80155. private static _TmpMatrix;
  80156. /**
  80157. * Normal of the plane (a,b,c)
  80158. */
  80159. normal: Vector3;
  80160. /**
  80161. * d component of the plane
  80162. */
  80163. d: number;
  80164. /**
  80165. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80166. * @param a a component of the plane
  80167. * @param b b component of the plane
  80168. * @param c c component of the plane
  80169. * @param d d component of the plane
  80170. */
  80171. constructor(a: number, b: number, c: number, d: number);
  80172. /**
  80173. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80174. */
  80175. asArray(): number[];
  80176. /**
  80177. * @returns a new plane copied from the current Plane.
  80178. */
  80179. clone(): Plane;
  80180. /**
  80181. * @returns the string "Plane".
  80182. */
  80183. getClassName(): string;
  80184. /**
  80185. * @returns the Plane hash code.
  80186. */
  80187. getHashCode(): number;
  80188. /**
  80189. * Normalize the current Plane in place.
  80190. * @returns the updated Plane.
  80191. */
  80192. normalize(): Plane;
  80193. /**
  80194. * Applies a transformation the plane and returns the result
  80195. * @param transformation the transformation matrix to be applied to the plane
  80196. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80197. */
  80198. transform(transformation: DeepImmutable<Matrix>): Plane;
  80199. /**
  80200. * Compute the dot product between the point and the plane normal
  80201. * @param point point to calculate the dot product with
  80202. * @returns the dot product (float) of the point coordinates and the plane normal.
  80203. */
  80204. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80205. /**
  80206. * Updates the current Plane from the plane defined by the three given points.
  80207. * @param point1 one of the points used to contruct the plane
  80208. * @param point2 one of the points used to contruct the plane
  80209. * @param point3 one of the points used to contruct the plane
  80210. * @returns the updated Plane.
  80211. */
  80212. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80213. /**
  80214. * Checks if the plane is facing a given direction
  80215. * @param direction the direction to check if the plane is facing
  80216. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80217. * @returns True is the vector "direction" is the same side than the plane normal.
  80218. */
  80219. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80220. /**
  80221. * Calculates the distance to a point
  80222. * @param point point to calculate distance to
  80223. * @returns the signed distance (float) from the given point to the Plane.
  80224. */
  80225. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80226. /**
  80227. * Creates a plane from an array
  80228. * @param array the array to create a plane from
  80229. * @returns a new Plane from the given array.
  80230. */
  80231. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80232. /**
  80233. * Creates a plane from three points
  80234. * @param point1 point used to create the plane
  80235. * @param point2 point used to create the plane
  80236. * @param point3 point used to create the plane
  80237. * @returns a new Plane defined by the three given points.
  80238. */
  80239. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80240. /**
  80241. * Creates a plane from an origin point and a normal
  80242. * @param origin origin of the plane to be constructed
  80243. * @param normal normal of the plane to be constructed
  80244. * @returns a new Plane the normal vector to this plane at the given origin point.
  80245. * Note : the vector "normal" is updated because normalized.
  80246. */
  80247. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  80248. /**
  80249. * Calculates the distance from a plane and a point
  80250. * @param origin origin of the plane to be constructed
  80251. * @param normal normal of the plane to be constructed
  80252. * @param point point to calculate distance to
  80253. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80254. */
  80255. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80256. }
  80257. }
  80258. declare module BABYLON {
  80259. /**
  80260. * Class representing a vector containing 2 coordinates
  80261. */
  80262. export class Vector2 {
  80263. /** defines the first coordinate */
  80264. x: number;
  80265. /** defines the second coordinate */
  80266. y: number;
  80267. /**
  80268. * Creates a new Vector2 from the given x and y coordinates
  80269. * @param x defines the first coordinate
  80270. * @param y defines the second coordinate
  80271. */
  80272. constructor(
  80273. /** defines the first coordinate */
  80274. x?: number,
  80275. /** defines the second coordinate */
  80276. y?: number);
  80277. /**
  80278. * Gets a string with the Vector2 coordinates
  80279. * @returns a string with the Vector2 coordinates
  80280. */
  80281. toString(): string;
  80282. /**
  80283. * Gets class name
  80284. * @returns the string "Vector2"
  80285. */
  80286. getClassName(): string;
  80287. /**
  80288. * Gets current vector hash code
  80289. * @returns the Vector2 hash code as a number
  80290. */
  80291. getHashCode(): number;
  80292. /**
  80293. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  80294. * @param array defines the source array
  80295. * @param index defines the offset in source array
  80296. * @returns the current Vector2
  80297. */
  80298. toArray(array: FloatArray, index?: number): Vector2;
  80299. /**
  80300. * Copy the current vector to an array
  80301. * @returns a new array with 2 elements: the Vector2 coordinates.
  80302. */
  80303. asArray(): number[];
  80304. /**
  80305. * Sets the Vector2 coordinates with the given Vector2 coordinates
  80306. * @param source defines the source Vector2
  80307. * @returns the current updated Vector2
  80308. */
  80309. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  80310. /**
  80311. * Sets the Vector2 coordinates with the given floats
  80312. * @param x defines the first coordinate
  80313. * @param y defines the second coordinate
  80314. * @returns the current updated Vector2
  80315. */
  80316. copyFromFloats(x: number, y: number): Vector2;
  80317. /**
  80318. * Sets the Vector2 coordinates with the given floats
  80319. * @param x defines the first coordinate
  80320. * @param y defines the second coordinate
  80321. * @returns the current updated Vector2
  80322. */
  80323. set(x: number, y: number): Vector2;
  80324. /**
  80325. * Add another vector with the current one
  80326. * @param otherVector defines the other vector
  80327. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  80328. */
  80329. add(otherVector: DeepImmutable<Vector2>): Vector2;
  80330. /**
  80331. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  80332. * @param otherVector defines the other vector
  80333. * @param result defines the target vector
  80334. * @returns the unmodified current Vector2
  80335. */
  80336. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80337. /**
  80338. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  80339. * @param otherVector defines the other vector
  80340. * @returns the current updated Vector2
  80341. */
  80342. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80343. /**
  80344. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  80345. * @param otherVector defines the other vector
  80346. * @returns a new Vector2
  80347. */
  80348. addVector3(otherVector: Vector3): Vector2;
  80349. /**
  80350. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  80351. * @param otherVector defines the other vector
  80352. * @returns a new Vector2
  80353. */
  80354. subtract(otherVector: Vector2): Vector2;
  80355. /**
  80356. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  80357. * @param otherVector defines the other vector
  80358. * @param result defines the target vector
  80359. * @returns the unmodified current Vector2
  80360. */
  80361. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80362. /**
  80363. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  80364. * @param otherVector defines the other vector
  80365. * @returns the current updated Vector2
  80366. */
  80367. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80368. /**
  80369. * Multiplies in place the current Vector2 coordinates by the given ones
  80370. * @param otherVector defines the other vector
  80371. * @returns the current updated Vector2
  80372. */
  80373. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80374. /**
  80375. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  80376. * @param otherVector defines the other vector
  80377. * @returns a new Vector2
  80378. */
  80379. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  80380. /**
  80381. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  80382. * @param otherVector defines the other vector
  80383. * @param result defines the target vector
  80384. * @returns the unmodified current Vector2
  80385. */
  80386. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80387. /**
  80388. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  80389. * @param x defines the first coordinate
  80390. * @param y defines the second coordinate
  80391. * @returns a new Vector2
  80392. */
  80393. multiplyByFloats(x: number, y: number): Vector2;
  80394. /**
  80395. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  80396. * @param otherVector defines the other vector
  80397. * @returns a new Vector2
  80398. */
  80399. divide(otherVector: Vector2): Vector2;
  80400. /**
  80401. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  80402. * @param otherVector defines the other vector
  80403. * @param result defines the target vector
  80404. * @returns the unmodified current Vector2
  80405. */
  80406. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80407. /**
  80408. * Divides the current Vector2 coordinates by the given ones
  80409. * @param otherVector defines the other vector
  80410. * @returns the current updated Vector2
  80411. */
  80412. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80413. /**
  80414. * Gets a new Vector2 with current Vector2 negated coordinates
  80415. * @returns a new Vector2
  80416. */
  80417. negate(): Vector2;
  80418. /**
  80419. * Negate this vector in place
  80420. * @returns this
  80421. */
  80422. negateInPlace(): Vector2;
  80423. /**
  80424. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  80425. * @param result defines the Vector3 object where to store the result
  80426. * @returns the current Vector2
  80427. */
  80428. negateToRef(result: Vector2): Vector2;
  80429. /**
  80430. * Multiply the Vector2 coordinates by scale
  80431. * @param scale defines the scaling factor
  80432. * @returns the current updated Vector2
  80433. */
  80434. scaleInPlace(scale: number): Vector2;
  80435. /**
  80436. * Returns a new Vector2 scaled by "scale" from the current Vector2
  80437. * @param scale defines the scaling factor
  80438. * @returns a new Vector2
  80439. */
  80440. scale(scale: number): Vector2;
  80441. /**
  80442. * Scale the current Vector2 values by a factor to a given Vector2
  80443. * @param scale defines the scale factor
  80444. * @param result defines the Vector2 object where to store the result
  80445. * @returns the unmodified current Vector2
  80446. */
  80447. scaleToRef(scale: number, result: Vector2): Vector2;
  80448. /**
  80449. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  80450. * @param scale defines the scale factor
  80451. * @param result defines the Vector2 object where to store the result
  80452. * @returns the unmodified current Vector2
  80453. */
  80454. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  80455. /**
  80456. * Gets a boolean if two vectors are equals
  80457. * @param otherVector defines the other vector
  80458. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  80459. */
  80460. equals(otherVector: DeepImmutable<Vector2>): boolean;
  80461. /**
  80462. * Gets a boolean if two vectors are equals (using an epsilon value)
  80463. * @param otherVector defines the other vector
  80464. * @param epsilon defines the minimal distance to consider equality
  80465. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  80466. */
  80467. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  80468. /**
  80469. * Gets a new Vector2 from current Vector2 floored values
  80470. * @returns a new Vector2
  80471. */
  80472. floor(): Vector2;
  80473. /**
  80474. * Gets a new Vector2 from current Vector2 floored values
  80475. * @returns a new Vector2
  80476. */
  80477. fract(): Vector2;
  80478. /**
  80479. * Gets the length of the vector
  80480. * @returns the vector length (float)
  80481. */
  80482. length(): number;
  80483. /**
  80484. * Gets the vector squared length
  80485. * @returns the vector squared length (float)
  80486. */
  80487. lengthSquared(): number;
  80488. /**
  80489. * Normalize the vector
  80490. * @returns the current updated Vector2
  80491. */
  80492. normalize(): Vector2;
  80493. /**
  80494. * Gets a new Vector2 copied from the Vector2
  80495. * @returns a new Vector2
  80496. */
  80497. clone(): Vector2;
  80498. /**
  80499. * Gets a new Vector2(0, 0)
  80500. * @returns a new Vector2
  80501. */
  80502. static Zero(): Vector2;
  80503. /**
  80504. * Gets a new Vector2(1, 1)
  80505. * @returns a new Vector2
  80506. */
  80507. static One(): Vector2;
  80508. /**
  80509. * Gets a new Vector2 set from the given index element of the given array
  80510. * @param array defines the data source
  80511. * @param offset defines the offset in the data source
  80512. * @returns a new Vector2
  80513. */
  80514. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  80515. /**
  80516. * Sets "result" from the given index element of the given array
  80517. * @param array defines the data source
  80518. * @param offset defines the offset in the data source
  80519. * @param result defines the target vector
  80520. */
  80521. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  80522. /**
  80523. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  80524. * @param value1 defines 1st point of control
  80525. * @param value2 defines 2nd point of control
  80526. * @param value3 defines 3rd point of control
  80527. * @param value4 defines 4th point of control
  80528. * @param amount defines the interpolation factor
  80529. * @returns a new Vector2
  80530. */
  80531. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  80532. /**
  80533. * 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".
  80534. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  80535. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  80536. * @param value defines the value to clamp
  80537. * @param min defines the lower limit
  80538. * @param max defines the upper limit
  80539. * @returns a new Vector2
  80540. */
  80541. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  80542. /**
  80543. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  80544. * @param value1 defines the 1st control point
  80545. * @param tangent1 defines the outgoing tangent
  80546. * @param value2 defines the 2nd control point
  80547. * @param tangent2 defines the incoming tangent
  80548. * @param amount defines the interpolation factor
  80549. * @returns a new Vector2
  80550. */
  80551. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  80552. /**
  80553. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  80554. * @param start defines the start vector
  80555. * @param end defines the end vector
  80556. * @param amount defines the interpolation factor
  80557. * @returns a new Vector2
  80558. */
  80559. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  80560. /**
  80561. * Gets the dot product of the vector "left" and the vector "right"
  80562. * @param left defines first vector
  80563. * @param right defines second vector
  80564. * @returns the dot product (float)
  80565. */
  80566. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  80567. /**
  80568. * Returns a new Vector2 equal to the normalized given vector
  80569. * @param vector defines the vector to normalize
  80570. * @returns a new Vector2
  80571. */
  80572. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  80573. /**
  80574. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  80575. * @param left defines 1st vector
  80576. * @param right defines 2nd vector
  80577. * @returns a new Vector2
  80578. */
  80579. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80580. /**
  80581. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  80582. * @param left defines 1st vector
  80583. * @param right defines 2nd vector
  80584. * @returns a new Vector2
  80585. */
  80586. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80587. /**
  80588. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  80589. * @param vector defines the vector to transform
  80590. * @param transformation defines the matrix to apply
  80591. * @returns a new Vector2
  80592. */
  80593. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  80594. /**
  80595. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  80596. * @param vector defines the vector to transform
  80597. * @param transformation defines the matrix to apply
  80598. * @param result defines the target vector
  80599. */
  80600. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  80601. /**
  80602. * Determines if a given vector is included in a triangle
  80603. * @param p defines the vector to test
  80604. * @param p0 defines 1st triangle point
  80605. * @param p1 defines 2nd triangle point
  80606. * @param p2 defines 3rd triangle point
  80607. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  80608. */
  80609. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  80610. /**
  80611. * Gets the distance between the vectors "value1" and "value2"
  80612. * @param value1 defines first vector
  80613. * @param value2 defines second vector
  80614. * @returns the distance between vectors
  80615. */
  80616. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80617. /**
  80618. * Returns the squared distance between the vectors "value1" and "value2"
  80619. * @param value1 defines first vector
  80620. * @param value2 defines second vector
  80621. * @returns the squared distance between vectors
  80622. */
  80623. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80624. /**
  80625. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  80626. * @param value1 defines first vector
  80627. * @param value2 defines second vector
  80628. * @returns a new Vector2
  80629. */
  80630. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  80631. /**
  80632. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  80633. * @param p defines the middle point
  80634. * @param segA defines one point of the segment
  80635. * @param segB defines the other point of the segment
  80636. * @returns the shortest distance
  80637. */
  80638. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  80639. }
  80640. /**
  80641. * Class used to store (x,y,z) vector representation
  80642. * A Vector3 is the main object used in 3D geometry
  80643. * It can represent etiher the coordinates of a point the space, either a direction
  80644. * Reminder: js uses a left handed forward facing system
  80645. */
  80646. export class Vector3 {
  80647. private static _UpReadOnly;
  80648. private static _ZeroReadOnly;
  80649. /** @hidden */
  80650. _x: number;
  80651. /** @hidden */
  80652. _y: number;
  80653. /** @hidden */
  80654. _z: number;
  80655. /** @hidden */
  80656. _isDirty: boolean;
  80657. /** Gets or sets the x coordinate */
  80658. get x(): number;
  80659. set x(value: number);
  80660. /** Gets or sets the y coordinate */
  80661. get y(): number;
  80662. set y(value: number);
  80663. /** Gets or sets the z coordinate */
  80664. get z(): number;
  80665. set z(value: number);
  80666. /**
  80667. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  80668. * @param x defines the first coordinates (on X axis)
  80669. * @param y defines the second coordinates (on Y axis)
  80670. * @param z defines the third coordinates (on Z axis)
  80671. */
  80672. constructor(x?: number, y?: number, z?: number);
  80673. /**
  80674. * Creates a string representation of the Vector3
  80675. * @returns a string with the Vector3 coordinates.
  80676. */
  80677. toString(): string;
  80678. /**
  80679. * Gets the class name
  80680. * @returns the string "Vector3"
  80681. */
  80682. getClassName(): string;
  80683. /**
  80684. * Creates the Vector3 hash code
  80685. * @returns a number which tends to be unique between Vector3 instances
  80686. */
  80687. getHashCode(): number;
  80688. /**
  80689. * Creates an array containing three elements : the coordinates of the Vector3
  80690. * @returns a new array of numbers
  80691. */
  80692. asArray(): number[];
  80693. /**
  80694. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  80695. * @param array defines the destination array
  80696. * @param index defines the offset in the destination array
  80697. * @returns the current Vector3
  80698. */
  80699. toArray(array: FloatArray, index?: number): Vector3;
  80700. /**
  80701. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  80702. * @returns a new Quaternion object, computed from the Vector3 coordinates
  80703. */
  80704. toQuaternion(): Quaternion;
  80705. /**
  80706. * Adds the given vector to the current Vector3
  80707. * @param otherVector defines the second operand
  80708. * @returns the current updated Vector3
  80709. */
  80710. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80711. /**
  80712. * Adds the given coordinates to the current Vector3
  80713. * @param x defines the x coordinate of the operand
  80714. * @param y defines the y coordinate of the operand
  80715. * @param z defines the z coordinate of the operand
  80716. * @returns the current updated Vector3
  80717. */
  80718. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80719. /**
  80720. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  80721. * @param otherVector defines the second operand
  80722. * @returns the resulting Vector3
  80723. */
  80724. add(otherVector: DeepImmutable<Vector3>): Vector3;
  80725. /**
  80726. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  80727. * @param otherVector defines the second operand
  80728. * @param result defines the Vector3 object where to store the result
  80729. * @returns the current Vector3
  80730. */
  80731. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80732. /**
  80733. * Subtract the given vector from the current Vector3
  80734. * @param otherVector defines the second operand
  80735. * @returns the current updated Vector3
  80736. */
  80737. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80738. /**
  80739. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  80740. * @param otherVector defines the second operand
  80741. * @returns the resulting Vector3
  80742. */
  80743. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  80744. /**
  80745. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  80746. * @param otherVector defines the second operand
  80747. * @param result defines the Vector3 object where to store the result
  80748. * @returns the current Vector3
  80749. */
  80750. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80751. /**
  80752. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  80753. * @param x defines the x coordinate of the operand
  80754. * @param y defines the y coordinate of the operand
  80755. * @param z defines the z coordinate of the operand
  80756. * @returns the resulting Vector3
  80757. */
  80758. subtractFromFloats(x: number, y: number, z: number): Vector3;
  80759. /**
  80760. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  80761. * @param x defines the x coordinate of the operand
  80762. * @param y defines the y coordinate of the operand
  80763. * @param z defines the z coordinate of the operand
  80764. * @param result defines the Vector3 object where to store the result
  80765. * @returns the current Vector3
  80766. */
  80767. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  80768. /**
  80769. * Gets a new Vector3 set with the current Vector3 negated coordinates
  80770. * @returns a new Vector3
  80771. */
  80772. negate(): Vector3;
  80773. /**
  80774. * Negate this vector in place
  80775. * @returns this
  80776. */
  80777. negateInPlace(): Vector3;
  80778. /**
  80779. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  80780. * @param result defines the Vector3 object where to store the result
  80781. * @returns the current Vector3
  80782. */
  80783. negateToRef(result: Vector3): Vector3;
  80784. /**
  80785. * Multiplies the Vector3 coordinates by the float "scale"
  80786. * @param scale defines the multiplier factor
  80787. * @returns the current updated Vector3
  80788. */
  80789. scaleInPlace(scale: number): Vector3;
  80790. /**
  80791. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  80792. * @param scale defines the multiplier factor
  80793. * @returns a new Vector3
  80794. */
  80795. scale(scale: number): Vector3;
  80796. /**
  80797. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  80798. * @param scale defines the multiplier factor
  80799. * @param result defines the Vector3 object where to store the result
  80800. * @returns the current Vector3
  80801. */
  80802. scaleToRef(scale: number, result: Vector3): Vector3;
  80803. /**
  80804. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  80805. * @param scale defines the scale factor
  80806. * @param result defines the Vector3 object where to store the result
  80807. * @returns the unmodified current Vector3
  80808. */
  80809. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  80810. /**
  80811. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80812. * @param origin defines the origin of the projection ray
  80813. * @param plane defines the plane to project to
  80814. * @returns the projected vector3
  80815. */
  80816. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  80817. /**
  80818. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80819. * @param origin defines the origin of the projection ray
  80820. * @param plane defines the plane to project to
  80821. * @param result defines the Vector3 where to store the result
  80822. */
  80823. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  80824. /**
  80825. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  80826. * @param otherVector defines the second operand
  80827. * @returns true if both vectors are equals
  80828. */
  80829. equals(otherVector: DeepImmutable<Vector3>): boolean;
  80830. /**
  80831. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  80832. * @param otherVector defines the second operand
  80833. * @param epsilon defines the minimal distance to define values as equals
  80834. * @returns true if both vectors are distant less than epsilon
  80835. */
  80836. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  80837. /**
  80838. * Returns true if the current Vector3 coordinates equals the given floats
  80839. * @param x defines the x coordinate of the operand
  80840. * @param y defines the y coordinate of the operand
  80841. * @param z defines the z coordinate of the operand
  80842. * @returns true if both vectors are equals
  80843. */
  80844. equalsToFloats(x: number, y: number, z: number): boolean;
  80845. /**
  80846. * Multiplies the current Vector3 coordinates by the given ones
  80847. * @param otherVector defines the second operand
  80848. * @returns the current updated Vector3
  80849. */
  80850. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80851. /**
  80852. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  80853. * @param otherVector defines the second operand
  80854. * @returns the new Vector3
  80855. */
  80856. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  80857. /**
  80858. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  80859. * @param otherVector defines the second operand
  80860. * @param result defines the Vector3 object where to store the result
  80861. * @returns the current Vector3
  80862. */
  80863. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80864. /**
  80865. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  80866. * @param x defines the x coordinate of the operand
  80867. * @param y defines the y coordinate of the operand
  80868. * @param z defines the z coordinate of the operand
  80869. * @returns the new Vector3
  80870. */
  80871. multiplyByFloats(x: number, y: number, z: number): Vector3;
  80872. /**
  80873. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  80874. * @param otherVector defines the second operand
  80875. * @returns the new Vector3
  80876. */
  80877. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  80878. /**
  80879. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  80880. * @param otherVector defines the second operand
  80881. * @param result defines the Vector3 object where to store the result
  80882. * @returns the current Vector3
  80883. */
  80884. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80885. /**
  80886. * Divides the current Vector3 coordinates by the given ones.
  80887. * @param otherVector defines the second operand
  80888. * @returns the current updated Vector3
  80889. */
  80890. divideInPlace(otherVector: Vector3): Vector3;
  80891. /**
  80892. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  80893. * @param other defines the second operand
  80894. * @returns the current updated Vector3
  80895. */
  80896. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80897. /**
  80898. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  80899. * @param other defines the second operand
  80900. * @returns the current updated Vector3
  80901. */
  80902. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80903. /**
  80904. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  80905. * @param x defines the x coordinate of the operand
  80906. * @param y defines the y coordinate of the operand
  80907. * @param z defines the z coordinate of the operand
  80908. * @returns the current updated Vector3
  80909. */
  80910. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80911. /**
  80912. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  80913. * @param x defines the x coordinate of the operand
  80914. * @param y defines the y coordinate of the operand
  80915. * @param z defines the z coordinate of the operand
  80916. * @returns the current updated Vector3
  80917. */
  80918. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80919. /**
  80920. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  80921. * Check if is non uniform within a certain amount of decimal places to account for this
  80922. * @param epsilon the amount the values can differ
  80923. * @returns if the the vector is non uniform to a certain number of decimal places
  80924. */
  80925. isNonUniformWithinEpsilon(epsilon: number): boolean;
  80926. /**
  80927. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  80928. */
  80929. get isNonUniform(): boolean;
  80930. /**
  80931. * Gets a new Vector3 from current Vector3 floored values
  80932. * @returns a new Vector3
  80933. */
  80934. floor(): Vector3;
  80935. /**
  80936. * Gets a new Vector3 from current Vector3 floored values
  80937. * @returns a new Vector3
  80938. */
  80939. fract(): Vector3;
  80940. /**
  80941. * Gets the length of the Vector3
  80942. * @returns the length of the Vector3
  80943. */
  80944. length(): number;
  80945. /**
  80946. * Gets the squared length of the Vector3
  80947. * @returns squared length of the Vector3
  80948. */
  80949. lengthSquared(): number;
  80950. /**
  80951. * Normalize the current Vector3.
  80952. * Please note that this is an in place operation.
  80953. * @returns the current updated Vector3
  80954. */
  80955. normalize(): Vector3;
  80956. /**
  80957. * Reorders the x y z properties of the vector in place
  80958. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  80959. * @returns the current updated vector
  80960. */
  80961. reorderInPlace(order: string): this;
  80962. /**
  80963. * Rotates the vector around 0,0,0 by a quaternion
  80964. * @param quaternion the rotation quaternion
  80965. * @param result vector to store the result
  80966. * @returns the resulting vector
  80967. */
  80968. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  80969. /**
  80970. * Rotates a vector around a given point
  80971. * @param quaternion the rotation quaternion
  80972. * @param point the point to rotate around
  80973. * @param result vector to store the result
  80974. * @returns the resulting vector
  80975. */
  80976. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  80977. /**
  80978. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  80979. * The cross product is then orthogonal to both current and "other"
  80980. * @param other defines the right operand
  80981. * @returns the cross product
  80982. */
  80983. cross(other: Vector3): Vector3;
  80984. /**
  80985. * Normalize the current Vector3 with the given input length.
  80986. * Please note that this is an in place operation.
  80987. * @param len the length of the vector
  80988. * @returns the current updated Vector3
  80989. */
  80990. normalizeFromLength(len: number): Vector3;
  80991. /**
  80992. * Normalize the current Vector3 to a new vector
  80993. * @returns the new Vector3
  80994. */
  80995. normalizeToNew(): Vector3;
  80996. /**
  80997. * Normalize the current Vector3 to the reference
  80998. * @param reference define the Vector3 to update
  80999. * @returns the updated Vector3
  81000. */
  81001. normalizeToRef(reference: Vector3): Vector3;
  81002. /**
  81003. * Creates a new Vector3 copied from the current Vector3
  81004. * @returns the new Vector3
  81005. */
  81006. clone(): Vector3;
  81007. /**
  81008. * Copies the given vector coordinates to the current Vector3 ones
  81009. * @param source defines the source Vector3
  81010. * @returns the current updated Vector3
  81011. */
  81012. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81013. /**
  81014. * Copies the given floats to the current Vector3 coordinates
  81015. * @param x defines the x coordinate of the operand
  81016. * @param y defines the y coordinate of the operand
  81017. * @param z defines the z coordinate of the operand
  81018. * @returns the current updated Vector3
  81019. */
  81020. copyFromFloats(x: number, y: number, z: number): Vector3;
  81021. /**
  81022. * Copies the given floats to the current Vector3 coordinates
  81023. * @param x defines the x coordinate of the operand
  81024. * @param y defines the y coordinate of the operand
  81025. * @param z defines the z coordinate of the operand
  81026. * @returns the current updated Vector3
  81027. */
  81028. set(x: number, y: number, z: number): Vector3;
  81029. /**
  81030. * Copies the given float to the current Vector3 coordinates
  81031. * @param v defines the x, y and z coordinates of the operand
  81032. * @returns the current updated Vector3
  81033. */
  81034. setAll(v: number): Vector3;
  81035. /**
  81036. * Get the clip factor between two vectors
  81037. * @param vector0 defines the first operand
  81038. * @param vector1 defines the second operand
  81039. * @param axis defines the axis to use
  81040. * @param size defines the size along the axis
  81041. * @returns the clip factor
  81042. */
  81043. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81044. /**
  81045. * Get angle between two vectors
  81046. * @param vector0 angle between vector0 and vector1
  81047. * @param vector1 angle between vector0 and vector1
  81048. * @param normal direction of the normal
  81049. * @return the angle between vector0 and vector1
  81050. */
  81051. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81052. /**
  81053. * Returns a new Vector3 set from the index "offset" of the given array
  81054. * @param array defines the source array
  81055. * @param offset defines the offset in the source array
  81056. * @returns the new Vector3
  81057. */
  81058. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81059. /**
  81060. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81061. * @param array defines the source array
  81062. * @param offset defines the offset in the source array
  81063. * @returns the new Vector3
  81064. * @deprecated Please use FromArray instead.
  81065. */
  81066. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81067. /**
  81068. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81069. * @param array defines the source array
  81070. * @param offset defines the offset in the source array
  81071. * @param result defines the Vector3 where to store the result
  81072. */
  81073. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81074. /**
  81075. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81076. * @param array defines the source array
  81077. * @param offset defines the offset in the source array
  81078. * @param result defines the Vector3 where to store the result
  81079. * @deprecated Please use FromArrayToRef instead.
  81080. */
  81081. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81082. /**
  81083. * Sets the given vector "result" with the given floats.
  81084. * @param x defines the x coordinate of the source
  81085. * @param y defines the y coordinate of the source
  81086. * @param z defines the z coordinate of the source
  81087. * @param result defines the Vector3 where to store the result
  81088. */
  81089. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81090. /**
  81091. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81092. * @returns a new empty Vector3
  81093. */
  81094. static Zero(): Vector3;
  81095. /**
  81096. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81097. * @returns a new unit Vector3
  81098. */
  81099. static One(): Vector3;
  81100. /**
  81101. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81102. * @returns a new up Vector3
  81103. */
  81104. static Up(): Vector3;
  81105. /**
  81106. * Gets a up Vector3 that must not be updated
  81107. */
  81108. static get UpReadOnly(): DeepImmutable<Vector3>;
  81109. /**
  81110. * Gets a zero Vector3 that must not be updated
  81111. */
  81112. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81113. /**
  81114. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81115. * @returns a new down Vector3
  81116. */
  81117. static Down(): Vector3;
  81118. /**
  81119. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81120. * @param rightHandedSystem is the scene right-handed (negative z)
  81121. * @returns a new forward Vector3
  81122. */
  81123. static Forward(rightHandedSystem?: boolean): Vector3;
  81124. /**
  81125. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81126. * @param rightHandedSystem is the scene right-handed (negative-z)
  81127. * @returns a new forward Vector3
  81128. */
  81129. static Backward(rightHandedSystem?: boolean): Vector3;
  81130. /**
  81131. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81132. * @returns a new right Vector3
  81133. */
  81134. static Right(): Vector3;
  81135. /**
  81136. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81137. * @returns a new left Vector3
  81138. */
  81139. static Left(): Vector3;
  81140. /**
  81141. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  81142. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81143. * @param vector defines the Vector3 to transform
  81144. * @param transformation defines the transformation matrix
  81145. * @returns the transformed Vector3
  81146. */
  81147. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81148. /**
  81149. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  81150. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81151. * @param vector defines the Vector3 to transform
  81152. * @param transformation defines the transformation matrix
  81153. * @param result defines the Vector3 where to store the result
  81154. */
  81155. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81156. /**
  81157. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  81158. * This method computes tranformed coordinates only, not transformed direction vectors
  81159. * @param x define the x coordinate of the source vector
  81160. * @param y define the y coordinate of the source vector
  81161. * @param z define the z coordinate of the source vector
  81162. * @param transformation defines the transformation matrix
  81163. * @param result defines the Vector3 where to store the result
  81164. */
  81165. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81166. /**
  81167. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  81168. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81169. * @param vector defines the Vector3 to transform
  81170. * @param transformation defines the transformation matrix
  81171. * @returns the new Vector3
  81172. */
  81173. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81174. /**
  81175. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  81176. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81177. * @param vector defines the Vector3 to transform
  81178. * @param transformation defines the transformation matrix
  81179. * @param result defines the Vector3 where to store the result
  81180. */
  81181. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81182. /**
  81183. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  81184. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81185. * @param x define the x coordinate of the source vector
  81186. * @param y define the y coordinate of the source vector
  81187. * @param z define the z coordinate of the source vector
  81188. * @param transformation defines the transformation matrix
  81189. * @param result defines the Vector3 where to store the result
  81190. */
  81191. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81192. /**
  81193. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  81194. * @param value1 defines the first control point
  81195. * @param value2 defines the second control point
  81196. * @param value3 defines the third control point
  81197. * @param value4 defines the fourth control point
  81198. * @param amount defines the amount on the spline to use
  81199. * @returns the new Vector3
  81200. */
  81201. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  81202. /**
  81203. * 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"
  81204. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81205. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81206. * @param value defines the current value
  81207. * @param min defines the lower range value
  81208. * @param max defines the upper range value
  81209. * @returns the new Vector3
  81210. */
  81211. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  81212. /**
  81213. * 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"
  81214. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81215. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81216. * @param value defines the current value
  81217. * @param min defines the lower range value
  81218. * @param max defines the upper range value
  81219. * @param result defines the Vector3 where to store the result
  81220. */
  81221. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  81222. /**
  81223. * Checks if a given vector is inside a specific range
  81224. * @param v defines the vector to test
  81225. * @param min defines the minimum range
  81226. * @param max defines the maximum range
  81227. */
  81228. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  81229. /**
  81230. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  81231. * @param value1 defines the first control point
  81232. * @param tangent1 defines the first tangent vector
  81233. * @param value2 defines the second control point
  81234. * @param tangent2 defines the second tangent vector
  81235. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  81236. * @returns the new Vector3
  81237. */
  81238. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  81239. /**
  81240. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  81241. * @param start defines the start value
  81242. * @param end defines the end value
  81243. * @param amount max defines amount between both (between 0 and 1)
  81244. * @returns the new Vector3
  81245. */
  81246. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  81247. /**
  81248. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  81249. * @param start defines the start value
  81250. * @param end defines the end value
  81251. * @param amount max defines amount between both (between 0 and 1)
  81252. * @param result defines the Vector3 where to store the result
  81253. */
  81254. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  81255. /**
  81256. * Returns the dot product (float) between the vectors "left" and "right"
  81257. * @param left defines the left operand
  81258. * @param right defines the right operand
  81259. * @returns the dot product
  81260. */
  81261. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  81262. /**
  81263. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  81264. * The cross product is then orthogonal to both "left" and "right"
  81265. * @param left defines the left operand
  81266. * @param right defines the right operand
  81267. * @returns the cross product
  81268. */
  81269. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81270. /**
  81271. * Sets the given vector "result" with the cross product of "left" and "right"
  81272. * The cross product is then orthogonal to both "left" and "right"
  81273. * @param left defines the left operand
  81274. * @param right defines the right operand
  81275. * @param result defines the Vector3 where to store the result
  81276. */
  81277. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  81278. /**
  81279. * Returns a new Vector3 as the normalization of the given vector
  81280. * @param vector defines the Vector3 to normalize
  81281. * @returns the new Vector3
  81282. */
  81283. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  81284. /**
  81285. * Sets the given vector "result" with the normalization of the given first vector
  81286. * @param vector defines the Vector3 to normalize
  81287. * @param result defines the Vector3 where to store the result
  81288. */
  81289. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  81290. /**
  81291. * Project a Vector3 onto screen space
  81292. * @param vector defines the Vector3 to project
  81293. * @param world defines the world matrix to use
  81294. * @param transform defines the transform (view x projection) matrix to use
  81295. * @param viewport defines the screen viewport to use
  81296. * @returns the new Vector3
  81297. */
  81298. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  81299. /** @hidden */
  81300. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  81301. /**
  81302. * Unproject from screen space to object space
  81303. * @param source defines the screen space Vector3 to use
  81304. * @param viewportWidth defines the current width of the viewport
  81305. * @param viewportHeight defines the current height of the viewport
  81306. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81307. * @param transform defines the transform (view x projection) matrix to use
  81308. * @returns the new Vector3
  81309. */
  81310. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  81311. /**
  81312. * Unproject from screen space to object space
  81313. * @param source defines the screen space Vector3 to use
  81314. * @param viewportWidth defines the current width of the viewport
  81315. * @param viewportHeight defines the current height of the viewport
  81316. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81317. * @param view defines the view matrix to use
  81318. * @param projection defines the projection matrix to use
  81319. * @returns the new Vector3
  81320. */
  81321. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  81322. /**
  81323. * Unproject from screen space to object space
  81324. * @param source defines the screen space Vector3 to use
  81325. * @param viewportWidth defines the current width of the viewport
  81326. * @param viewportHeight defines the current height of the viewport
  81327. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81328. * @param view defines the view matrix to use
  81329. * @param projection defines the projection matrix to use
  81330. * @param result defines the Vector3 where to store the result
  81331. */
  81332. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81333. /**
  81334. * Unproject from screen space to object space
  81335. * @param sourceX defines the screen space x coordinate to use
  81336. * @param sourceY defines the screen space y coordinate to use
  81337. * @param sourceZ defines the screen space z coordinate to use
  81338. * @param viewportWidth defines the current width of the viewport
  81339. * @param viewportHeight defines the current height of the viewport
  81340. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81341. * @param view defines the view matrix to use
  81342. * @param projection defines the projection matrix to use
  81343. * @param result defines the Vector3 where to store the result
  81344. */
  81345. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81346. /**
  81347. * Gets the minimal coordinate values between two Vector3
  81348. * @param left defines the first operand
  81349. * @param right defines the second operand
  81350. * @returns the new Vector3
  81351. */
  81352. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81353. /**
  81354. * Gets the maximal coordinate values between two Vector3
  81355. * @param left defines the first operand
  81356. * @param right defines the second operand
  81357. * @returns the new Vector3
  81358. */
  81359. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81360. /**
  81361. * Returns the distance between the vectors "value1" and "value2"
  81362. * @param value1 defines the first operand
  81363. * @param value2 defines the second operand
  81364. * @returns the distance
  81365. */
  81366. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81367. /**
  81368. * Returns the squared distance between the vectors "value1" and "value2"
  81369. * @param value1 defines the first operand
  81370. * @param value2 defines the second operand
  81371. * @returns the squared distance
  81372. */
  81373. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81374. /**
  81375. * Returns a new Vector3 located at the center between "value1" and "value2"
  81376. * @param value1 defines the first operand
  81377. * @param value2 defines the second operand
  81378. * @returns the new Vector3
  81379. */
  81380. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  81381. /**
  81382. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  81383. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  81384. * to something in order to rotate it from its local system to the given target system
  81385. * Note: axis1, axis2 and axis3 are normalized during this operation
  81386. * @param axis1 defines the first axis
  81387. * @param axis2 defines the second axis
  81388. * @param axis3 defines the third axis
  81389. * @returns a new Vector3
  81390. */
  81391. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  81392. /**
  81393. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  81394. * @param axis1 defines the first axis
  81395. * @param axis2 defines the second axis
  81396. * @param axis3 defines the third axis
  81397. * @param ref defines the Vector3 where to store the result
  81398. */
  81399. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  81400. }
  81401. /**
  81402. * Vector4 class created for EulerAngle class conversion to Quaternion
  81403. */
  81404. export class Vector4 {
  81405. /** x value of the vector */
  81406. x: number;
  81407. /** y value of the vector */
  81408. y: number;
  81409. /** z value of the vector */
  81410. z: number;
  81411. /** w value of the vector */
  81412. w: number;
  81413. /**
  81414. * Creates a Vector4 object from the given floats.
  81415. * @param x x value of the vector
  81416. * @param y y value of the vector
  81417. * @param z z value of the vector
  81418. * @param w w value of the vector
  81419. */
  81420. constructor(
  81421. /** x value of the vector */
  81422. x: number,
  81423. /** y value of the vector */
  81424. y: number,
  81425. /** z value of the vector */
  81426. z: number,
  81427. /** w value of the vector */
  81428. w: number);
  81429. /**
  81430. * Returns the string with the Vector4 coordinates.
  81431. * @returns a string containing all the vector values
  81432. */
  81433. toString(): string;
  81434. /**
  81435. * Returns the string "Vector4".
  81436. * @returns "Vector4"
  81437. */
  81438. getClassName(): string;
  81439. /**
  81440. * Returns the Vector4 hash code.
  81441. * @returns a unique hash code
  81442. */
  81443. getHashCode(): number;
  81444. /**
  81445. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  81446. * @returns the resulting array
  81447. */
  81448. asArray(): number[];
  81449. /**
  81450. * Populates the given array from the given index with the Vector4 coordinates.
  81451. * @param array array to populate
  81452. * @param index index of the array to start at (default: 0)
  81453. * @returns the Vector4.
  81454. */
  81455. toArray(array: FloatArray, index?: number): Vector4;
  81456. /**
  81457. * Adds the given vector to the current Vector4.
  81458. * @param otherVector the vector to add
  81459. * @returns the updated Vector4.
  81460. */
  81461. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81462. /**
  81463. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  81464. * @param otherVector the vector to add
  81465. * @returns the resulting vector
  81466. */
  81467. add(otherVector: DeepImmutable<Vector4>): Vector4;
  81468. /**
  81469. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  81470. * @param otherVector the vector to add
  81471. * @param result the vector to store the result
  81472. * @returns the current Vector4.
  81473. */
  81474. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81475. /**
  81476. * Subtract in place the given vector from the current Vector4.
  81477. * @param otherVector the vector to subtract
  81478. * @returns the updated Vector4.
  81479. */
  81480. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81481. /**
  81482. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  81483. * @param otherVector the vector to add
  81484. * @returns the new vector with the result
  81485. */
  81486. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  81487. /**
  81488. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  81489. * @param otherVector the vector to subtract
  81490. * @param result the vector to store the result
  81491. * @returns the current Vector4.
  81492. */
  81493. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81494. /**
  81495. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81496. */
  81497. /**
  81498. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81499. * @param x value to subtract
  81500. * @param y value to subtract
  81501. * @param z value to subtract
  81502. * @param w value to subtract
  81503. * @returns new vector containing the result
  81504. */
  81505. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81506. /**
  81507. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81508. * @param x value to subtract
  81509. * @param y value to subtract
  81510. * @param z value to subtract
  81511. * @param w value to subtract
  81512. * @param result the vector to store the result in
  81513. * @returns the current Vector4.
  81514. */
  81515. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  81516. /**
  81517. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  81518. * @returns a new vector with the negated values
  81519. */
  81520. negate(): Vector4;
  81521. /**
  81522. * Negate this vector in place
  81523. * @returns this
  81524. */
  81525. negateInPlace(): Vector4;
  81526. /**
  81527. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  81528. * @param result defines the Vector3 object where to store the result
  81529. * @returns the current Vector4
  81530. */
  81531. negateToRef(result: Vector4): Vector4;
  81532. /**
  81533. * Multiplies the current Vector4 coordinates by scale (float).
  81534. * @param scale the number to scale with
  81535. * @returns the updated Vector4.
  81536. */
  81537. scaleInPlace(scale: number): Vector4;
  81538. /**
  81539. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  81540. * @param scale the number to scale with
  81541. * @returns a new vector with the result
  81542. */
  81543. scale(scale: number): Vector4;
  81544. /**
  81545. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  81546. * @param scale the number to scale with
  81547. * @param result a vector to store the result in
  81548. * @returns the current Vector4.
  81549. */
  81550. scaleToRef(scale: number, result: Vector4): Vector4;
  81551. /**
  81552. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  81553. * @param scale defines the scale factor
  81554. * @param result defines the Vector4 object where to store the result
  81555. * @returns the unmodified current Vector4
  81556. */
  81557. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  81558. /**
  81559. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  81560. * @param otherVector the vector to compare against
  81561. * @returns true if they are equal
  81562. */
  81563. equals(otherVector: DeepImmutable<Vector4>): boolean;
  81564. /**
  81565. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  81566. * @param otherVector vector to compare against
  81567. * @param epsilon (Default: very small number)
  81568. * @returns true if they are equal
  81569. */
  81570. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  81571. /**
  81572. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  81573. * @param x x value to compare against
  81574. * @param y y value to compare against
  81575. * @param z z value to compare against
  81576. * @param w w value to compare against
  81577. * @returns true if equal
  81578. */
  81579. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  81580. /**
  81581. * Multiplies in place the current Vector4 by the given one.
  81582. * @param otherVector vector to multiple with
  81583. * @returns the updated Vector4.
  81584. */
  81585. multiplyInPlace(otherVector: Vector4): Vector4;
  81586. /**
  81587. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  81588. * @param otherVector vector to multiple with
  81589. * @returns resulting new vector
  81590. */
  81591. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  81592. /**
  81593. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  81594. * @param otherVector vector to multiple with
  81595. * @param result vector to store the result
  81596. * @returns the current Vector4.
  81597. */
  81598. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81599. /**
  81600. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  81601. * @param x x value multiply with
  81602. * @param y y value multiply with
  81603. * @param z z value multiply with
  81604. * @param w w value multiply with
  81605. * @returns resulting new vector
  81606. */
  81607. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  81608. /**
  81609. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  81610. * @param otherVector vector to devide with
  81611. * @returns resulting new vector
  81612. */
  81613. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  81614. /**
  81615. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  81616. * @param otherVector vector to devide with
  81617. * @param result vector to store the result
  81618. * @returns the current Vector4.
  81619. */
  81620. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81621. /**
  81622. * Divides the current Vector3 coordinates by the given ones.
  81623. * @param otherVector vector to devide with
  81624. * @returns the updated Vector3.
  81625. */
  81626. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81627. /**
  81628. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  81629. * @param other defines the second operand
  81630. * @returns the current updated Vector4
  81631. */
  81632. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81633. /**
  81634. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  81635. * @param other defines the second operand
  81636. * @returns the current updated Vector4
  81637. */
  81638. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81639. /**
  81640. * Gets a new Vector4 from current Vector4 floored values
  81641. * @returns a new Vector4
  81642. */
  81643. floor(): Vector4;
  81644. /**
  81645. * Gets a new Vector4 from current Vector3 floored values
  81646. * @returns a new Vector4
  81647. */
  81648. fract(): Vector4;
  81649. /**
  81650. * Returns the Vector4 length (float).
  81651. * @returns the length
  81652. */
  81653. length(): number;
  81654. /**
  81655. * Returns the Vector4 squared length (float).
  81656. * @returns the length squared
  81657. */
  81658. lengthSquared(): number;
  81659. /**
  81660. * Normalizes in place the Vector4.
  81661. * @returns the updated Vector4.
  81662. */
  81663. normalize(): Vector4;
  81664. /**
  81665. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  81666. * @returns this converted to a new vector3
  81667. */
  81668. toVector3(): Vector3;
  81669. /**
  81670. * Returns a new Vector4 copied from the current one.
  81671. * @returns the new cloned vector
  81672. */
  81673. clone(): Vector4;
  81674. /**
  81675. * Updates the current Vector4 with the given one coordinates.
  81676. * @param source the source vector to copy from
  81677. * @returns the updated Vector4.
  81678. */
  81679. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  81680. /**
  81681. * Updates the current Vector4 coordinates with the given floats.
  81682. * @param x float to copy from
  81683. * @param y float to copy from
  81684. * @param z float to copy from
  81685. * @param w float to copy from
  81686. * @returns the updated Vector4.
  81687. */
  81688. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81689. /**
  81690. * Updates the current Vector4 coordinates with the given floats.
  81691. * @param x float to set from
  81692. * @param y float to set from
  81693. * @param z float to set from
  81694. * @param w float to set from
  81695. * @returns the updated Vector4.
  81696. */
  81697. set(x: number, y: number, z: number, w: number): Vector4;
  81698. /**
  81699. * Copies the given float to the current Vector3 coordinates
  81700. * @param v defines the x, y, z and w coordinates of the operand
  81701. * @returns the current updated Vector3
  81702. */
  81703. setAll(v: number): Vector4;
  81704. /**
  81705. * Returns a new Vector4 set from the starting index of the given array.
  81706. * @param array the array to pull values from
  81707. * @param offset the offset into the array to start at
  81708. * @returns the new vector
  81709. */
  81710. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  81711. /**
  81712. * Updates the given vector "result" from the starting index of the given array.
  81713. * @param array the array to pull values from
  81714. * @param offset the offset into the array to start at
  81715. * @param result the vector to store the result in
  81716. */
  81717. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  81718. /**
  81719. * Updates the given vector "result" from the starting index of the given Float32Array.
  81720. * @param array the array to pull values from
  81721. * @param offset the offset into the array to start at
  81722. * @param result the vector to store the result in
  81723. */
  81724. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  81725. /**
  81726. * Updates the given vector "result" coordinates from the given floats.
  81727. * @param x float to set from
  81728. * @param y float to set from
  81729. * @param z float to set from
  81730. * @param w float to set from
  81731. * @param result the vector to the floats in
  81732. */
  81733. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  81734. /**
  81735. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  81736. * @returns the new vector
  81737. */
  81738. static Zero(): Vector4;
  81739. /**
  81740. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  81741. * @returns the new vector
  81742. */
  81743. static One(): Vector4;
  81744. /**
  81745. * Returns a new normalized Vector4 from the given one.
  81746. * @param vector the vector to normalize
  81747. * @returns the vector
  81748. */
  81749. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  81750. /**
  81751. * Updates the given vector "result" from the normalization of the given one.
  81752. * @param vector the vector to normalize
  81753. * @param result the vector to store the result in
  81754. */
  81755. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  81756. /**
  81757. * Returns a vector with the minimum values from the left and right vectors
  81758. * @param left left vector to minimize
  81759. * @param right right vector to minimize
  81760. * @returns a new vector with the minimum of the left and right vector values
  81761. */
  81762. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81763. /**
  81764. * Returns a vector with the maximum values from the left and right vectors
  81765. * @param left left vector to maximize
  81766. * @param right right vector to maximize
  81767. * @returns a new vector with the maximum of the left and right vector values
  81768. */
  81769. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81770. /**
  81771. * Returns the distance (float) between the vectors "value1" and "value2".
  81772. * @param value1 value to calulate the distance between
  81773. * @param value2 value to calulate the distance between
  81774. * @return the distance between the two vectors
  81775. */
  81776. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81777. /**
  81778. * Returns the squared distance (float) between the vectors "value1" and "value2".
  81779. * @param value1 value to calulate the distance between
  81780. * @param value2 value to calulate the distance between
  81781. * @return the distance between the two vectors squared
  81782. */
  81783. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81784. /**
  81785. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  81786. * @param value1 value to calulate the center between
  81787. * @param value2 value to calulate the center between
  81788. * @return the center between the two vectors
  81789. */
  81790. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  81791. /**
  81792. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  81793. * This methods computes transformed normalized direction vectors only.
  81794. * @param vector the vector to transform
  81795. * @param transformation the transformation matrix to apply
  81796. * @returns the new vector
  81797. */
  81798. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  81799. /**
  81800. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  81801. * This methods computes transformed normalized direction vectors only.
  81802. * @param vector the vector to transform
  81803. * @param transformation the transformation matrix to apply
  81804. * @param result the vector to store the result in
  81805. */
  81806. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81807. /**
  81808. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  81809. * This methods computes transformed normalized direction vectors only.
  81810. * @param x value to transform
  81811. * @param y value to transform
  81812. * @param z value to transform
  81813. * @param w value to transform
  81814. * @param transformation the transformation matrix to apply
  81815. * @param result the vector to store the results in
  81816. */
  81817. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81818. /**
  81819. * Creates a new Vector4 from a Vector3
  81820. * @param source defines the source data
  81821. * @param w defines the 4th component (default is 0)
  81822. * @returns a new Vector4
  81823. */
  81824. static FromVector3(source: Vector3, w?: number): Vector4;
  81825. }
  81826. /**
  81827. * Class used to store quaternion data
  81828. * @see https://en.wikipedia.org/wiki/Quaternion
  81829. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  81830. */
  81831. export class Quaternion {
  81832. /** @hidden */
  81833. _x: number;
  81834. /** @hidden */
  81835. _y: number;
  81836. /** @hidden */
  81837. _z: number;
  81838. /** @hidden */
  81839. _w: number;
  81840. /** @hidden */
  81841. _isDirty: boolean;
  81842. /** Gets or sets the x coordinate */
  81843. get x(): number;
  81844. set x(value: number);
  81845. /** Gets or sets the y coordinate */
  81846. get y(): number;
  81847. set y(value: number);
  81848. /** Gets or sets the z coordinate */
  81849. get z(): number;
  81850. set z(value: number);
  81851. /** Gets or sets the w coordinate */
  81852. get w(): number;
  81853. set w(value: number);
  81854. /**
  81855. * Creates a new Quaternion from the given floats
  81856. * @param x defines the first component (0 by default)
  81857. * @param y defines the second component (0 by default)
  81858. * @param z defines the third component (0 by default)
  81859. * @param w defines the fourth component (1.0 by default)
  81860. */
  81861. constructor(x?: number, y?: number, z?: number, w?: number);
  81862. /**
  81863. * Gets a string representation for the current quaternion
  81864. * @returns a string with the Quaternion coordinates
  81865. */
  81866. toString(): string;
  81867. /**
  81868. * Gets the class name of the quaternion
  81869. * @returns the string "Quaternion"
  81870. */
  81871. getClassName(): string;
  81872. /**
  81873. * Gets a hash code for this quaternion
  81874. * @returns the quaternion hash code
  81875. */
  81876. getHashCode(): number;
  81877. /**
  81878. * Copy the quaternion to an array
  81879. * @returns a new array populated with 4 elements from the quaternion coordinates
  81880. */
  81881. asArray(): number[];
  81882. /**
  81883. * Check if two quaternions are equals
  81884. * @param otherQuaternion defines the second operand
  81885. * @return true if the current quaternion and the given one coordinates are strictly equals
  81886. */
  81887. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  81888. /**
  81889. * Gets a boolean if two quaternions are equals (using an epsilon value)
  81890. * @param otherQuaternion defines the other quaternion
  81891. * @param epsilon defines the minimal distance to consider equality
  81892. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  81893. */
  81894. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  81895. /**
  81896. * Clone the current quaternion
  81897. * @returns a new quaternion copied from the current one
  81898. */
  81899. clone(): Quaternion;
  81900. /**
  81901. * Copy a quaternion to the current one
  81902. * @param other defines the other quaternion
  81903. * @returns the updated current quaternion
  81904. */
  81905. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  81906. /**
  81907. * Updates the current quaternion with the given float coordinates
  81908. * @param x defines the x coordinate
  81909. * @param y defines the y coordinate
  81910. * @param z defines the z coordinate
  81911. * @param w defines the w coordinate
  81912. * @returns the updated current quaternion
  81913. */
  81914. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  81915. /**
  81916. * Updates the current quaternion from the given float coordinates
  81917. * @param x defines the x coordinate
  81918. * @param y defines the y coordinate
  81919. * @param z defines the z coordinate
  81920. * @param w defines the w coordinate
  81921. * @returns the updated current quaternion
  81922. */
  81923. set(x: number, y: number, z: number, w: number): Quaternion;
  81924. /**
  81925. * Adds two quaternions
  81926. * @param other defines the second operand
  81927. * @returns a new quaternion as the addition result of the given one and the current quaternion
  81928. */
  81929. add(other: DeepImmutable<Quaternion>): Quaternion;
  81930. /**
  81931. * Add a quaternion to the current one
  81932. * @param other defines the quaternion to add
  81933. * @returns the current quaternion
  81934. */
  81935. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  81936. /**
  81937. * Subtract two quaternions
  81938. * @param other defines the second operand
  81939. * @returns a new quaternion as the subtraction result of the given one from the current one
  81940. */
  81941. subtract(other: Quaternion): Quaternion;
  81942. /**
  81943. * Multiplies the current quaternion by a scale factor
  81944. * @param value defines the scale factor
  81945. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  81946. */
  81947. scale(value: number): Quaternion;
  81948. /**
  81949. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  81950. * @param scale defines the scale factor
  81951. * @param result defines the Quaternion object where to store the result
  81952. * @returns the unmodified current quaternion
  81953. */
  81954. scaleToRef(scale: number, result: Quaternion): Quaternion;
  81955. /**
  81956. * Multiplies in place the current quaternion by a scale factor
  81957. * @param value defines the scale factor
  81958. * @returns the current modified quaternion
  81959. */
  81960. scaleInPlace(value: number): Quaternion;
  81961. /**
  81962. * Scale the current quaternion values by a factor and add the result to a given quaternion
  81963. * @param scale defines the scale factor
  81964. * @param result defines the Quaternion object where to store the result
  81965. * @returns the unmodified current quaternion
  81966. */
  81967. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  81968. /**
  81969. * Multiplies two quaternions
  81970. * @param q1 defines the second operand
  81971. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  81972. */
  81973. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  81974. /**
  81975. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  81976. * @param q1 defines the second operand
  81977. * @param result defines the target quaternion
  81978. * @returns the current quaternion
  81979. */
  81980. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  81981. /**
  81982. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  81983. * @param q1 defines the second operand
  81984. * @returns the currentupdated quaternion
  81985. */
  81986. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  81987. /**
  81988. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  81989. * @param ref defines the target quaternion
  81990. * @returns the current quaternion
  81991. */
  81992. conjugateToRef(ref: Quaternion): Quaternion;
  81993. /**
  81994. * Conjugates in place (1-q) the current quaternion
  81995. * @returns the current updated quaternion
  81996. */
  81997. conjugateInPlace(): Quaternion;
  81998. /**
  81999. * Conjugates in place (1-q) the current quaternion
  82000. * @returns a new quaternion
  82001. */
  82002. conjugate(): Quaternion;
  82003. /**
  82004. * Gets length of current quaternion
  82005. * @returns the quaternion length (float)
  82006. */
  82007. length(): number;
  82008. /**
  82009. * Normalize in place the current quaternion
  82010. * @returns the current updated quaternion
  82011. */
  82012. normalize(): Quaternion;
  82013. /**
  82014. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82015. * @param order is a reserved parameter and is ignore for now
  82016. * @returns a new Vector3 containing the Euler angles
  82017. */
  82018. toEulerAngles(order?: string): Vector3;
  82019. /**
  82020. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82021. * @param result defines the vector which will be filled with the Euler angles
  82022. * @param order is a reserved parameter and is ignore for now
  82023. * @returns the current unchanged quaternion
  82024. */
  82025. toEulerAnglesToRef(result: Vector3): Quaternion;
  82026. /**
  82027. * Updates the given rotation matrix with the current quaternion values
  82028. * @param result defines the target matrix
  82029. * @returns the current unchanged quaternion
  82030. */
  82031. toRotationMatrix(result: Matrix): Quaternion;
  82032. /**
  82033. * Updates the current quaternion from the given rotation matrix values
  82034. * @param matrix defines the source matrix
  82035. * @returns the current updated quaternion
  82036. */
  82037. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82038. /**
  82039. * Creates a new quaternion from a rotation matrix
  82040. * @param matrix defines the source matrix
  82041. * @returns a new quaternion created from the given rotation matrix values
  82042. */
  82043. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82044. /**
  82045. * Updates the given quaternion with the given rotation matrix values
  82046. * @param matrix defines the source matrix
  82047. * @param result defines the target quaternion
  82048. */
  82049. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82050. /**
  82051. * Returns the dot product (float) between the quaternions "left" and "right"
  82052. * @param left defines the left operand
  82053. * @param right defines the right operand
  82054. * @returns the dot product
  82055. */
  82056. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82057. /**
  82058. * Checks if the two quaternions are close to each other
  82059. * @param quat0 defines the first quaternion to check
  82060. * @param quat1 defines the second quaternion to check
  82061. * @returns true if the two quaternions are close to each other
  82062. */
  82063. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82064. /**
  82065. * Creates an empty quaternion
  82066. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82067. */
  82068. static Zero(): Quaternion;
  82069. /**
  82070. * Inverse a given quaternion
  82071. * @param q defines the source quaternion
  82072. * @returns a new quaternion as the inverted current quaternion
  82073. */
  82074. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82075. /**
  82076. * Inverse a given quaternion
  82077. * @param q defines the source quaternion
  82078. * @param result the quaternion the result will be stored in
  82079. * @returns the result quaternion
  82080. */
  82081. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82082. /**
  82083. * Creates an identity quaternion
  82084. * @returns the identity quaternion
  82085. */
  82086. static Identity(): Quaternion;
  82087. /**
  82088. * Gets a boolean indicating if the given quaternion is identity
  82089. * @param quaternion defines the quaternion to check
  82090. * @returns true if the quaternion is identity
  82091. */
  82092. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82093. /**
  82094. * Creates a quaternion from a rotation around an axis
  82095. * @param axis defines the axis to use
  82096. * @param angle defines the angle to use
  82097. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82098. */
  82099. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82100. /**
  82101. * Creates a rotation around an axis and stores it into the given quaternion
  82102. * @param axis defines the axis to use
  82103. * @param angle defines the angle to use
  82104. * @param result defines the target quaternion
  82105. * @returns the target quaternion
  82106. */
  82107. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82108. /**
  82109. * Creates a new quaternion from data stored into an array
  82110. * @param array defines the data source
  82111. * @param offset defines the offset in the source array where the data starts
  82112. * @returns a new quaternion
  82113. */
  82114. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82115. /**
  82116. * Updates the given quaternion "result" from the starting index of the given array.
  82117. * @param array the array to pull values from
  82118. * @param offset the offset into the array to start at
  82119. * @param result the quaternion to store the result in
  82120. */
  82121. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82122. /**
  82123. * Create a quaternion from Euler rotation angles
  82124. * @param x Pitch
  82125. * @param y Yaw
  82126. * @param z Roll
  82127. * @returns the new Quaternion
  82128. */
  82129. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82130. /**
  82131. * Updates a quaternion from Euler rotation angles
  82132. * @param x Pitch
  82133. * @param y Yaw
  82134. * @param z Roll
  82135. * @param result the quaternion to store the result
  82136. * @returns the updated quaternion
  82137. */
  82138. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  82139. /**
  82140. * Create a quaternion from Euler rotation vector
  82141. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82142. * @returns the new Quaternion
  82143. */
  82144. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  82145. /**
  82146. * Updates a quaternion from Euler rotation vector
  82147. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82148. * @param result the quaternion to store the result
  82149. * @returns the updated quaternion
  82150. */
  82151. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  82152. /**
  82153. * Creates a new quaternion from the given Euler float angles (y, x, z)
  82154. * @param yaw defines the rotation around Y axis
  82155. * @param pitch defines the rotation around X axis
  82156. * @param roll defines the rotation around Z axis
  82157. * @returns the new quaternion
  82158. */
  82159. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  82160. /**
  82161. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  82162. * @param yaw defines the rotation around Y axis
  82163. * @param pitch defines the rotation around X axis
  82164. * @param roll defines the rotation around Z axis
  82165. * @param result defines the target quaternion
  82166. */
  82167. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  82168. /**
  82169. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  82170. * @param alpha defines the rotation around first axis
  82171. * @param beta defines the rotation around second axis
  82172. * @param gamma defines the rotation around third axis
  82173. * @returns the new quaternion
  82174. */
  82175. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  82176. /**
  82177. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  82178. * @param alpha defines the rotation around first axis
  82179. * @param beta defines the rotation around second axis
  82180. * @param gamma defines the rotation around third axis
  82181. * @param result defines the target quaternion
  82182. */
  82183. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  82184. /**
  82185. * 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)
  82186. * @param axis1 defines the first axis
  82187. * @param axis2 defines the second axis
  82188. * @param axis3 defines the third axis
  82189. * @returns the new quaternion
  82190. */
  82191. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  82192. /**
  82193. * 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
  82194. * @param axis1 defines the first axis
  82195. * @param axis2 defines the second axis
  82196. * @param axis3 defines the third axis
  82197. * @param ref defines the target quaternion
  82198. */
  82199. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  82200. /**
  82201. * Interpolates between two quaternions
  82202. * @param left defines first quaternion
  82203. * @param right defines second quaternion
  82204. * @param amount defines the gradient to use
  82205. * @returns the new interpolated quaternion
  82206. */
  82207. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82208. /**
  82209. * Interpolates between two quaternions and stores it into a target quaternion
  82210. * @param left defines first quaternion
  82211. * @param right defines second quaternion
  82212. * @param amount defines the gradient to use
  82213. * @param result defines the target quaternion
  82214. */
  82215. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  82216. /**
  82217. * Interpolate between two quaternions using Hermite interpolation
  82218. * @param value1 defines first quaternion
  82219. * @param tangent1 defines the incoming tangent
  82220. * @param value2 defines second quaternion
  82221. * @param tangent2 defines the outgoing tangent
  82222. * @param amount defines the target quaternion
  82223. * @returns the new interpolated quaternion
  82224. */
  82225. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82226. }
  82227. /**
  82228. * Class used to store matrix data (4x4)
  82229. */
  82230. export class Matrix {
  82231. private static _updateFlagSeed;
  82232. private static _identityReadOnly;
  82233. private _isIdentity;
  82234. private _isIdentityDirty;
  82235. private _isIdentity3x2;
  82236. private _isIdentity3x2Dirty;
  82237. /**
  82238. * Gets the update flag of the matrix which is an unique number for the matrix.
  82239. * It will be incremented every time the matrix data change.
  82240. * You can use it to speed the comparison between two versions of the same matrix.
  82241. */
  82242. updateFlag: number;
  82243. private readonly _m;
  82244. /**
  82245. * Gets the internal data of the matrix
  82246. */
  82247. get m(): DeepImmutable<Float32Array>;
  82248. /** @hidden */
  82249. _markAsUpdated(): void;
  82250. /** @hidden */
  82251. private _updateIdentityStatus;
  82252. /**
  82253. * Creates an empty matrix (filled with zeros)
  82254. */
  82255. constructor();
  82256. /**
  82257. * Check if the current matrix is identity
  82258. * @returns true is the matrix is the identity matrix
  82259. */
  82260. isIdentity(): boolean;
  82261. /**
  82262. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  82263. * @returns true is the matrix is the identity matrix
  82264. */
  82265. isIdentityAs3x2(): boolean;
  82266. /**
  82267. * Gets the determinant of the matrix
  82268. * @returns the matrix determinant
  82269. */
  82270. determinant(): number;
  82271. /**
  82272. * Returns the matrix as a Float32Array
  82273. * @returns the matrix underlying array
  82274. */
  82275. toArray(): DeepImmutable<Float32Array>;
  82276. /**
  82277. * Returns the matrix as a Float32Array
  82278. * @returns the matrix underlying array.
  82279. */
  82280. asArray(): DeepImmutable<Float32Array>;
  82281. /**
  82282. * Inverts the current matrix in place
  82283. * @returns the current inverted matrix
  82284. */
  82285. invert(): Matrix;
  82286. /**
  82287. * Sets all the matrix elements to zero
  82288. * @returns the current matrix
  82289. */
  82290. reset(): Matrix;
  82291. /**
  82292. * Adds the current matrix with a second one
  82293. * @param other defines the matrix to add
  82294. * @returns a new matrix as the addition of the current matrix and the given one
  82295. */
  82296. add(other: DeepImmutable<Matrix>): Matrix;
  82297. /**
  82298. * Sets the given matrix "result" to the addition of the current matrix and the given one
  82299. * @param other defines the matrix to add
  82300. * @param result defines the target matrix
  82301. * @returns the current matrix
  82302. */
  82303. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82304. /**
  82305. * Adds in place the given matrix to the current matrix
  82306. * @param other defines the second operand
  82307. * @returns the current updated matrix
  82308. */
  82309. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  82310. /**
  82311. * Sets the given matrix to the current inverted Matrix
  82312. * @param other defines the target matrix
  82313. * @returns the unmodified current matrix
  82314. */
  82315. invertToRef(other: Matrix): Matrix;
  82316. /**
  82317. * add a value at the specified position in the current Matrix
  82318. * @param index the index of the value within the matrix. between 0 and 15.
  82319. * @param value the value to be added
  82320. * @returns the current updated matrix
  82321. */
  82322. addAtIndex(index: number, value: number): Matrix;
  82323. /**
  82324. * mutiply the specified position in the current Matrix by a value
  82325. * @param index the index of the value within the matrix. between 0 and 15.
  82326. * @param value the value to be added
  82327. * @returns the current updated matrix
  82328. */
  82329. multiplyAtIndex(index: number, value: number): Matrix;
  82330. /**
  82331. * Inserts the translation vector (using 3 floats) in the current matrix
  82332. * @param x defines the 1st component of the translation
  82333. * @param y defines the 2nd component of the translation
  82334. * @param z defines the 3rd component of the translation
  82335. * @returns the current updated matrix
  82336. */
  82337. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82338. /**
  82339. * Adds the translation vector (using 3 floats) in the current matrix
  82340. * @param x defines the 1st component of the translation
  82341. * @param y defines the 2nd component of the translation
  82342. * @param z defines the 3rd component of the translation
  82343. * @returns the current updated matrix
  82344. */
  82345. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82346. /**
  82347. * Inserts the translation vector in the current matrix
  82348. * @param vector3 defines the translation to insert
  82349. * @returns the current updated matrix
  82350. */
  82351. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  82352. /**
  82353. * Gets the translation value of the current matrix
  82354. * @returns a new Vector3 as the extracted translation from the matrix
  82355. */
  82356. getTranslation(): Vector3;
  82357. /**
  82358. * Fill a Vector3 with the extracted translation from the matrix
  82359. * @param result defines the Vector3 where to store the translation
  82360. * @returns the current matrix
  82361. */
  82362. getTranslationToRef(result: Vector3): Matrix;
  82363. /**
  82364. * Remove rotation and scaling part from the matrix
  82365. * @returns the updated matrix
  82366. */
  82367. removeRotationAndScaling(): Matrix;
  82368. /**
  82369. * Multiply two matrices
  82370. * @param other defines the second operand
  82371. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  82372. */
  82373. multiply(other: DeepImmutable<Matrix>): Matrix;
  82374. /**
  82375. * Copy the current matrix from the given one
  82376. * @param other defines the source matrix
  82377. * @returns the current updated matrix
  82378. */
  82379. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  82380. /**
  82381. * Populates the given array from the starting index with the current matrix values
  82382. * @param array defines the target array
  82383. * @param offset defines the offset in the target array where to start storing values
  82384. * @returns the current matrix
  82385. */
  82386. copyToArray(array: Float32Array, offset?: number): Matrix;
  82387. /**
  82388. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  82389. * @param other defines the second operand
  82390. * @param result defines the matrix where to store the multiplication
  82391. * @returns the current matrix
  82392. */
  82393. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82394. /**
  82395. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  82396. * @param other defines the second operand
  82397. * @param result defines the array where to store the multiplication
  82398. * @param offset defines the offset in the target array where to start storing values
  82399. * @returns the current matrix
  82400. */
  82401. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  82402. /**
  82403. * Check equality between this matrix and a second one
  82404. * @param value defines the second matrix to compare
  82405. * @returns true is the current matrix and the given one values are strictly equal
  82406. */
  82407. equals(value: DeepImmutable<Matrix>): boolean;
  82408. /**
  82409. * Clone the current matrix
  82410. * @returns a new matrix from the current matrix
  82411. */
  82412. clone(): Matrix;
  82413. /**
  82414. * Returns the name of the current matrix class
  82415. * @returns the string "Matrix"
  82416. */
  82417. getClassName(): string;
  82418. /**
  82419. * Gets the hash code of the current matrix
  82420. * @returns the hash code
  82421. */
  82422. getHashCode(): number;
  82423. /**
  82424. * Decomposes the current Matrix into a translation, rotation and scaling components
  82425. * @param scale defines the scale vector3 given as a reference to update
  82426. * @param rotation defines the rotation quaternion given as a reference to update
  82427. * @param translation defines the translation vector3 given as a reference to update
  82428. * @returns true if operation was successful
  82429. */
  82430. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  82431. /**
  82432. * Gets specific row of the matrix
  82433. * @param index defines the number of the row to get
  82434. * @returns the index-th row of the current matrix as a new Vector4
  82435. */
  82436. getRow(index: number): Nullable<Vector4>;
  82437. /**
  82438. * Sets the index-th row of the current matrix to the vector4 values
  82439. * @param index defines the number of the row to set
  82440. * @param row defines the target vector4
  82441. * @returns the updated current matrix
  82442. */
  82443. setRow(index: number, row: Vector4): Matrix;
  82444. /**
  82445. * Compute the transpose of the matrix
  82446. * @returns the new transposed matrix
  82447. */
  82448. transpose(): Matrix;
  82449. /**
  82450. * Compute the transpose of the matrix and store it in a given matrix
  82451. * @param result defines the target matrix
  82452. * @returns the current matrix
  82453. */
  82454. transposeToRef(result: Matrix): Matrix;
  82455. /**
  82456. * Sets the index-th row of the current matrix with the given 4 x float values
  82457. * @param index defines the row index
  82458. * @param x defines the x component to set
  82459. * @param y defines the y component to set
  82460. * @param z defines the z component to set
  82461. * @param w defines the w component to set
  82462. * @returns the updated current matrix
  82463. */
  82464. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  82465. /**
  82466. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  82467. * @param scale defines the scale factor
  82468. * @returns a new matrix
  82469. */
  82470. scale(scale: number): Matrix;
  82471. /**
  82472. * Scale the current matrix values by a factor to a given result matrix
  82473. * @param scale defines the scale factor
  82474. * @param result defines the matrix to store the result
  82475. * @returns the current matrix
  82476. */
  82477. scaleToRef(scale: number, result: Matrix): Matrix;
  82478. /**
  82479. * Scale the current matrix values by a factor and add the result to a given matrix
  82480. * @param scale defines the scale factor
  82481. * @param result defines the Matrix to store the result
  82482. * @returns the current matrix
  82483. */
  82484. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  82485. /**
  82486. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  82487. * @param ref matrix to store the result
  82488. */
  82489. toNormalMatrix(ref: Matrix): void;
  82490. /**
  82491. * Gets only rotation part of the current matrix
  82492. * @returns a new matrix sets to the extracted rotation matrix from the current one
  82493. */
  82494. getRotationMatrix(): Matrix;
  82495. /**
  82496. * Extracts the rotation matrix from the current one and sets it as the given "result"
  82497. * @param result defines the target matrix to store data to
  82498. * @returns the current matrix
  82499. */
  82500. getRotationMatrixToRef(result: Matrix): Matrix;
  82501. /**
  82502. * Toggles model matrix from being right handed to left handed in place and vice versa
  82503. */
  82504. toggleModelMatrixHandInPlace(): void;
  82505. /**
  82506. * Toggles projection matrix from being right handed to left handed in place and vice versa
  82507. */
  82508. toggleProjectionMatrixHandInPlace(): void;
  82509. /**
  82510. * Creates a matrix from an array
  82511. * @param array defines the source array
  82512. * @param offset defines an offset in the source array
  82513. * @returns a new Matrix set from the starting index of the given array
  82514. */
  82515. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  82516. /**
  82517. * Copy the content of an array into a given matrix
  82518. * @param array defines the source array
  82519. * @param offset defines an offset in the source array
  82520. * @param result defines the target matrix
  82521. */
  82522. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  82523. /**
  82524. * Stores an array into a matrix after having multiplied each component by a given factor
  82525. * @param array defines the source array
  82526. * @param offset defines the offset in the source array
  82527. * @param scale defines the scaling factor
  82528. * @param result defines the target matrix
  82529. */
  82530. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  82531. /**
  82532. * Gets an identity matrix that must not be updated
  82533. */
  82534. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  82535. /**
  82536. * Stores a list of values (16) inside a given matrix
  82537. * @param initialM11 defines 1st value of 1st row
  82538. * @param initialM12 defines 2nd value of 1st row
  82539. * @param initialM13 defines 3rd value of 1st row
  82540. * @param initialM14 defines 4th value of 1st row
  82541. * @param initialM21 defines 1st value of 2nd row
  82542. * @param initialM22 defines 2nd value of 2nd row
  82543. * @param initialM23 defines 3rd value of 2nd row
  82544. * @param initialM24 defines 4th value of 2nd row
  82545. * @param initialM31 defines 1st value of 3rd row
  82546. * @param initialM32 defines 2nd value of 3rd row
  82547. * @param initialM33 defines 3rd value of 3rd row
  82548. * @param initialM34 defines 4th value of 3rd row
  82549. * @param initialM41 defines 1st value of 4th row
  82550. * @param initialM42 defines 2nd value of 4th row
  82551. * @param initialM43 defines 3rd value of 4th row
  82552. * @param initialM44 defines 4th value of 4th row
  82553. * @param result defines the target matrix
  82554. */
  82555. 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;
  82556. /**
  82557. * Creates new matrix from a list of values (16)
  82558. * @param initialM11 defines 1st value of 1st row
  82559. * @param initialM12 defines 2nd value of 1st row
  82560. * @param initialM13 defines 3rd value of 1st row
  82561. * @param initialM14 defines 4th value of 1st row
  82562. * @param initialM21 defines 1st value of 2nd row
  82563. * @param initialM22 defines 2nd value of 2nd row
  82564. * @param initialM23 defines 3rd value of 2nd row
  82565. * @param initialM24 defines 4th value of 2nd row
  82566. * @param initialM31 defines 1st value of 3rd row
  82567. * @param initialM32 defines 2nd value of 3rd row
  82568. * @param initialM33 defines 3rd value of 3rd row
  82569. * @param initialM34 defines 4th value of 3rd row
  82570. * @param initialM41 defines 1st value of 4th row
  82571. * @param initialM42 defines 2nd value of 4th row
  82572. * @param initialM43 defines 3rd value of 4th row
  82573. * @param initialM44 defines 4th value of 4th row
  82574. * @returns the new matrix
  82575. */
  82576. 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;
  82577. /**
  82578. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82579. * @param scale defines the scale vector3
  82580. * @param rotation defines the rotation quaternion
  82581. * @param translation defines the translation vector3
  82582. * @returns a new matrix
  82583. */
  82584. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  82585. /**
  82586. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82587. * @param scale defines the scale vector3
  82588. * @param rotation defines the rotation quaternion
  82589. * @param translation defines the translation vector3
  82590. * @param result defines the target matrix
  82591. */
  82592. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  82593. /**
  82594. * Creates a new identity matrix
  82595. * @returns a new identity matrix
  82596. */
  82597. static Identity(): Matrix;
  82598. /**
  82599. * Creates a new identity matrix and stores the result in a given matrix
  82600. * @param result defines the target matrix
  82601. */
  82602. static IdentityToRef(result: Matrix): void;
  82603. /**
  82604. * Creates a new zero matrix
  82605. * @returns a new zero matrix
  82606. */
  82607. static Zero(): Matrix;
  82608. /**
  82609. * Creates a new rotation matrix for "angle" radians around the X axis
  82610. * @param angle defines the angle (in radians) to use
  82611. * @return the new matrix
  82612. */
  82613. static RotationX(angle: number): Matrix;
  82614. /**
  82615. * Creates a new matrix as the invert of a given matrix
  82616. * @param source defines the source matrix
  82617. * @returns the new matrix
  82618. */
  82619. static Invert(source: DeepImmutable<Matrix>): Matrix;
  82620. /**
  82621. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  82622. * @param angle defines the angle (in radians) to use
  82623. * @param result defines the target matrix
  82624. */
  82625. static RotationXToRef(angle: number, result: Matrix): void;
  82626. /**
  82627. * Creates a new rotation matrix for "angle" radians around the Y axis
  82628. * @param angle defines the angle (in radians) to use
  82629. * @return the new matrix
  82630. */
  82631. static RotationY(angle: number): Matrix;
  82632. /**
  82633. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  82634. * @param angle defines the angle (in radians) to use
  82635. * @param result defines the target matrix
  82636. */
  82637. static RotationYToRef(angle: number, result: Matrix): void;
  82638. /**
  82639. * Creates a new rotation matrix for "angle" radians around the Z axis
  82640. * @param angle defines the angle (in radians) to use
  82641. * @return the new matrix
  82642. */
  82643. static RotationZ(angle: number): Matrix;
  82644. /**
  82645. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  82646. * @param angle defines the angle (in radians) to use
  82647. * @param result defines the target matrix
  82648. */
  82649. static RotationZToRef(angle: number, result: Matrix): void;
  82650. /**
  82651. * Creates a new rotation matrix for "angle" radians around the given axis
  82652. * @param axis defines the axis to use
  82653. * @param angle defines the angle (in radians) to use
  82654. * @return the new matrix
  82655. */
  82656. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  82657. /**
  82658. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  82659. * @param axis defines the axis to use
  82660. * @param angle defines the angle (in radians) to use
  82661. * @param result defines the target matrix
  82662. */
  82663. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  82664. /**
  82665. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  82666. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  82667. * @param from defines the vector to align
  82668. * @param to defines the vector to align to
  82669. * @param result defines the target matrix
  82670. */
  82671. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  82672. /**
  82673. * Creates a rotation matrix
  82674. * @param yaw defines the yaw angle in radians (Y axis)
  82675. * @param pitch defines the pitch angle in radians (X axis)
  82676. * @param roll defines the roll angle in radians (X axis)
  82677. * @returns the new rotation matrix
  82678. */
  82679. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  82680. /**
  82681. * Creates a rotation matrix and stores it in a given matrix
  82682. * @param yaw defines the yaw angle in radians (Y axis)
  82683. * @param pitch defines the pitch angle in radians (X axis)
  82684. * @param roll defines the roll angle in radians (X axis)
  82685. * @param result defines the target matrix
  82686. */
  82687. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  82688. /**
  82689. * Creates a scaling matrix
  82690. * @param x defines the scale factor on X axis
  82691. * @param y defines the scale factor on Y axis
  82692. * @param z defines the scale factor on Z axis
  82693. * @returns the new matrix
  82694. */
  82695. static Scaling(x: number, y: number, z: number): Matrix;
  82696. /**
  82697. * Creates a scaling matrix and stores it in a given matrix
  82698. * @param x defines the scale factor on X axis
  82699. * @param y defines the scale factor on Y axis
  82700. * @param z defines the scale factor on Z axis
  82701. * @param result defines the target matrix
  82702. */
  82703. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  82704. /**
  82705. * Creates a translation matrix
  82706. * @param x defines the translation on X axis
  82707. * @param y defines the translation on Y axis
  82708. * @param z defines the translationon Z axis
  82709. * @returns the new matrix
  82710. */
  82711. static Translation(x: number, y: number, z: number): Matrix;
  82712. /**
  82713. * Creates a translation matrix and stores it in a given matrix
  82714. * @param x defines the translation on X axis
  82715. * @param y defines the translation on Y axis
  82716. * @param z defines the translationon Z axis
  82717. * @param result defines the target matrix
  82718. */
  82719. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  82720. /**
  82721. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82722. * @param startValue defines the start value
  82723. * @param endValue defines the end value
  82724. * @param gradient defines the gradient factor
  82725. * @returns the new matrix
  82726. */
  82727. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82728. /**
  82729. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82730. * @param startValue defines the start value
  82731. * @param endValue defines the end value
  82732. * @param gradient defines the gradient factor
  82733. * @param result defines the Matrix object where to store data
  82734. */
  82735. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82736. /**
  82737. * Builds a new matrix whose values are computed by:
  82738. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82739. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82740. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82741. * @param startValue defines the first matrix
  82742. * @param endValue defines the second matrix
  82743. * @param gradient defines the gradient between the two matrices
  82744. * @returns the new matrix
  82745. */
  82746. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82747. /**
  82748. * Update a matrix to values which are computed by:
  82749. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82750. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82751. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82752. * @param startValue defines the first matrix
  82753. * @param endValue defines the second matrix
  82754. * @param gradient defines the gradient between the two matrices
  82755. * @param result defines the target matrix
  82756. */
  82757. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82758. /**
  82759. * 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"
  82760. * This function works in left handed mode
  82761. * @param eye defines the final position of the entity
  82762. * @param target defines where the entity should look at
  82763. * @param up defines the up vector for the entity
  82764. * @returns the new matrix
  82765. */
  82766. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82767. /**
  82768. * 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".
  82769. * This function works in left handed mode
  82770. * @param eye defines the final position of the entity
  82771. * @param target defines where the entity should look at
  82772. * @param up defines the up vector for the entity
  82773. * @param result defines the target matrix
  82774. */
  82775. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82776. /**
  82777. * 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"
  82778. * This function works in right handed mode
  82779. * @param eye defines the final position of the entity
  82780. * @param target defines where the entity should look at
  82781. * @param up defines the up vector for the entity
  82782. * @returns the new matrix
  82783. */
  82784. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82785. /**
  82786. * 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".
  82787. * This function works in right handed mode
  82788. * @param eye defines the final position of the entity
  82789. * @param target defines where the entity should look at
  82790. * @param up defines the up vector for the entity
  82791. * @param result defines the target matrix
  82792. */
  82793. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82794. /**
  82795. * Create a left-handed orthographic projection matrix
  82796. * @param width defines the viewport width
  82797. * @param height defines the viewport height
  82798. * @param znear defines the near clip plane
  82799. * @param zfar defines the far clip plane
  82800. * @returns a new matrix as a left-handed orthographic projection matrix
  82801. */
  82802. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82803. /**
  82804. * Store a left-handed orthographic projection to a given matrix
  82805. * @param width defines the viewport width
  82806. * @param height defines the viewport height
  82807. * @param znear defines the near clip plane
  82808. * @param zfar defines the far clip plane
  82809. * @param result defines the target matrix
  82810. */
  82811. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  82812. /**
  82813. * Create a left-handed orthographic projection matrix
  82814. * @param left defines the viewport left coordinate
  82815. * @param right defines the viewport right coordinate
  82816. * @param bottom defines the viewport bottom coordinate
  82817. * @param top defines the viewport top coordinate
  82818. * @param znear defines the near clip plane
  82819. * @param zfar defines the far clip plane
  82820. * @returns a new matrix as a left-handed orthographic projection matrix
  82821. */
  82822. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82823. /**
  82824. * Stores a left-handed orthographic projection into a given matrix
  82825. * @param left defines the viewport left coordinate
  82826. * @param right defines the viewport right coordinate
  82827. * @param bottom defines the viewport bottom coordinate
  82828. * @param top defines the viewport top coordinate
  82829. * @param znear defines the near clip plane
  82830. * @param zfar defines the far clip plane
  82831. * @param result defines the target matrix
  82832. */
  82833. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82834. /**
  82835. * Creates a right-handed orthographic projection matrix
  82836. * @param left defines the viewport left coordinate
  82837. * @param right defines the viewport right coordinate
  82838. * @param bottom defines the viewport bottom coordinate
  82839. * @param top defines the viewport top coordinate
  82840. * @param znear defines the near clip plane
  82841. * @param zfar defines the far clip plane
  82842. * @returns a new matrix as a right-handed orthographic projection matrix
  82843. */
  82844. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82845. /**
  82846. * Stores a right-handed orthographic projection into a given matrix
  82847. * @param left defines the viewport left coordinate
  82848. * @param right defines the viewport right coordinate
  82849. * @param bottom defines the viewport bottom coordinate
  82850. * @param top defines the viewport top coordinate
  82851. * @param znear defines the near clip plane
  82852. * @param zfar defines the far clip plane
  82853. * @param result defines the target matrix
  82854. */
  82855. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82856. /**
  82857. * Creates a left-handed perspective projection matrix
  82858. * @param width defines the viewport width
  82859. * @param height defines the viewport height
  82860. * @param znear defines the near clip plane
  82861. * @param zfar defines the far clip plane
  82862. * @returns a new matrix as a left-handed perspective projection matrix
  82863. */
  82864. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82865. /**
  82866. * Creates a left-handed perspective projection matrix
  82867. * @param fov defines the horizontal field of view
  82868. * @param aspect defines the aspect ratio
  82869. * @param znear defines the near clip plane
  82870. * @param zfar defines the far clip plane
  82871. * @returns a new matrix as a left-handed perspective projection matrix
  82872. */
  82873. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82874. /**
  82875. * Stores a left-handed perspective projection into a given matrix
  82876. * @param fov defines the horizontal field of view
  82877. * @param aspect defines the aspect ratio
  82878. * @param znear defines the near clip plane
  82879. * @param zfar defines the far clip plane
  82880. * @param result defines the target matrix
  82881. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82882. */
  82883. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82884. /**
  82885. * Stores a left-handed perspective projection into a given matrix with depth reversed
  82886. * @param fov defines the horizontal field of view
  82887. * @param aspect defines the aspect ratio
  82888. * @param znear defines the near clip plane
  82889. * @param zfar not used as infinity is used as far clip
  82890. * @param result defines the target matrix
  82891. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82892. */
  82893. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82894. /**
  82895. * Creates a right-handed perspective projection matrix
  82896. * @param fov defines the horizontal field of view
  82897. * @param aspect defines the aspect ratio
  82898. * @param znear defines the near clip plane
  82899. * @param zfar defines the far clip plane
  82900. * @returns a new matrix as a right-handed perspective projection matrix
  82901. */
  82902. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82903. /**
  82904. * Stores a right-handed perspective projection into a given matrix
  82905. * @param fov defines the horizontal field of view
  82906. * @param aspect defines the aspect ratio
  82907. * @param znear defines the near clip plane
  82908. * @param zfar defines the far clip plane
  82909. * @param result defines the target matrix
  82910. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82911. */
  82912. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82913. /**
  82914. * Stores a right-handed perspective projection into a given matrix
  82915. * @param fov defines the horizontal field of view
  82916. * @param aspect defines the aspect ratio
  82917. * @param znear defines the near clip plane
  82918. * @param zfar not used as infinity is used as far clip
  82919. * @param result defines the target matrix
  82920. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82921. */
  82922. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82923. /**
  82924. * Stores a perspective projection for WebVR info a given matrix
  82925. * @param fov defines the field of view
  82926. * @param znear defines the near clip plane
  82927. * @param zfar defines the far clip plane
  82928. * @param result defines the target matrix
  82929. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  82930. */
  82931. static PerspectiveFovWebVRToRef(fov: {
  82932. upDegrees: number;
  82933. downDegrees: number;
  82934. leftDegrees: number;
  82935. rightDegrees: number;
  82936. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  82937. /**
  82938. * Computes a complete transformation matrix
  82939. * @param viewport defines the viewport to use
  82940. * @param world defines the world matrix
  82941. * @param view defines the view matrix
  82942. * @param projection defines the projection matrix
  82943. * @param zmin defines the near clip plane
  82944. * @param zmax defines the far clip plane
  82945. * @returns the transformation matrix
  82946. */
  82947. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  82948. /**
  82949. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  82950. * @param matrix defines the matrix to use
  82951. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  82952. */
  82953. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  82954. /**
  82955. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  82956. * @param matrix defines the matrix to use
  82957. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  82958. */
  82959. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  82960. /**
  82961. * Compute the transpose of a given matrix
  82962. * @param matrix defines the matrix to transpose
  82963. * @returns the new matrix
  82964. */
  82965. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  82966. /**
  82967. * Compute the transpose of a matrix and store it in a target matrix
  82968. * @param matrix defines the matrix to transpose
  82969. * @param result defines the target matrix
  82970. */
  82971. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  82972. /**
  82973. * Computes a reflection matrix from a plane
  82974. * @param plane defines the reflection plane
  82975. * @returns a new matrix
  82976. */
  82977. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  82978. /**
  82979. * Computes a reflection matrix from a plane
  82980. * @param plane defines the reflection plane
  82981. * @param result defines the target matrix
  82982. */
  82983. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  82984. /**
  82985. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  82986. * @param xaxis defines the value of the 1st axis
  82987. * @param yaxis defines the value of the 2nd axis
  82988. * @param zaxis defines the value of the 3rd axis
  82989. * @param result defines the target matrix
  82990. */
  82991. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  82992. /**
  82993. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  82994. * @param quat defines the quaternion to use
  82995. * @param result defines the target matrix
  82996. */
  82997. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  82998. }
  82999. /**
  83000. * @hidden
  83001. */
  83002. export class TmpVectors {
  83003. static Vector2: Vector2[];
  83004. static Vector3: Vector3[];
  83005. static Vector4: Vector4[];
  83006. static Quaternion: Quaternion[];
  83007. static Matrix: Matrix[];
  83008. }
  83009. }
  83010. declare module BABYLON {
  83011. /**
  83012. * Defines potential orientation for back face culling
  83013. */
  83014. export enum Orientation {
  83015. /**
  83016. * Clockwise
  83017. */
  83018. CW = 0,
  83019. /** Counter clockwise */
  83020. CCW = 1
  83021. }
  83022. /** Class used to represent a Bezier curve */
  83023. export class BezierCurve {
  83024. /**
  83025. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83026. * @param t defines the time
  83027. * @param x1 defines the left coordinate on X axis
  83028. * @param y1 defines the left coordinate on Y axis
  83029. * @param x2 defines the right coordinate on X axis
  83030. * @param y2 defines the right coordinate on Y axis
  83031. * @returns the interpolated value
  83032. */
  83033. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83034. }
  83035. /**
  83036. * Defines angle representation
  83037. */
  83038. export class Angle {
  83039. private _radians;
  83040. /**
  83041. * Creates an Angle object of "radians" radians (float).
  83042. * @param radians the angle in radians
  83043. */
  83044. constructor(radians: number);
  83045. /**
  83046. * Get value in degrees
  83047. * @returns the Angle value in degrees (float)
  83048. */
  83049. degrees(): number;
  83050. /**
  83051. * Get value in radians
  83052. * @returns the Angle value in radians (float)
  83053. */
  83054. radians(): number;
  83055. /**
  83056. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  83057. * @param a defines first vector
  83058. * @param b defines second vector
  83059. * @returns a new Angle
  83060. */
  83061. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83062. /**
  83063. * Gets a new Angle object from the given float in radians
  83064. * @param radians defines the angle value in radians
  83065. * @returns a new Angle
  83066. */
  83067. static FromRadians(radians: number): Angle;
  83068. /**
  83069. * Gets a new Angle object from the given float in degrees
  83070. * @param degrees defines the angle value in degrees
  83071. * @returns a new Angle
  83072. */
  83073. static FromDegrees(degrees: number): Angle;
  83074. }
  83075. /**
  83076. * This represents an arc in a 2d space.
  83077. */
  83078. export class Arc2 {
  83079. /** Defines the start point of the arc */
  83080. startPoint: Vector2;
  83081. /** Defines the mid point of the arc */
  83082. midPoint: Vector2;
  83083. /** Defines the end point of the arc */
  83084. endPoint: Vector2;
  83085. /**
  83086. * Defines the center point of the arc.
  83087. */
  83088. centerPoint: Vector2;
  83089. /**
  83090. * Defines the radius of the arc.
  83091. */
  83092. radius: number;
  83093. /**
  83094. * Defines the angle of the arc (from mid point to end point).
  83095. */
  83096. angle: Angle;
  83097. /**
  83098. * Defines the start angle of the arc (from start point to middle point).
  83099. */
  83100. startAngle: Angle;
  83101. /**
  83102. * Defines the orientation of the arc (clock wise/counter clock wise).
  83103. */
  83104. orientation: Orientation;
  83105. /**
  83106. * Creates an Arc object from the three given points : start, middle and end.
  83107. * @param startPoint Defines the start point of the arc
  83108. * @param midPoint Defines the midlle point of the arc
  83109. * @param endPoint Defines the end point of the arc
  83110. */
  83111. constructor(
  83112. /** Defines the start point of the arc */
  83113. startPoint: Vector2,
  83114. /** Defines the mid point of the arc */
  83115. midPoint: Vector2,
  83116. /** Defines the end point of the arc */
  83117. endPoint: Vector2);
  83118. }
  83119. /**
  83120. * Represents a 2D path made up of multiple 2D points
  83121. */
  83122. export class Path2 {
  83123. private _points;
  83124. private _length;
  83125. /**
  83126. * If the path start and end point are the same
  83127. */
  83128. closed: boolean;
  83129. /**
  83130. * Creates a Path2 object from the starting 2D coordinates x and y.
  83131. * @param x the starting points x value
  83132. * @param y the starting points y value
  83133. */
  83134. constructor(x: number, y: number);
  83135. /**
  83136. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  83137. * @param x the added points x value
  83138. * @param y the added points y value
  83139. * @returns the updated Path2.
  83140. */
  83141. addLineTo(x: number, y: number): Path2;
  83142. /**
  83143. * 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.
  83144. * @param midX middle point x value
  83145. * @param midY middle point y value
  83146. * @param endX end point x value
  83147. * @param endY end point y value
  83148. * @param numberOfSegments (default: 36)
  83149. * @returns the updated Path2.
  83150. */
  83151. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  83152. /**
  83153. * Closes the Path2.
  83154. * @returns the Path2.
  83155. */
  83156. close(): Path2;
  83157. /**
  83158. * Gets the sum of the distance between each sequential point in the path
  83159. * @returns the Path2 total length (float).
  83160. */
  83161. length(): number;
  83162. /**
  83163. * Gets the points which construct the path
  83164. * @returns the Path2 internal array of points.
  83165. */
  83166. getPoints(): Vector2[];
  83167. /**
  83168. * Retreives the point at the distance aways from the starting point
  83169. * @param normalizedLengthPosition the length along the path to retreive the point from
  83170. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  83171. */
  83172. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  83173. /**
  83174. * Creates a new path starting from an x and y position
  83175. * @param x starting x value
  83176. * @param y starting y value
  83177. * @returns a new Path2 starting at the coordinates (x, y).
  83178. */
  83179. static StartingAt(x: number, y: number): Path2;
  83180. }
  83181. /**
  83182. * Represents a 3D path made up of multiple 3D points
  83183. */
  83184. export class Path3D {
  83185. /**
  83186. * an array of Vector3, the curve axis of the Path3D
  83187. */
  83188. path: Vector3[];
  83189. private _curve;
  83190. private _distances;
  83191. private _tangents;
  83192. private _normals;
  83193. private _binormals;
  83194. private _raw;
  83195. private _alignTangentsWithPath;
  83196. private readonly _pointAtData;
  83197. /**
  83198. * new Path3D(path, normal, raw)
  83199. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  83200. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  83201. * @param path an array of Vector3, the curve axis of the Path3D
  83202. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  83203. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  83204. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  83205. */
  83206. constructor(
  83207. /**
  83208. * an array of Vector3, the curve axis of the Path3D
  83209. */
  83210. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  83211. /**
  83212. * Returns the Path3D array of successive Vector3 designing its curve.
  83213. * @returns the Path3D array of successive Vector3 designing its curve.
  83214. */
  83215. getCurve(): Vector3[];
  83216. /**
  83217. * Returns the Path3D array of successive Vector3 designing its curve.
  83218. * @returns the Path3D array of successive Vector3 designing its curve.
  83219. */
  83220. getPoints(): Vector3[];
  83221. /**
  83222. * @returns the computed length (float) of the path.
  83223. */
  83224. length(): number;
  83225. /**
  83226. * Returns an array populated with tangent vectors on each Path3D curve point.
  83227. * @returns an array populated with tangent vectors on each Path3D curve point.
  83228. */
  83229. getTangents(): Vector3[];
  83230. /**
  83231. * Returns an array populated with normal vectors on each Path3D curve point.
  83232. * @returns an array populated with normal vectors on each Path3D curve point.
  83233. */
  83234. getNormals(): Vector3[];
  83235. /**
  83236. * Returns an array populated with binormal vectors on each Path3D curve point.
  83237. * @returns an array populated with binormal vectors on each Path3D curve point.
  83238. */
  83239. getBinormals(): Vector3[];
  83240. /**
  83241. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  83242. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  83243. */
  83244. getDistances(): number[];
  83245. /**
  83246. * Returns an interpolated point along this path
  83247. * @param position the position of the point along this path, from 0.0 to 1.0
  83248. * @returns a new Vector3 as the point
  83249. */
  83250. getPointAt(position: number): Vector3;
  83251. /**
  83252. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83253. * @param position the position of the point along this path, from 0.0 to 1.0
  83254. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  83255. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  83256. */
  83257. getTangentAt(position: number, interpolated?: boolean): Vector3;
  83258. /**
  83259. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83260. * @param position the position of the point along this path, from 0.0 to 1.0
  83261. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  83262. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  83263. */
  83264. getNormalAt(position: number, interpolated?: boolean): Vector3;
  83265. /**
  83266. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  83267. * @param position the position of the point along this path, from 0.0 to 1.0
  83268. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  83269. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  83270. */
  83271. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  83272. /**
  83273. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  83274. * @param position the position of the point along this path, from 0.0 to 1.0
  83275. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  83276. */
  83277. getDistanceAt(position: number): number;
  83278. /**
  83279. * Returns the array index of the previous point of an interpolated point along this path
  83280. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83281. * @returns the array index
  83282. */
  83283. getPreviousPointIndexAt(position: number): number;
  83284. /**
  83285. * 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)
  83286. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83287. * @returns the sub position
  83288. */
  83289. getSubPositionAt(position: number): number;
  83290. /**
  83291. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  83292. * @param target the vector of which to get the closest position to
  83293. * @returns the position of the closest virtual point on this path to the target vector
  83294. */
  83295. getClosestPositionTo(target: Vector3): number;
  83296. /**
  83297. * Returns a sub path (slice) of this path
  83298. * @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
  83299. * @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
  83300. * @returns a sub path (slice) of this path
  83301. */
  83302. slice(start?: number, end?: number): Path3D;
  83303. /**
  83304. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  83305. * @param path path which all values are copied into the curves points
  83306. * @param firstNormal which should be projected onto the curve
  83307. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  83308. * @returns the same object updated.
  83309. */
  83310. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  83311. private _compute;
  83312. private _getFirstNonNullVector;
  83313. private _getLastNonNullVector;
  83314. private _normalVector;
  83315. /**
  83316. * Updates the point at data for an interpolated point along this curve
  83317. * @param position the position of the point along this curve, from 0.0 to 1.0
  83318. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  83319. * @returns the (updated) point at data
  83320. */
  83321. private _updatePointAtData;
  83322. /**
  83323. * Updates the point at data from the specified parameters
  83324. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  83325. * @param point the interpolated point
  83326. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  83327. */
  83328. private _setPointAtData;
  83329. /**
  83330. * Updates the point at interpolation matrix for the tangents, normals and binormals
  83331. */
  83332. private _updateInterpolationMatrix;
  83333. }
  83334. /**
  83335. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83336. * A Curve3 is designed from a series of successive Vector3.
  83337. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  83338. */
  83339. export class Curve3 {
  83340. private _points;
  83341. private _length;
  83342. /**
  83343. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  83344. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  83345. * @param v1 (Vector3) the control point
  83346. * @param v2 (Vector3) the end point of the Quadratic Bezier
  83347. * @param nbPoints (integer) the wanted number of points in the curve
  83348. * @returns the created Curve3
  83349. */
  83350. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83351. /**
  83352. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  83353. * @param v0 (Vector3) the origin point of the Cubic Bezier
  83354. * @param v1 (Vector3) the first control point
  83355. * @param v2 (Vector3) the second control point
  83356. * @param v3 (Vector3) the end point of the Cubic Bezier
  83357. * @param nbPoints (integer) the wanted number of points in the curve
  83358. * @returns the created Curve3
  83359. */
  83360. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83361. /**
  83362. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  83363. * @param p1 (Vector3) the origin point of the Hermite Spline
  83364. * @param t1 (Vector3) the tangent vector at the origin point
  83365. * @param p2 (Vector3) the end point of the Hermite Spline
  83366. * @param t2 (Vector3) the tangent vector at the end point
  83367. * @param nbPoints (integer) the wanted number of points in the curve
  83368. * @returns the created Curve3
  83369. */
  83370. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83371. /**
  83372. * Returns a Curve3 object along a CatmullRom Spline curve :
  83373. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  83374. * @param nbPoints (integer) the wanted number of points between each curve control points
  83375. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  83376. * @returns the created Curve3
  83377. */
  83378. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  83379. /**
  83380. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83381. * A Curve3 is designed from a series of successive Vector3.
  83382. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  83383. * @param points points which make up the curve
  83384. */
  83385. constructor(points: Vector3[]);
  83386. /**
  83387. * @returns the Curve3 stored array of successive Vector3
  83388. */
  83389. getPoints(): Vector3[];
  83390. /**
  83391. * @returns the computed length (float) of the curve.
  83392. */
  83393. length(): number;
  83394. /**
  83395. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  83396. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  83397. * curveA and curveB keep unchanged.
  83398. * @param curve the curve to continue from this curve
  83399. * @returns the newly constructed curve
  83400. */
  83401. continue(curve: DeepImmutable<Curve3>): Curve3;
  83402. private _computeLength;
  83403. }
  83404. }
  83405. declare module BABYLON {
  83406. /**
  83407. * This represents the main contract an easing function should follow.
  83408. * Easing functions are used throughout the animation system.
  83409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83410. */
  83411. export interface IEasingFunction {
  83412. /**
  83413. * Given an input gradient between 0 and 1, this returns the corrseponding value
  83414. * of the easing function.
  83415. * The link below provides some of the most common examples of easing functions.
  83416. * @see https://easings.net/
  83417. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83418. * @returns the corresponding value on the curve defined by the easing function
  83419. */
  83420. ease(gradient: number): number;
  83421. }
  83422. /**
  83423. * Base class used for every default easing function.
  83424. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83425. */
  83426. export class EasingFunction implements IEasingFunction {
  83427. /**
  83428. * Interpolation follows the mathematical formula associated with the easing function.
  83429. */
  83430. static readonly EASINGMODE_EASEIN: number;
  83431. /**
  83432. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  83433. */
  83434. static readonly EASINGMODE_EASEOUT: number;
  83435. /**
  83436. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  83437. */
  83438. static readonly EASINGMODE_EASEINOUT: number;
  83439. private _easingMode;
  83440. /**
  83441. * Sets the easing mode of the current function.
  83442. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  83443. */
  83444. setEasingMode(easingMode: number): void;
  83445. /**
  83446. * Gets the current easing mode.
  83447. * @returns the easing mode
  83448. */
  83449. getEasingMode(): number;
  83450. /**
  83451. * @hidden
  83452. */
  83453. easeInCore(gradient: number): number;
  83454. /**
  83455. * Given an input gradient between 0 and 1, this returns the corresponding value
  83456. * of the easing function.
  83457. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83458. * @returns the corresponding value on the curve defined by the easing function
  83459. */
  83460. ease(gradient: number): number;
  83461. }
  83462. /**
  83463. * Easing function with a circle shape (see link below).
  83464. * @see https://easings.net/#easeInCirc
  83465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83466. */
  83467. export class CircleEase extends EasingFunction implements IEasingFunction {
  83468. /** @hidden */
  83469. easeInCore(gradient: number): number;
  83470. }
  83471. /**
  83472. * Easing function with a ease back shape (see link below).
  83473. * @see https://easings.net/#easeInBack
  83474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83475. */
  83476. export class BackEase extends EasingFunction implements IEasingFunction {
  83477. /** Defines the amplitude of the function */
  83478. amplitude: number;
  83479. /**
  83480. * Instantiates a back ease easing
  83481. * @see https://easings.net/#easeInBack
  83482. * @param amplitude Defines the amplitude of the function
  83483. */
  83484. constructor(
  83485. /** Defines the amplitude of the function */
  83486. amplitude?: number);
  83487. /** @hidden */
  83488. easeInCore(gradient: number): number;
  83489. }
  83490. /**
  83491. * Easing function with a bouncing shape (see link below).
  83492. * @see https://easings.net/#easeInBounce
  83493. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83494. */
  83495. export class BounceEase extends EasingFunction implements IEasingFunction {
  83496. /** Defines the number of bounces */
  83497. bounces: number;
  83498. /** Defines the amplitude of the bounce */
  83499. bounciness: number;
  83500. /**
  83501. * Instantiates a bounce easing
  83502. * @see https://easings.net/#easeInBounce
  83503. * @param bounces Defines the number of bounces
  83504. * @param bounciness Defines the amplitude of the bounce
  83505. */
  83506. constructor(
  83507. /** Defines the number of bounces */
  83508. bounces?: number,
  83509. /** Defines the amplitude of the bounce */
  83510. bounciness?: number);
  83511. /** @hidden */
  83512. easeInCore(gradient: number): number;
  83513. }
  83514. /**
  83515. * Easing function with a power of 3 shape (see link below).
  83516. * @see https://easings.net/#easeInCubic
  83517. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83518. */
  83519. export class CubicEase extends EasingFunction implements IEasingFunction {
  83520. /** @hidden */
  83521. easeInCore(gradient: number): number;
  83522. }
  83523. /**
  83524. * Easing function with an elastic shape (see link below).
  83525. * @see https://easings.net/#easeInElastic
  83526. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83527. */
  83528. export class ElasticEase extends EasingFunction implements IEasingFunction {
  83529. /** Defines the number of oscillations*/
  83530. oscillations: number;
  83531. /** Defines the amplitude of the oscillations*/
  83532. springiness: number;
  83533. /**
  83534. * Instantiates an elastic easing function
  83535. * @see https://easings.net/#easeInElastic
  83536. * @param oscillations Defines the number of oscillations
  83537. * @param springiness Defines the amplitude of the oscillations
  83538. */
  83539. constructor(
  83540. /** Defines the number of oscillations*/
  83541. oscillations?: number,
  83542. /** Defines the amplitude of the oscillations*/
  83543. springiness?: number);
  83544. /** @hidden */
  83545. easeInCore(gradient: number): number;
  83546. }
  83547. /**
  83548. * Easing function with an exponential shape (see link below).
  83549. * @see https://easings.net/#easeInExpo
  83550. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83551. */
  83552. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  83553. /** Defines the exponent of the function */
  83554. exponent: number;
  83555. /**
  83556. * Instantiates an exponential easing function
  83557. * @see https://easings.net/#easeInExpo
  83558. * @param exponent Defines the exponent of the function
  83559. */
  83560. constructor(
  83561. /** Defines the exponent of the function */
  83562. exponent?: number);
  83563. /** @hidden */
  83564. easeInCore(gradient: number): number;
  83565. }
  83566. /**
  83567. * Easing function with a power shape (see link below).
  83568. * @see https://easings.net/#easeInQuad
  83569. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83570. */
  83571. export class PowerEase extends EasingFunction implements IEasingFunction {
  83572. /** Defines the power of the function */
  83573. power: number;
  83574. /**
  83575. * Instantiates an power base easing function
  83576. * @see https://easings.net/#easeInQuad
  83577. * @param power Defines the power of the function
  83578. */
  83579. constructor(
  83580. /** Defines the power of the function */
  83581. power?: number);
  83582. /** @hidden */
  83583. easeInCore(gradient: number): number;
  83584. }
  83585. /**
  83586. * Easing function with a power of 2 shape (see link below).
  83587. * @see https://easings.net/#easeInQuad
  83588. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83589. */
  83590. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  83591. /** @hidden */
  83592. easeInCore(gradient: number): number;
  83593. }
  83594. /**
  83595. * Easing function with a power of 4 shape (see link below).
  83596. * @see https://easings.net/#easeInQuart
  83597. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83598. */
  83599. export class QuarticEase extends EasingFunction implements IEasingFunction {
  83600. /** @hidden */
  83601. easeInCore(gradient: number): number;
  83602. }
  83603. /**
  83604. * Easing function with a power of 5 shape (see link below).
  83605. * @see https://easings.net/#easeInQuint
  83606. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83607. */
  83608. export class QuinticEase extends EasingFunction implements IEasingFunction {
  83609. /** @hidden */
  83610. easeInCore(gradient: number): number;
  83611. }
  83612. /**
  83613. * Easing function with a sin shape (see link below).
  83614. * @see https://easings.net/#easeInSine
  83615. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83616. */
  83617. export class SineEase extends EasingFunction implements IEasingFunction {
  83618. /** @hidden */
  83619. easeInCore(gradient: number): number;
  83620. }
  83621. /**
  83622. * Easing function with a bezier shape (see link below).
  83623. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83624. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83625. */
  83626. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  83627. /** Defines the x component of the start tangent in the bezier curve */
  83628. x1: number;
  83629. /** Defines the y component of the start tangent in the bezier curve */
  83630. y1: number;
  83631. /** Defines the x component of the end tangent in the bezier curve */
  83632. x2: number;
  83633. /** Defines the y component of the end tangent in the bezier curve */
  83634. y2: number;
  83635. /**
  83636. * Instantiates a bezier function
  83637. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83638. * @param x1 Defines the x component of the start tangent in the bezier curve
  83639. * @param y1 Defines the y component of the start tangent in the bezier curve
  83640. * @param x2 Defines the x component of the end tangent in the bezier curve
  83641. * @param y2 Defines the y component of the end tangent in the bezier curve
  83642. */
  83643. constructor(
  83644. /** Defines the x component of the start tangent in the bezier curve */
  83645. x1?: number,
  83646. /** Defines the y component of the start tangent in the bezier curve */
  83647. y1?: number,
  83648. /** Defines the x component of the end tangent in the bezier curve */
  83649. x2?: number,
  83650. /** Defines the y component of the end tangent in the bezier curve */
  83651. y2?: number);
  83652. /** @hidden */
  83653. easeInCore(gradient: number): number;
  83654. }
  83655. }
  83656. declare module BABYLON {
  83657. /**
  83658. * Class used to hold a RBG color
  83659. */
  83660. export class Color3 {
  83661. /**
  83662. * Defines the red component (between 0 and 1, default is 0)
  83663. */
  83664. r: number;
  83665. /**
  83666. * Defines the green component (between 0 and 1, default is 0)
  83667. */
  83668. g: number;
  83669. /**
  83670. * Defines the blue component (between 0 and 1, default is 0)
  83671. */
  83672. b: number;
  83673. /**
  83674. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  83675. * @param r defines the red component (between 0 and 1, default is 0)
  83676. * @param g defines the green component (between 0 and 1, default is 0)
  83677. * @param b defines the blue component (between 0 and 1, default is 0)
  83678. */
  83679. constructor(
  83680. /**
  83681. * Defines the red component (between 0 and 1, default is 0)
  83682. */
  83683. r?: number,
  83684. /**
  83685. * Defines the green component (between 0 and 1, default is 0)
  83686. */
  83687. g?: number,
  83688. /**
  83689. * Defines the blue component (between 0 and 1, default is 0)
  83690. */
  83691. b?: number);
  83692. /**
  83693. * Creates a string with the Color3 current values
  83694. * @returns the string representation of the Color3 object
  83695. */
  83696. toString(): string;
  83697. /**
  83698. * Returns the string "Color3"
  83699. * @returns "Color3"
  83700. */
  83701. getClassName(): string;
  83702. /**
  83703. * Compute the Color3 hash code
  83704. * @returns an unique number that can be used to hash Color3 objects
  83705. */
  83706. getHashCode(): number;
  83707. /**
  83708. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  83709. * @param array defines the array where to store the r,g,b components
  83710. * @param index defines an optional index in the target array to define where to start storing values
  83711. * @returns the current Color3 object
  83712. */
  83713. toArray(array: FloatArray, index?: number): Color3;
  83714. /**
  83715. * Returns a new Color4 object from the current Color3 and the given alpha
  83716. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  83717. * @returns a new Color4 object
  83718. */
  83719. toColor4(alpha?: number): Color4;
  83720. /**
  83721. * Returns a new array populated with 3 numeric elements : red, green and blue values
  83722. * @returns the new array
  83723. */
  83724. asArray(): number[];
  83725. /**
  83726. * Returns the luminance value
  83727. * @returns a float value
  83728. */
  83729. toLuminance(): number;
  83730. /**
  83731. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  83732. * @param otherColor defines the second operand
  83733. * @returns the new Color3 object
  83734. */
  83735. multiply(otherColor: DeepImmutable<Color3>): Color3;
  83736. /**
  83737. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  83738. * @param otherColor defines the second operand
  83739. * @param result defines the Color3 object where to store the result
  83740. * @returns the current Color3
  83741. */
  83742. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83743. /**
  83744. * Determines equality between Color3 objects
  83745. * @param otherColor defines the second operand
  83746. * @returns true if the rgb values are equal to the given ones
  83747. */
  83748. equals(otherColor: DeepImmutable<Color3>): boolean;
  83749. /**
  83750. * Determines equality between the current Color3 object and a set of r,b,g values
  83751. * @param r defines the red component to check
  83752. * @param g defines the green component to check
  83753. * @param b defines the blue component to check
  83754. * @returns true if the rgb values are equal to the given ones
  83755. */
  83756. equalsFloats(r: number, g: number, b: number): boolean;
  83757. /**
  83758. * Multiplies in place each rgb value by scale
  83759. * @param scale defines the scaling factor
  83760. * @returns the updated Color3
  83761. */
  83762. scale(scale: number): Color3;
  83763. /**
  83764. * Multiplies the rgb values by scale and stores the result into "result"
  83765. * @param scale defines the scaling factor
  83766. * @param result defines the Color3 object where to store the result
  83767. * @returns the unmodified current Color3
  83768. */
  83769. scaleToRef(scale: number, result: Color3): Color3;
  83770. /**
  83771. * Scale the current Color3 values by a factor and add the result to a given Color3
  83772. * @param scale defines the scale factor
  83773. * @param result defines color to store the result into
  83774. * @returns the unmodified current Color3
  83775. */
  83776. scaleAndAddToRef(scale: number, result: Color3): Color3;
  83777. /**
  83778. * Clamps the rgb values by the min and max values and stores the result into "result"
  83779. * @param min defines minimum clamping value (default is 0)
  83780. * @param max defines maximum clamping value (default is 1)
  83781. * @param result defines color to store the result into
  83782. * @returns the original Color3
  83783. */
  83784. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  83785. /**
  83786. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  83787. * @param otherColor defines the second operand
  83788. * @returns the new Color3
  83789. */
  83790. add(otherColor: DeepImmutable<Color3>): Color3;
  83791. /**
  83792. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  83793. * @param otherColor defines the second operand
  83794. * @param result defines Color3 object to store the result into
  83795. * @returns the unmodified current Color3
  83796. */
  83797. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83798. /**
  83799. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  83800. * @param otherColor defines the second operand
  83801. * @returns the new Color3
  83802. */
  83803. subtract(otherColor: DeepImmutable<Color3>): Color3;
  83804. /**
  83805. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  83806. * @param otherColor defines the second operand
  83807. * @param result defines Color3 object to store the result into
  83808. * @returns the unmodified current Color3
  83809. */
  83810. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83811. /**
  83812. * Copy the current object
  83813. * @returns a new Color3 copied the current one
  83814. */
  83815. clone(): Color3;
  83816. /**
  83817. * Copies the rgb values from the source in the current Color3
  83818. * @param source defines the source Color3 object
  83819. * @returns the updated Color3 object
  83820. */
  83821. copyFrom(source: DeepImmutable<Color3>): Color3;
  83822. /**
  83823. * Updates the Color3 rgb values from the given floats
  83824. * @param r defines the red component to read from
  83825. * @param g defines the green component to read from
  83826. * @param b defines the blue component to read from
  83827. * @returns the current Color3 object
  83828. */
  83829. copyFromFloats(r: number, g: number, b: number): Color3;
  83830. /**
  83831. * Updates the Color3 rgb values from the given floats
  83832. * @param r defines the red component to read from
  83833. * @param g defines the green component to read from
  83834. * @param b defines the blue component to read from
  83835. * @returns the current Color3 object
  83836. */
  83837. set(r: number, g: number, b: number): Color3;
  83838. /**
  83839. * Compute the Color3 hexadecimal code as a string
  83840. * @returns a string containing the hexadecimal representation of the Color3 object
  83841. */
  83842. toHexString(): string;
  83843. /**
  83844. * Computes a new Color3 converted from the current one to linear space
  83845. * @returns a new Color3 object
  83846. */
  83847. toLinearSpace(): Color3;
  83848. /**
  83849. * Converts current color in rgb space to HSV values
  83850. * @returns a new color3 representing the HSV values
  83851. */
  83852. toHSV(): Color3;
  83853. /**
  83854. * Converts current color in rgb space to HSV values
  83855. * @param result defines the Color3 where to store the HSV values
  83856. */
  83857. toHSVToRef(result: Color3): void;
  83858. /**
  83859. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  83860. * @param convertedColor defines the Color3 object where to store the linear space version
  83861. * @returns the unmodified Color3
  83862. */
  83863. toLinearSpaceToRef(convertedColor: Color3): Color3;
  83864. /**
  83865. * Computes a new Color3 converted from the current one to gamma space
  83866. * @returns a new Color3 object
  83867. */
  83868. toGammaSpace(): Color3;
  83869. /**
  83870. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  83871. * @param convertedColor defines the Color3 object where to store the gamma space version
  83872. * @returns the unmodified Color3
  83873. */
  83874. toGammaSpaceToRef(convertedColor: Color3): Color3;
  83875. private static _BlackReadOnly;
  83876. /**
  83877. * Convert Hue, saturation and value to a Color3 (RGB)
  83878. * @param hue defines the hue
  83879. * @param saturation defines the saturation
  83880. * @param value defines the value
  83881. * @param result defines the Color3 where to store the RGB values
  83882. */
  83883. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  83884. /**
  83885. * Creates a new Color3 from the string containing valid hexadecimal values
  83886. * @param hex defines a string containing valid hexadecimal values
  83887. * @returns a new Color3 object
  83888. */
  83889. static FromHexString(hex: string): Color3;
  83890. /**
  83891. * Creates a new Color3 from the starting index of the given array
  83892. * @param array defines the source array
  83893. * @param offset defines an offset in the source array
  83894. * @returns a new Color3 object
  83895. */
  83896. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  83897. /**
  83898. * Creates a new Color3 from integer values (< 256)
  83899. * @param r defines the red component to read from (value between 0 and 255)
  83900. * @param g defines the green component to read from (value between 0 and 255)
  83901. * @param b defines the blue component to read from (value between 0 and 255)
  83902. * @returns a new Color3 object
  83903. */
  83904. static FromInts(r: number, g: number, b: number): Color3;
  83905. /**
  83906. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83907. * @param start defines the start Color3 value
  83908. * @param end defines the end Color3 value
  83909. * @param amount defines the gradient value between start and end
  83910. * @returns a new Color3 object
  83911. */
  83912. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  83913. /**
  83914. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83915. * @param left defines the start value
  83916. * @param right defines the end value
  83917. * @param amount defines the gradient factor
  83918. * @param result defines the Color3 object where to store the result
  83919. */
  83920. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  83921. /**
  83922. * Returns a Color3 value containing a red color
  83923. * @returns a new Color3 object
  83924. */
  83925. static Red(): Color3;
  83926. /**
  83927. * Returns a Color3 value containing a green color
  83928. * @returns a new Color3 object
  83929. */
  83930. static Green(): Color3;
  83931. /**
  83932. * Returns a Color3 value containing a blue color
  83933. * @returns a new Color3 object
  83934. */
  83935. static Blue(): Color3;
  83936. /**
  83937. * Returns a Color3 value containing a black color
  83938. * @returns a new Color3 object
  83939. */
  83940. static Black(): Color3;
  83941. /**
  83942. * Gets a Color3 value containing a black color that must not be updated
  83943. */
  83944. static get BlackReadOnly(): DeepImmutable<Color3>;
  83945. /**
  83946. * Returns a Color3 value containing a white color
  83947. * @returns a new Color3 object
  83948. */
  83949. static White(): Color3;
  83950. /**
  83951. * Returns a Color3 value containing a purple color
  83952. * @returns a new Color3 object
  83953. */
  83954. static Purple(): Color3;
  83955. /**
  83956. * Returns a Color3 value containing a magenta color
  83957. * @returns a new Color3 object
  83958. */
  83959. static Magenta(): Color3;
  83960. /**
  83961. * Returns a Color3 value containing a yellow color
  83962. * @returns a new Color3 object
  83963. */
  83964. static Yellow(): Color3;
  83965. /**
  83966. * Returns a Color3 value containing a gray color
  83967. * @returns a new Color3 object
  83968. */
  83969. static Gray(): Color3;
  83970. /**
  83971. * Returns a Color3 value containing a teal color
  83972. * @returns a new Color3 object
  83973. */
  83974. static Teal(): Color3;
  83975. /**
  83976. * Returns a Color3 value containing a random color
  83977. * @returns a new Color3 object
  83978. */
  83979. static Random(): Color3;
  83980. }
  83981. /**
  83982. * Class used to hold a RBGA color
  83983. */
  83984. export class Color4 {
  83985. /**
  83986. * Defines the red component (between 0 and 1, default is 0)
  83987. */
  83988. r: number;
  83989. /**
  83990. * Defines the green component (between 0 and 1, default is 0)
  83991. */
  83992. g: number;
  83993. /**
  83994. * Defines the blue component (between 0 and 1, default is 0)
  83995. */
  83996. b: number;
  83997. /**
  83998. * Defines the alpha component (between 0 and 1, default is 1)
  83999. */
  84000. a: number;
  84001. /**
  84002. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  84003. * @param r defines the red component (between 0 and 1, default is 0)
  84004. * @param g defines the green component (between 0 and 1, default is 0)
  84005. * @param b defines the blue component (between 0 and 1, default is 0)
  84006. * @param a defines the alpha component (between 0 and 1, default is 1)
  84007. */
  84008. constructor(
  84009. /**
  84010. * Defines the red component (between 0 and 1, default is 0)
  84011. */
  84012. r?: number,
  84013. /**
  84014. * Defines the green component (between 0 and 1, default is 0)
  84015. */
  84016. g?: number,
  84017. /**
  84018. * Defines the blue component (between 0 and 1, default is 0)
  84019. */
  84020. b?: number,
  84021. /**
  84022. * Defines the alpha component (between 0 and 1, default is 1)
  84023. */
  84024. a?: number);
  84025. /**
  84026. * Adds in place the given Color4 values to the current Color4 object
  84027. * @param right defines the second operand
  84028. * @returns the current updated Color4 object
  84029. */
  84030. addInPlace(right: DeepImmutable<Color4>): Color4;
  84031. /**
  84032. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84033. * @returns the new array
  84034. */
  84035. asArray(): number[];
  84036. /**
  84037. * Stores from the starting index in the given array the Color4 successive values
  84038. * @param array defines the array where to store the r,g,b components
  84039. * @param index defines an optional index in the target array to define where to start storing values
  84040. * @returns the current Color4 object
  84041. */
  84042. toArray(array: number[], index?: number): Color4;
  84043. /**
  84044. * Determines equality between Color4 objects
  84045. * @param otherColor defines the second operand
  84046. * @returns true if the rgba values are equal to the given ones
  84047. */
  84048. equals(otherColor: DeepImmutable<Color4>): boolean;
  84049. /**
  84050. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84051. * @param right defines the second operand
  84052. * @returns a new Color4 object
  84053. */
  84054. add(right: DeepImmutable<Color4>): Color4;
  84055. /**
  84056. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84057. * @param right defines the second operand
  84058. * @returns a new Color4 object
  84059. */
  84060. subtract(right: DeepImmutable<Color4>): Color4;
  84061. /**
  84062. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84063. * @param right defines the second operand
  84064. * @param result defines the Color4 object where to store the result
  84065. * @returns the current Color4 object
  84066. */
  84067. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84068. /**
  84069. * Creates a new Color4 with the current Color4 values multiplied by scale
  84070. * @param scale defines the scaling factor to apply
  84071. * @returns a new Color4 object
  84072. */
  84073. scale(scale: number): Color4;
  84074. /**
  84075. * Multiplies the current Color4 values by scale and stores the result in "result"
  84076. * @param scale defines the scaling factor to apply
  84077. * @param result defines the Color4 object where to store the result
  84078. * @returns the current unmodified Color4
  84079. */
  84080. scaleToRef(scale: number, result: Color4): Color4;
  84081. /**
  84082. * Scale the current Color4 values by a factor and add the result to a given Color4
  84083. * @param scale defines the scale factor
  84084. * @param result defines the Color4 object where to store the result
  84085. * @returns the unmodified current Color4
  84086. */
  84087. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84088. /**
  84089. * Clamps the rgb values by the min and max values and stores the result into "result"
  84090. * @param min defines minimum clamping value (default is 0)
  84091. * @param max defines maximum clamping value (default is 1)
  84092. * @param result defines color to store the result into.
  84093. * @returns the cuurent Color4
  84094. */
  84095. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84096. /**
  84097. * Multipy an Color4 value by another and return a new Color4 object
  84098. * @param color defines the Color4 value to multiply by
  84099. * @returns a new Color4 object
  84100. */
  84101. multiply(color: Color4): Color4;
  84102. /**
  84103. * Multipy a Color4 value by another and push the result in a reference value
  84104. * @param color defines the Color4 value to multiply by
  84105. * @param result defines the Color4 to fill the result in
  84106. * @returns the result Color4
  84107. */
  84108. multiplyToRef(color: Color4, result: Color4): Color4;
  84109. /**
  84110. * Creates a string with the Color4 current values
  84111. * @returns the string representation of the Color4 object
  84112. */
  84113. toString(): string;
  84114. /**
  84115. * Returns the string "Color4"
  84116. * @returns "Color4"
  84117. */
  84118. getClassName(): string;
  84119. /**
  84120. * Compute the Color4 hash code
  84121. * @returns an unique number that can be used to hash Color4 objects
  84122. */
  84123. getHashCode(): number;
  84124. /**
  84125. * Creates a new Color4 copied from the current one
  84126. * @returns a new Color4 object
  84127. */
  84128. clone(): Color4;
  84129. /**
  84130. * Copies the given Color4 values into the current one
  84131. * @param source defines the source Color4 object
  84132. * @returns the current updated Color4 object
  84133. */
  84134. copyFrom(source: Color4): Color4;
  84135. /**
  84136. * Copies the given float values into the current one
  84137. * @param r defines the red component to read from
  84138. * @param g defines the green component to read from
  84139. * @param b defines the blue component to read from
  84140. * @param a defines the alpha component to read from
  84141. * @returns the current updated Color4 object
  84142. */
  84143. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  84144. /**
  84145. * Copies the given float values into the current one
  84146. * @param r defines the red component to read from
  84147. * @param g defines the green component to read from
  84148. * @param b defines the blue component to read from
  84149. * @param a defines the alpha component to read from
  84150. * @returns the current updated Color4 object
  84151. */
  84152. set(r: number, g: number, b: number, a: number): Color4;
  84153. /**
  84154. * Compute the Color4 hexadecimal code as a string
  84155. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  84156. * @returns a string containing the hexadecimal representation of the Color4 object
  84157. */
  84158. toHexString(returnAsColor3?: boolean): string;
  84159. /**
  84160. * Computes a new Color4 converted from the current one to linear space
  84161. * @returns a new Color4 object
  84162. */
  84163. toLinearSpace(): Color4;
  84164. /**
  84165. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  84166. * @param convertedColor defines the Color4 object where to store the linear space version
  84167. * @returns the unmodified Color4
  84168. */
  84169. toLinearSpaceToRef(convertedColor: Color4): Color4;
  84170. /**
  84171. * Computes a new Color4 converted from the current one to gamma space
  84172. * @returns a new Color4 object
  84173. */
  84174. toGammaSpace(): Color4;
  84175. /**
  84176. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  84177. * @param convertedColor defines the Color4 object where to store the gamma space version
  84178. * @returns the unmodified Color4
  84179. */
  84180. toGammaSpaceToRef(convertedColor: Color4): Color4;
  84181. /**
  84182. * Creates a new Color4 from the string containing valid hexadecimal values
  84183. * @param hex defines a string containing valid hexadecimal values
  84184. * @returns a new Color4 object
  84185. */
  84186. static FromHexString(hex: string): Color4;
  84187. /**
  84188. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84189. * @param left defines the start value
  84190. * @param right defines the end value
  84191. * @param amount defines the gradient factor
  84192. * @returns a new Color4 object
  84193. */
  84194. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  84195. /**
  84196. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84197. * @param left defines the start value
  84198. * @param right defines the end value
  84199. * @param amount defines the gradient factor
  84200. * @param result defines the Color4 object where to store data
  84201. */
  84202. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  84203. /**
  84204. * Creates a new Color4 from a Color3 and an alpha value
  84205. * @param color3 defines the source Color3 to read from
  84206. * @param alpha defines the alpha component (1.0 by default)
  84207. * @returns a new Color4 object
  84208. */
  84209. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  84210. /**
  84211. * Creates a new Color4 from the starting index element of the given array
  84212. * @param array defines the source array to read from
  84213. * @param offset defines the offset in the source array
  84214. * @returns a new Color4 object
  84215. */
  84216. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84217. /**
  84218. * Creates a new Color3 from integer values (< 256)
  84219. * @param r defines the red component to read from (value between 0 and 255)
  84220. * @param g defines the green component to read from (value between 0 and 255)
  84221. * @param b defines the blue component to read from (value between 0 and 255)
  84222. * @param a defines the alpha component to read from (value between 0 and 255)
  84223. * @returns a new Color3 object
  84224. */
  84225. static FromInts(r: number, g: number, b: number, a: number): Color4;
  84226. /**
  84227. * Check the content of a given array and convert it to an array containing RGBA data
  84228. * If the original array was already containing count * 4 values then it is returned directly
  84229. * @param colors defines the array to check
  84230. * @param count defines the number of RGBA data to expect
  84231. * @returns an array containing count * 4 values (RGBA)
  84232. */
  84233. static CheckColors4(colors: number[], count: number): number[];
  84234. }
  84235. /**
  84236. * @hidden
  84237. */
  84238. export class TmpColors {
  84239. static Color3: Color3[];
  84240. static Color4: Color4[];
  84241. }
  84242. }
  84243. declare module BABYLON {
  84244. /**
  84245. * Defines an interface which represents an animation key frame
  84246. */
  84247. export interface IAnimationKey {
  84248. /**
  84249. * Frame of the key frame
  84250. */
  84251. frame: number;
  84252. /**
  84253. * Value at the specifies key frame
  84254. */
  84255. value: any;
  84256. /**
  84257. * The input tangent for the cubic hermite spline
  84258. */
  84259. inTangent?: any;
  84260. /**
  84261. * The output tangent for the cubic hermite spline
  84262. */
  84263. outTangent?: any;
  84264. /**
  84265. * The animation interpolation type
  84266. */
  84267. interpolation?: AnimationKeyInterpolation;
  84268. }
  84269. /**
  84270. * Enum for the animation key frame interpolation type
  84271. */
  84272. export enum AnimationKeyInterpolation {
  84273. /**
  84274. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  84275. */
  84276. STEP = 1
  84277. }
  84278. }
  84279. declare module BABYLON {
  84280. /**
  84281. * Represents the range of an animation
  84282. */
  84283. export class AnimationRange {
  84284. /**The name of the animation range**/
  84285. name: string;
  84286. /**The starting frame of the animation */
  84287. from: number;
  84288. /**The ending frame of the animation*/
  84289. to: number;
  84290. /**
  84291. * Initializes the range of an animation
  84292. * @param name The name of the animation range
  84293. * @param from The starting frame of the animation
  84294. * @param to The ending frame of the animation
  84295. */
  84296. constructor(
  84297. /**The name of the animation range**/
  84298. name: string,
  84299. /**The starting frame of the animation */
  84300. from: number,
  84301. /**The ending frame of the animation*/
  84302. to: number);
  84303. /**
  84304. * Makes a copy of the animation range
  84305. * @returns A copy of the animation range
  84306. */
  84307. clone(): AnimationRange;
  84308. }
  84309. }
  84310. declare module BABYLON {
  84311. /**
  84312. * Composed of a frame, and an action function
  84313. */
  84314. export class AnimationEvent {
  84315. /** The frame for which the event is triggered **/
  84316. frame: number;
  84317. /** The event to perform when triggered **/
  84318. action: (currentFrame: number) => void;
  84319. /** Specifies if the event should be triggered only once**/
  84320. onlyOnce?: boolean | undefined;
  84321. /**
  84322. * Specifies if the animation event is done
  84323. */
  84324. isDone: boolean;
  84325. /**
  84326. * Initializes the animation event
  84327. * @param frame The frame for which the event is triggered
  84328. * @param action The event to perform when triggered
  84329. * @param onlyOnce Specifies if the event should be triggered only once
  84330. */
  84331. constructor(
  84332. /** The frame for which the event is triggered **/
  84333. frame: number,
  84334. /** The event to perform when triggered **/
  84335. action: (currentFrame: number) => void,
  84336. /** Specifies if the event should be triggered only once**/
  84337. onlyOnce?: boolean | undefined);
  84338. /** @hidden */
  84339. _clone(): AnimationEvent;
  84340. }
  84341. }
  84342. declare module BABYLON {
  84343. /**
  84344. * Interface used to define a behavior
  84345. */
  84346. export interface Behavior<T> {
  84347. /** gets or sets behavior's name */
  84348. name: string;
  84349. /**
  84350. * Function called when the behavior needs to be initialized (after attaching it to a target)
  84351. */
  84352. init(): void;
  84353. /**
  84354. * Called when the behavior is attached to a target
  84355. * @param target defines the target where the behavior is attached to
  84356. */
  84357. attach(target: T): void;
  84358. /**
  84359. * Called when the behavior is detached from its target
  84360. */
  84361. detach(): void;
  84362. }
  84363. /**
  84364. * Interface implemented by classes supporting behaviors
  84365. */
  84366. export interface IBehaviorAware<T> {
  84367. /**
  84368. * Attach a behavior
  84369. * @param behavior defines the behavior to attach
  84370. * @returns the current host
  84371. */
  84372. addBehavior(behavior: Behavior<T>): T;
  84373. /**
  84374. * Remove a behavior from the current object
  84375. * @param behavior defines the behavior to detach
  84376. * @returns the current host
  84377. */
  84378. removeBehavior(behavior: Behavior<T>): T;
  84379. /**
  84380. * Gets a behavior using its name to search
  84381. * @param name defines the name to search
  84382. * @returns the behavior or null if not found
  84383. */
  84384. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  84385. }
  84386. }
  84387. declare module BABYLON {
  84388. /**
  84389. * Defines an array and its length.
  84390. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  84391. */
  84392. export interface ISmartArrayLike<T> {
  84393. /**
  84394. * The data of the array.
  84395. */
  84396. data: Array<T>;
  84397. /**
  84398. * The active length of the array.
  84399. */
  84400. length: number;
  84401. }
  84402. /**
  84403. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84404. */
  84405. export class SmartArray<T> implements ISmartArrayLike<T> {
  84406. /**
  84407. * The full set of data from the array.
  84408. */
  84409. data: Array<T>;
  84410. /**
  84411. * The active length of the array.
  84412. */
  84413. length: number;
  84414. protected _id: number;
  84415. /**
  84416. * Instantiates a Smart Array.
  84417. * @param capacity defines the default capacity of the array.
  84418. */
  84419. constructor(capacity: number);
  84420. /**
  84421. * Pushes a value at the end of the active data.
  84422. * @param value defines the object to push in the array.
  84423. */
  84424. push(value: T): void;
  84425. /**
  84426. * Iterates over the active data and apply the lambda to them.
  84427. * @param func defines the action to apply on each value.
  84428. */
  84429. forEach(func: (content: T) => void): void;
  84430. /**
  84431. * Sorts the full sets of data.
  84432. * @param compareFn defines the comparison function to apply.
  84433. */
  84434. sort(compareFn: (a: T, b: T) => number): void;
  84435. /**
  84436. * Resets the active data to an empty array.
  84437. */
  84438. reset(): void;
  84439. /**
  84440. * Releases all the data from the array as well as the array.
  84441. */
  84442. dispose(): void;
  84443. /**
  84444. * Concats the active data with a given array.
  84445. * @param array defines the data to concatenate with.
  84446. */
  84447. concat(array: any): void;
  84448. /**
  84449. * Returns the position of a value in the active data.
  84450. * @param value defines the value to find the index for
  84451. * @returns the index if found in the active data otherwise -1
  84452. */
  84453. indexOf(value: T): number;
  84454. /**
  84455. * Returns whether an element is part of the active data.
  84456. * @param value defines the value to look for
  84457. * @returns true if found in the active data otherwise false
  84458. */
  84459. contains(value: T): boolean;
  84460. private static _GlobalId;
  84461. }
  84462. /**
  84463. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84464. * The data in this array can only be present once
  84465. */
  84466. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  84467. private _duplicateId;
  84468. /**
  84469. * Pushes a value at the end of the active data.
  84470. * THIS DOES NOT PREVENT DUPPLICATE DATA
  84471. * @param value defines the object to push in the array.
  84472. */
  84473. push(value: T): void;
  84474. /**
  84475. * Pushes a value at the end of the active data.
  84476. * If the data is already present, it won t be added again
  84477. * @param value defines the object to push in the array.
  84478. * @returns true if added false if it was already present
  84479. */
  84480. pushNoDuplicate(value: T): boolean;
  84481. /**
  84482. * Resets the active data to an empty array.
  84483. */
  84484. reset(): void;
  84485. /**
  84486. * Concats the active data with a given array.
  84487. * This ensures no dupplicate will be present in the result.
  84488. * @param array defines the data to concatenate with.
  84489. */
  84490. concatWithNoDuplicate(array: any): void;
  84491. }
  84492. }
  84493. declare module BABYLON {
  84494. /**
  84495. * @ignore
  84496. * This is a list of all the different input types that are available in the application.
  84497. * Fo instance: ArcRotateCameraGamepadInput...
  84498. */
  84499. export var CameraInputTypes: {};
  84500. /**
  84501. * This is the contract to implement in order to create a new input class.
  84502. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  84503. */
  84504. export interface ICameraInput<TCamera extends Camera> {
  84505. /**
  84506. * Defines the camera the input is attached to.
  84507. */
  84508. camera: Nullable<TCamera>;
  84509. /**
  84510. * Gets the class name of the current intput.
  84511. * @returns the class name
  84512. */
  84513. getClassName(): string;
  84514. /**
  84515. * Get the friendly name associated with the input class.
  84516. * @returns the input friendly name
  84517. */
  84518. getSimpleName(): string;
  84519. /**
  84520. * Attach the input controls to a specific dom element to get the input from.
  84521. * @param element Defines the element the controls should be listened from
  84522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84523. */
  84524. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84525. /**
  84526. * Detach the current controls from the specified dom element.
  84527. * @param element Defines the element to stop listening the inputs from
  84528. */
  84529. detachControl(element: Nullable<HTMLElement>): void;
  84530. /**
  84531. * Update the current camera state depending on the inputs that have been used this frame.
  84532. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84533. */
  84534. checkInputs?: () => void;
  84535. }
  84536. /**
  84537. * Represents a map of input types to input instance or input index to input instance.
  84538. */
  84539. export interface CameraInputsMap<TCamera extends Camera> {
  84540. /**
  84541. * Accessor to the input by input type.
  84542. */
  84543. [name: string]: ICameraInput<TCamera>;
  84544. /**
  84545. * Accessor to the input by input index.
  84546. */
  84547. [idx: number]: ICameraInput<TCamera>;
  84548. }
  84549. /**
  84550. * This represents the input manager used within a camera.
  84551. * It helps dealing with all the different kind of input attached to a camera.
  84552. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84553. */
  84554. export class CameraInputsManager<TCamera extends Camera> {
  84555. /**
  84556. * Defines the list of inputs attahed to the camera.
  84557. */
  84558. attached: CameraInputsMap<TCamera>;
  84559. /**
  84560. * Defines the dom element the camera is collecting inputs from.
  84561. * This is null if the controls have not been attached.
  84562. */
  84563. attachedElement: Nullable<HTMLElement>;
  84564. /**
  84565. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84566. */
  84567. noPreventDefault: boolean;
  84568. /**
  84569. * Defined the camera the input manager belongs to.
  84570. */
  84571. camera: TCamera;
  84572. /**
  84573. * Update the current camera state depending on the inputs that have been used this frame.
  84574. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84575. */
  84576. checkInputs: () => void;
  84577. /**
  84578. * Instantiate a new Camera Input Manager.
  84579. * @param camera Defines the camera the input manager blongs to
  84580. */
  84581. constructor(camera: TCamera);
  84582. /**
  84583. * Add an input method to a camera
  84584. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84585. * @param input camera input method
  84586. */
  84587. add(input: ICameraInput<TCamera>): void;
  84588. /**
  84589. * Remove a specific input method from a camera
  84590. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  84591. * @param inputToRemove camera input method
  84592. */
  84593. remove(inputToRemove: ICameraInput<TCamera>): void;
  84594. /**
  84595. * Remove a specific input type from a camera
  84596. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  84597. * @param inputType the type of the input to remove
  84598. */
  84599. removeByType(inputType: string): void;
  84600. private _addCheckInputs;
  84601. /**
  84602. * Attach the input controls to the currently attached dom element to listen the events from.
  84603. * @param input Defines the input to attach
  84604. */
  84605. attachInput(input: ICameraInput<TCamera>): void;
  84606. /**
  84607. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  84608. * @param element Defines the dom element to collect the events from
  84609. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84610. */
  84611. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  84612. /**
  84613. * Detach the current manager inputs controls from a specific dom element.
  84614. * @param element Defines the dom element to collect the events from
  84615. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  84616. */
  84617. detachElement(element: HTMLElement, disconnect?: boolean): void;
  84618. /**
  84619. * Rebuild the dynamic inputCheck function from the current list of
  84620. * defined inputs in the manager.
  84621. */
  84622. rebuildInputCheck(): void;
  84623. /**
  84624. * Remove all attached input methods from a camera
  84625. */
  84626. clear(): void;
  84627. /**
  84628. * Serialize the current input manager attached to a camera.
  84629. * This ensures than once parsed,
  84630. * the input associated to the camera will be identical to the current ones
  84631. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  84632. */
  84633. serialize(serializedCamera: any): void;
  84634. /**
  84635. * Parses an input manager serialized JSON to restore the previous list of inputs
  84636. * and states associated to a camera.
  84637. * @param parsedCamera Defines the JSON to parse
  84638. */
  84639. parse(parsedCamera: any): void;
  84640. }
  84641. }
  84642. declare module BABYLON {
  84643. /**
  84644. * Class used to store data that will be store in GPU memory
  84645. */
  84646. export class Buffer {
  84647. private _engine;
  84648. private _buffer;
  84649. /** @hidden */
  84650. _data: Nullable<DataArray>;
  84651. private _updatable;
  84652. private _instanced;
  84653. private _divisor;
  84654. /**
  84655. * Gets the byte stride.
  84656. */
  84657. readonly byteStride: number;
  84658. /**
  84659. * Constructor
  84660. * @param engine the engine
  84661. * @param data the data to use for this buffer
  84662. * @param updatable whether the data is updatable
  84663. * @param stride the stride (optional)
  84664. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84665. * @param instanced whether the buffer is instanced (optional)
  84666. * @param useBytes set to true if the stride in in bytes (optional)
  84667. * @param divisor sets an optional divisor for instances (1 by default)
  84668. */
  84669. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  84670. /**
  84671. * Create a new VertexBuffer based on the current buffer
  84672. * @param kind defines the vertex buffer kind (position, normal, etc.)
  84673. * @param offset defines offset in the buffer (0 by default)
  84674. * @param size defines the size in floats of attributes (position is 3 for instance)
  84675. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  84676. * @param instanced defines if the vertex buffer contains indexed data
  84677. * @param useBytes defines if the offset and stride are in bytes *
  84678. * @param divisor sets an optional divisor for instances (1 by default)
  84679. * @returns the new vertex buffer
  84680. */
  84681. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  84682. /**
  84683. * Gets a boolean indicating if the Buffer is updatable?
  84684. * @returns true if the buffer is updatable
  84685. */
  84686. isUpdatable(): boolean;
  84687. /**
  84688. * Gets current buffer's data
  84689. * @returns a DataArray or null
  84690. */
  84691. getData(): Nullable<DataArray>;
  84692. /**
  84693. * Gets underlying native buffer
  84694. * @returns underlying native buffer
  84695. */
  84696. getBuffer(): Nullable<DataBuffer>;
  84697. /**
  84698. * Gets the stride in float32 units (i.e. byte stride / 4).
  84699. * May not be an integer if the byte stride is not divisible by 4.
  84700. * @returns the stride in float32 units
  84701. * @deprecated Please use byteStride instead.
  84702. */
  84703. getStrideSize(): number;
  84704. /**
  84705. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84706. * @param data defines the data to store
  84707. */
  84708. create(data?: Nullable<DataArray>): void;
  84709. /** @hidden */
  84710. _rebuild(): void;
  84711. /**
  84712. * Update current buffer data
  84713. * @param data defines the data to store
  84714. */
  84715. update(data: DataArray): void;
  84716. /**
  84717. * Updates the data directly.
  84718. * @param data the new data
  84719. * @param offset the new offset
  84720. * @param vertexCount the vertex count (optional)
  84721. * @param useBytes set to true if the offset is in bytes
  84722. */
  84723. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  84724. /**
  84725. * Release all resources
  84726. */
  84727. dispose(): void;
  84728. }
  84729. /**
  84730. * Specialized buffer used to store vertex data
  84731. */
  84732. export class VertexBuffer {
  84733. /** @hidden */
  84734. _buffer: Buffer;
  84735. private _kind;
  84736. private _size;
  84737. private _ownsBuffer;
  84738. private _instanced;
  84739. private _instanceDivisor;
  84740. /**
  84741. * The byte type.
  84742. */
  84743. static readonly BYTE: number;
  84744. /**
  84745. * The unsigned byte type.
  84746. */
  84747. static readonly UNSIGNED_BYTE: number;
  84748. /**
  84749. * The short type.
  84750. */
  84751. static readonly SHORT: number;
  84752. /**
  84753. * The unsigned short type.
  84754. */
  84755. static readonly UNSIGNED_SHORT: number;
  84756. /**
  84757. * The integer type.
  84758. */
  84759. static readonly INT: number;
  84760. /**
  84761. * The unsigned integer type.
  84762. */
  84763. static readonly UNSIGNED_INT: number;
  84764. /**
  84765. * The float type.
  84766. */
  84767. static readonly FLOAT: number;
  84768. /**
  84769. * Gets or sets the instance divisor when in instanced mode
  84770. */
  84771. get instanceDivisor(): number;
  84772. set instanceDivisor(value: number);
  84773. /**
  84774. * Gets the byte stride.
  84775. */
  84776. readonly byteStride: number;
  84777. /**
  84778. * Gets the byte offset.
  84779. */
  84780. readonly byteOffset: number;
  84781. /**
  84782. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  84783. */
  84784. readonly normalized: boolean;
  84785. /**
  84786. * Gets the data type of each component in the array.
  84787. */
  84788. readonly type: number;
  84789. /**
  84790. * Constructor
  84791. * @param engine the engine
  84792. * @param data the data to use for this vertex buffer
  84793. * @param kind the vertex buffer kind
  84794. * @param updatable whether the data is updatable
  84795. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84796. * @param stride the stride (optional)
  84797. * @param instanced whether the buffer is instanced (optional)
  84798. * @param offset the offset of the data (optional)
  84799. * @param size the number of components (optional)
  84800. * @param type the type of the component (optional)
  84801. * @param normalized whether the data contains normalized data (optional)
  84802. * @param useBytes set to true if stride and offset are in bytes (optional)
  84803. * @param divisor defines the instance divisor to use (1 by default)
  84804. */
  84805. 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);
  84806. /** @hidden */
  84807. _rebuild(): void;
  84808. /**
  84809. * Returns the kind of the VertexBuffer (string)
  84810. * @returns a string
  84811. */
  84812. getKind(): string;
  84813. /**
  84814. * Gets a boolean indicating if the VertexBuffer is updatable?
  84815. * @returns true if the buffer is updatable
  84816. */
  84817. isUpdatable(): boolean;
  84818. /**
  84819. * Gets current buffer's data
  84820. * @returns a DataArray or null
  84821. */
  84822. getData(): Nullable<DataArray>;
  84823. /**
  84824. * Gets underlying native buffer
  84825. * @returns underlying native buffer
  84826. */
  84827. getBuffer(): Nullable<DataBuffer>;
  84828. /**
  84829. * Gets the stride in float32 units (i.e. byte stride / 4).
  84830. * May not be an integer if the byte stride is not divisible by 4.
  84831. * @returns the stride in float32 units
  84832. * @deprecated Please use byteStride instead.
  84833. */
  84834. getStrideSize(): number;
  84835. /**
  84836. * Returns the offset as a multiple of the type byte length.
  84837. * @returns the offset in bytes
  84838. * @deprecated Please use byteOffset instead.
  84839. */
  84840. getOffset(): number;
  84841. /**
  84842. * Returns the number of components per vertex attribute (integer)
  84843. * @returns the size in float
  84844. */
  84845. getSize(): number;
  84846. /**
  84847. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84848. * @returns true if this buffer is instanced
  84849. */
  84850. getIsInstanced(): boolean;
  84851. /**
  84852. * Returns the instancing divisor, zero for non-instanced (integer).
  84853. * @returns a number
  84854. */
  84855. getInstanceDivisor(): number;
  84856. /**
  84857. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84858. * @param data defines the data to store
  84859. */
  84860. create(data?: DataArray): void;
  84861. /**
  84862. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  84863. * This function will create a new buffer if the current one is not updatable
  84864. * @param data defines the data to store
  84865. */
  84866. update(data: DataArray): void;
  84867. /**
  84868. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  84869. * Returns the directly updated WebGLBuffer.
  84870. * @param data the new data
  84871. * @param offset the new offset
  84872. * @param useBytes set to true if the offset is in bytes
  84873. */
  84874. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  84875. /**
  84876. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  84877. */
  84878. dispose(): void;
  84879. /**
  84880. * Enumerates each value of this vertex buffer as numbers.
  84881. * @param count the number of values to enumerate
  84882. * @param callback the callback function called for each value
  84883. */
  84884. forEach(count: number, callback: (value: number, index: number) => void): void;
  84885. /**
  84886. * Positions
  84887. */
  84888. static readonly PositionKind: string;
  84889. /**
  84890. * Normals
  84891. */
  84892. static readonly NormalKind: string;
  84893. /**
  84894. * Tangents
  84895. */
  84896. static readonly TangentKind: string;
  84897. /**
  84898. * Texture coordinates
  84899. */
  84900. static readonly UVKind: string;
  84901. /**
  84902. * Texture coordinates 2
  84903. */
  84904. static readonly UV2Kind: string;
  84905. /**
  84906. * Texture coordinates 3
  84907. */
  84908. static readonly UV3Kind: string;
  84909. /**
  84910. * Texture coordinates 4
  84911. */
  84912. static readonly UV4Kind: string;
  84913. /**
  84914. * Texture coordinates 5
  84915. */
  84916. static readonly UV5Kind: string;
  84917. /**
  84918. * Texture coordinates 6
  84919. */
  84920. static readonly UV6Kind: string;
  84921. /**
  84922. * Colors
  84923. */
  84924. static readonly ColorKind: string;
  84925. /**
  84926. * Matrix indices (for bones)
  84927. */
  84928. static readonly MatricesIndicesKind: string;
  84929. /**
  84930. * Matrix weights (for bones)
  84931. */
  84932. static readonly MatricesWeightsKind: string;
  84933. /**
  84934. * Additional matrix indices (for bones)
  84935. */
  84936. static readonly MatricesIndicesExtraKind: string;
  84937. /**
  84938. * Additional matrix weights (for bones)
  84939. */
  84940. static readonly MatricesWeightsExtraKind: string;
  84941. /**
  84942. * Deduces the stride given a kind.
  84943. * @param kind The kind string to deduce
  84944. * @returns The deduced stride
  84945. */
  84946. static DeduceStride(kind: string): number;
  84947. /**
  84948. * Gets the byte length of the given type.
  84949. * @param type the type
  84950. * @returns the number of bytes
  84951. */
  84952. static GetTypeByteLength(type: number): number;
  84953. /**
  84954. * Enumerates each value of the given parameters as numbers.
  84955. * @param data the data to enumerate
  84956. * @param byteOffset the byte offset of the data
  84957. * @param byteStride the byte stride of the data
  84958. * @param componentCount the number of components per element
  84959. * @param componentType the type of the component
  84960. * @param count the number of values to enumerate
  84961. * @param normalized whether the data is normalized
  84962. * @param callback the callback function called for each value
  84963. */
  84964. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  84965. private static _GetFloatValue;
  84966. }
  84967. }
  84968. declare module BABYLON {
  84969. /**
  84970. * @hidden
  84971. */
  84972. export class IntersectionInfo {
  84973. bu: Nullable<number>;
  84974. bv: Nullable<number>;
  84975. distance: number;
  84976. faceId: number;
  84977. subMeshId: number;
  84978. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  84979. }
  84980. }
  84981. declare module BABYLON {
  84982. /**
  84983. * Class used to store bounding sphere information
  84984. */
  84985. export class BoundingSphere {
  84986. /**
  84987. * Gets the center of the bounding sphere in local space
  84988. */
  84989. readonly center: Vector3;
  84990. /**
  84991. * Radius of the bounding sphere in local space
  84992. */
  84993. radius: number;
  84994. /**
  84995. * Gets the center of the bounding sphere in world space
  84996. */
  84997. readonly centerWorld: Vector3;
  84998. /**
  84999. * Radius of the bounding sphere in world space
  85000. */
  85001. radiusWorld: number;
  85002. /**
  85003. * Gets the minimum vector in local space
  85004. */
  85005. readonly minimum: Vector3;
  85006. /**
  85007. * Gets the maximum vector in local space
  85008. */
  85009. readonly maximum: Vector3;
  85010. private _worldMatrix;
  85011. private static readonly TmpVector3;
  85012. /**
  85013. * Creates a new bounding sphere
  85014. * @param min defines the minimum vector (in local space)
  85015. * @param max defines the maximum vector (in local space)
  85016. * @param worldMatrix defines the new world matrix
  85017. */
  85018. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85019. /**
  85020. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85021. * @param min defines the new minimum vector (in local space)
  85022. * @param max defines the new maximum vector (in local space)
  85023. * @param worldMatrix defines the new world matrix
  85024. */
  85025. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85026. /**
  85027. * Scale the current bounding sphere by applying a scale factor
  85028. * @param factor defines the scale factor to apply
  85029. * @returns the current bounding box
  85030. */
  85031. scale(factor: number): BoundingSphere;
  85032. /**
  85033. * Gets the world matrix of the bounding box
  85034. * @returns a matrix
  85035. */
  85036. getWorldMatrix(): DeepImmutable<Matrix>;
  85037. /** @hidden */
  85038. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85039. /**
  85040. * Tests if the bounding sphere is intersecting the frustum planes
  85041. * @param frustumPlanes defines the frustum planes to test
  85042. * @returns true if there is an intersection
  85043. */
  85044. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85045. /**
  85046. * Tests if the bounding sphere center is in between the frustum planes.
  85047. * Used for optimistic fast inclusion.
  85048. * @param frustumPlanes defines the frustum planes to test
  85049. * @returns true if the sphere center is in between the frustum planes
  85050. */
  85051. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85052. /**
  85053. * Tests if a point is inside the bounding sphere
  85054. * @param point defines the point to test
  85055. * @returns true if the point is inside the bounding sphere
  85056. */
  85057. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85058. /**
  85059. * Checks if two sphere intersct
  85060. * @param sphere0 sphere 0
  85061. * @param sphere1 sphere 1
  85062. * @returns true if the speres intersect
  85063. */
  85064. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85065. }
  85066. }
  85067. declare module BABYLON {
  85068. /**
  85069. * Class used to store bounding box information
  85070. */
  85071. export class BoundingBox implements ICullable {
  85072. /**
  85073. * Gets the 8 vectors representing the bounding box in local space
  85074. */
  85075. readonly vectors: Vector3[];
  85076. /**
  85077. * Gets the center of the bounding box in local space
  85078. */
  85079. readonly center: Vector3;
  85080. /**
  85081. * Gets the center of the bounding box in world space
  85082. */
  85083. readonly centerWorld: Vector3;
  85084. /**
  85085. * Gets the extend size in local space
  85086. */
  85087. readonly extendSize: Vector3;
  85088. /**
  85089. * Gets the extend size in world space
  85090. */
  85091. readonly extendSizeWorld: Vector3;
  85092. /**
  85093. * Gets the OBB (object bounding box) directions
  85094. */
  85095. readonly directions: Vector3[];
  85096. /**
  85097. * Gets the 8 vectors representing the bounding box in world space
  85098. */
  85099. readonly vectorsWorld: Vector3[];
  85100. /**
  85101. * Gets the minimum vector in world space
  85102. */
  85103. readonly minimumWorld: Vector3;
  85104. /**
  85105. * Gets the maximum vector in world space
  85106. */
  85107. readonly maximumWorld: Vector3;
  85108. /**
  85109. * Gets the minimum vector in local space
  85110. */
  85111. readonly minimum: Vector3;
  85112. /**
  85113. * Gets the maximum vector in local space
  85114. */
  85115. readonly maximum: Vector3;
  85116. private _worldMatrix;
  85117. private static readonly TmpVector3;
  85118. /**
  85119. * @hidden
  85120. */
  85121. _tag: number;
  85122. /**
  85123. * Creates a new bounding box
  85124. * @param min defines the minimum vector (in local space)
  85125. * @param max defines the maximum vector (in local space)
  85126. * @param worldMatrix defines the new world matrix
  85127. */
  85128. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85129. /**
  85130. * Recreates the entire bounding box from scratch as if we call the constructor in place
  85131. * @param min defines the new minimum vector (in local space)
  85132. * @param max defines the new maximum vector (in local space)
  85133. * @param worldMatrix defines the new world matrix
  85134. */
  85135. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85136. /**
  85137. * Scale the current bounding box by applying a scale factor
  85138. * @param factor defines the scale factor to apply
  85139. * @returns the current bounding box
  85140. */
  85141. scale(factor: number): BoundingBox;
  85142. /**
  85143. * Gets the world matrix of the bounding box
  85144. * @returns a matrix
  85145. */
  85146. getWorldMatrix(): DeepImmutable<Matrix>;
  85147. /** @hidden */
  85148. _update(world: DeepImmutable<Matrix>): void;
  85149. /**
  85150. * Tests if the bounding box is intersecting the frustum planes
  85151. * @param frustumPlanes defines the frustum planes to test
  85152. * @returns true if there is an intersection
  85153. */
  85154. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85155. /**
  85156. * Tests if the bounding box is entirely inside the frustum planes
  85157. * @param frustumPlanes defines the frustum planes to test
  85158. * @returns true if there is an inclusion
  85159. */
  85160. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85161. /**
  85162. * Tests if a point is inside the bounding box
  85163. * @param point defines the point to test
  85164. * @returns true if the point is inside the bounding box
  85165. */
  85166. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85167. /**
  85168. * Tests if the bounding box intersects with a bounding sphere
  85169. * @param sphere defines the sphere to test
  85170. * @returns true if there is an intersection
  85171. */
  85172. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  85173. /**
  85174. * Tests if the bounding box intersects with a box defined by a min and max vectors
  85175. * @param min defines the min vector to use
  85176. * @param max defines the max vector to use
  85177. * @returns true if there is an intersection
  85178. */
  85179. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  85180. /**
  85181. * Tests if two bounding boxes are intersections
  85182. * @param box0 defines the first box to test
  85183. * @param box1 defines the second box to test
  85184. * @returns true if there is an intersection
  85185. */
  85186. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  85187. /**
  85188. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  85189. * @param minPoint defines the minimum vector of the bounding box
  85190. * @param maxPoint defines the maximum vector of the bounding box
  85191. * @param sphereCenter defines the sphere center
  85192. * @param sphereRadius defines the sphere radius
  85193. * @returns true if there is an intersection
  85194. */
  85195. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  85196. /**
  85197. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  85198. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85199. * @param frustumPlanes defines the frustum planes to test
  85200. * @return true if there is an inclusion
  85201. */
  85202. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85203. /**
  85204. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  85205. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85206. * @param frustumPlanes defines the frustum planes to test
  85207. * @return true if there is an intersection
  85208. */
  85209. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85210. }
  85211. }
  85212. declare module BABYLON {
  85213. /** @hidden */
  85214. export class Collider {
  85215. /** Define if a collision was found */
  85216. collisionFound: boolean;
  85217. /**
  85218. * Define last intersection point in local space
  85219. */
  85220. intersectionPoint: Vector3;
  85221. /**
  85222. * Define last collided mesh
  85223. */
  85224. collidedMesh: Nullable<AbstractMesh>;
  85225. private _collisionPoint;
  85226. private _planeIntersectionPoint;
  85227. private _tempVector;
  85228. private _tempVector2;
  85229. private _tempVector3;
  85230. private _tempVector4;
  85231. private _edge;
  85232. private _baseToVertex;
  85233. private _destinationPoint;
  85234. private _slidePlaneNormal;
  85235. private _displacementVector;
  85236. /** @hidden */
  85237. _radius: Vector3;
  85238. /** @hidden */
  85239. _retry: number;
  85240. private _velocity;
  85241. private _basePoint;
  85242. private _epsilon;
  85243. /** @hidden */
  85244. _velocityWorldLength: number;
  85245. /** @hidden */
  85246. _basePointWorld: Vector3;
  85247. private _velocityWorld;
  85248. private _normalizedVelocity;
  85249. /** @hidden */
  85250. _initialVelocity: Vector3;
  85251. /** @hidden */
  85252. _initialPosition: Vector3;
  85253. private _nearestDistance;
  85254. private _collisionMask;
  85255. get collisionMask(): number;
  85256. set collisionMask(mask: number);
  85257. /**
  85258. * Gets the plane normal used to compute the sliding response (in local space)
  85259. */
  85260. get slidePlaneNormal(): Vector3;
  85261. /** @hidden */
  85262. _initialize(source: Vector3, dir: Vector3, e: number): void;
  85263. /** @hidden */
  85264. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  85265. /** @hidden */
  85266. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  85267. /** @hidden */
  85268. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85269. /** @hidden */
  85270. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85271. /** @hidden */
  85272. _getResponse(pos: Vector3, vel: Vector3): void;
  85273. }
  85274. }
  85275. declare module BABYLON {
  85276. /**
  85277. * Interface for cullable objects
  85278. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  85279. */
  85280. export interface ICullable {
  85281. /**
  85282. * Checks if the object or part of the object is in the frustum
  85283. * @param frustumPlanes Camera near/planes
  85284. * @returns true if the object is in frustum otherwise false
  85285. */
  85286. isInFrustum(frustumPlanes: Plane[]): boolean;
  85287. /**
  85288. * Checks if a cullable object (mesh...) is in the camera frustum
  85289. * Unlike isInFrustum this cheks the full bounding box
  85290. * @param frustumPlanes Camera near/planes
  85291. * @returns true if the object is in frustum otherwise false
  85292. */
  85293. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85294. }
  85295. /**
  85296. * Info for a bounding data of a mesh
  85297. */
  85298. export class BoundingInfo implements ICullable {
  85299. /**
  85300. * Bounding box for the mesh
  85301. */
  85302. readonly boundingBox: BoundingBox;
  85303. /**
  85304. * Bounding sphere for the mesh
  85305. */
  85306. readonly boundingSphere: BoundingSphere;
  85307. private _isLocked;
  85308. private static readonly TmpVector3;
  85309. /**
  85310. * Constructs bounding info
  85311. * @param minimum min vector of the bounding box/sphere
  85312. * @param maximum max vector of the bounding box/sphere
  85313. * @param worldMatrix defines the new world matrix
  85314. */
  85315. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85316. /**
  85317. * Recreates the entire bounding info from scratch as if we call the constructor in place
  85318. * @param min defines the new minimum vector (in local space)
  85319. * @param max defines the new maximum vector (in local space)
  85320. * @param worldMatrix defines the new world matrix
  85321. */
  85322. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85323. /**
  85324. * min vector of the bounding box/sphere
  85325. */
  85326. get minimum(): Vector3;
  85327. /**
  85328. * max vector of the bounding box/sphere
  85329. */
  85330. get maximum(): Vector3;
  85331. /**
  85332. * If the info is locked and won't be updated to avoid perf overhead
  85333. */
  85334. get isLocked(): boolean;
  85335. set isLocked(value: boolean);
  85336. /**
  85337. * Updates the bounding sphere and box
  85338. * @param world world matrix to be used to update
  85339. */
  85340. update(world: DeepImmutable<Matrix>): void;
  85341. /**
  85342. * Recreate the bounding info to be centered around a specific point given a specific extend.
  85343. * @param center New center of the bounding info
  85344. * @param extend New extend of the bounding info
  85345. * @returns the current bounding info
  85346. */
  85347. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  85348. /**
  85349. * Scale the current bounding info by applying a scale factor
  85350. * @param factor defines the scale factor to apply
  85351. * @returns the current bounding info
  85352. */
  85353. scale(factor: number): BoundingInfo;
  85354. /**
  85355. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  85356. * @param frustumPlanes defines the frustum to test
  85357. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  85358. * @returns true if the bounding info is in the frustum planes
  85359. */
  85360. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  85361. /**
  85362. * Gets the world distance between the min and max points of the bounding box
  85363. */
  85364. get diagonalLength(): number;
  85365. /**
  85366. * Checks if a cullable object (mesh...) is in the camera frustum
  85367. * Unlike isInFrustum this cheks the full bounding box
  85368. * @param frustumPlanes Camera near/planes
  85369. * @returns true if the object is in frustum otherwise false
  85370. */
  85371. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85372. /** @hidden */
  85373. _checkCollision(collider: Collider): boolean;
  85374. /**
  85375. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  85376. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85377. * @param point the point to check intersection with
  85378. * @returns if the point intersects
  85379. */
  85380. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85381. /**
  85382. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  85383. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85384. * @param boundingInfo the bounding info to check intersection with
  85385. * @param precise if the intersection should be done using OBB
  85386. * @returns if the bounding info intersects
  85387. */
  85388. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  85389. }
  85390. }
  85391. declare module BABYLON {
  85392. /**
  85393. * Extracts minimum and maximum values from a list of indexed positions
  85394. * @param positions defines the positions to use
  85395. * @param indices defines the indices to the positions
  85396. * @param indexStart defines the start index
  85397. * @param indexCount defines the end index
  85398. * @param bias defines bias value to add to the result
  85399. * @return minimum and maximum values
  85400. */
  85401. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  85402. minimum: Vector3;
  85403. maximum: Vector3;
  85404. };
  85405. /**
  85406. * Extracts minimum and maximum values from a list of positions
  85407. * @param positions defines the positions to use
  85408. * @param start defines the start index in the positions array
  85409. * @param count defines the number of positions to handle
  85410. * @param bias defines bias value to add to the result
  85411. * @param stride defines the stride size to use (distance between two positions in the positions array)
  85412. * @return minimum and maximum values
  85413. */
  85414. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  85415. minimum: Vector3;
  85416. maximum: Vector3;
  85417. };
  85418. }
  85419. declare module BABYLON {
  85420. /** @hidden */
  85421. export class WebGLDataBuffer extends DataBuffer {
  85422. private _buffer;
  85423. constructor(resource: WebGLBuffer);
  85424. get underlyingResource(): any;
  85425. }
  85426. }
  85427. declare module BABYLON {
  85428. /** @hidden */
  85429. export class WebGLPipelineContext implements IPipelineContext {
  85430. engine: ThinEngine;
  85431. program: Nullable<WebGLProgram>;
  85432. context?: WebGLRenderingContext;
  85433. vertexShader?: WebGLShader;
  85434. fragmentShader?: WebGLShader;
  85435. isParallelCompiled: boolean;
  85436. onCompiled?: () => void;
  85437. transformFeedback?: WebGLTransformFeedback | null;
  85438. vertexCompilationError: Nullable<string>;
  85439. fragmentCompilationError: Nullable<string>;
  85440. programLinkError: Nullable<string>;
  85441. programValidationError: Nullable<string>;
  85442. get isAsync(): boolean;
  85443. get isReady(): boolean;
  85444. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  85445. _getVertexShaderCode(): string | null;
  85446. _getFragmentShaderCode(): string | null;
  85447. }
  85448. }
  85449. declare module BABYLON {
  85450. interface ThinEngine {
  85451. /**
  85452. * Create an uniform buffer
  85453. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85454. * @param elements defines the content of the uniform buffer
  85455. * @returns the webGL uniform buffer
  85456. */
  85457. createUniformBuffer(elements: FloatArray): DataBuffer;
  85458. /**
  85459. * Create a dynamic uniform buffer
  85460. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85461. * @param elements defines the content of the uniform buffer
  85462. * @returns the webGL uniform buffer
  85463. */
  85464. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  85465. /**
  85466. * Update an existing uniform buffer
  85467. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85468. * @param uniformBuffer defines the target uniform buffer
  85469. * @param elements defines the content to update
  85470. * @param offset defines the offset in the uniform buffer where update should start
  85471. * @param count defines the size of the data to update
  85472. */
  85473. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85474. /**
  85475. * Bind an uniform buffer to the current webGL context
  85476. * @param buffer defines the buffer to bind
  85477. */
  85478. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  85479. /**
  85480. * Bind a buffer to the current webGL context at a given location
  85481. * @param buffer defines the buffer to bind
  85482. * @param location defines the index where to bind the buffer
  85483. */
  85484. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  85485. /**
  85486. * Bind a specific block at a given index in a specific shader program
  85487. * @param pipelineContext defines the pipeline context to use
  85488. * @param blockName defines the block name
  85489. * @param index defines the index where to bind the block
  85490. */
  85491. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  85492. }
  85493. }
  85494. declare module BABYLON {
  85495. /**
  85496. * Uniform buffer objects.
  85497. *
  85498. * Handles blocks of uniform on the GPU.
  85499. *
  85500. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85501. *
  85502. * For more information, please refer to :
  85503. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85504. */
  85505. export class UniformBuffer {
  85506. private _engine;
  85507. private _buffer;
  85508. private _data;
  85509. private _bufferData;
  85510. private _dynamic?;
  85511. private _uniformLocations;
  85512. private _uniformSizes;
  85513. private _uniformLocationPointer;
  85514. private _needSync;
  85515. private _noUBO;
  85516. private _currentEffect;
  85517. /** @hidden */
  85518. _alreadyBound: boolean;
  85519. private static _MAX_UNIFORM_SIZE;
  85520. private static _tempBuffer;
  85521. /**
  85522. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85523. * This is dynamic to allow compat with webgl 1 and 2.
  85524. * You will need to pass the name of the uniform as well as the value.
  85525. */
  85526. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85527. /**
  85528. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85529. * This is dynamic to allow compat with webgl 1 and 2.
  85530. * You will need to pass the name of the uniform as well as the value.
  85531. */
  85532. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85533. /**
  85534. * Lambda to Update a single float in a uniform buffer.
  85535. * This is dynamic to allow compat with webgl 1 and 2.
  85536. * You will need to pass the name of the uniform as well as the value.
  85537. */
  85538. updateFloat: (name: string, x: number) => void;
  85539. /**
  85540. * Lambda to Update a vec2 of float in a uniform buffer.
  85541. * This is dynamic to allow compat with webgl 1 and 2.
  85542. * You will need to pass the name of the uniform as well as the value.
  85543. */
  85544. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85545. /**
  85546. * Lambda to Update a vec3 of float in a uniform buffer.
  85547. * This is dynamic to allow compat with webgl 1 and 2.
  85548. * You will need to pass the name of the uniform as well as the value.
  85549. */
  85550. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85551. /**
  85552. * Lambda to Update a vec4 of float in a uniform buffer.
  85553. * This is dynamic to allow compat with webgl 1 and 2.
  85554. * You will need to pass the name of the uniform as well as the value.
  85555. */
  85556. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85557. /**
  85558. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85559. * This is dynamic to allow compat with webgl 1 and 2.
  85560. * You will need to pass the name of the uniform as well as the value.
  85561. */
  85562. updateMatrix: (name: string, mat: Matrix) => void;
  85563. /**
  85564. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85565. * This is dynamic to allow compat with webgl 1 and 2.
  85566. * You will need to pass the name of the uniform as well as the value.
  85567. */
  85568. updateVector3: (name: string, vector: Vector3) => void;
  85569. /**
  85570. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85571. * This is dynamic to allow compat with webgl 1 and 2.
  85572. * You will need to pass the name of the uniform as well as the value.
  85573. */
  85574. updateVector4: (name: string, vector: Vector4) => void;
  85575. /**
  85576. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85577. * This is dynamic to allow compat with webgl 1 and 2.
  85578. * You will need to pass the name of the uniform as well as the value.
  85579. */
  85580. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85581. /**
  85582. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85583. * This is dynamic to allow compat with webgl 1 and 2.
  85584. * You will need to pass the name of the uniform as well as the value.
  85585. */
  85586. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85587. /**
  85588. * Instantiates a new Uniform buffer objects.
  85589. *
  85590. * Handles blocks of uniform on the GPU.
  85591. *
  85592. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85593. *
  85594. * For more information, please refer to :
  85595. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85596. * @param engine Define the engine the buffer is associated with
  85597. * @param data Define the data contained in the buffer
  85598. * @param dynamic Define if the buffer is updatable
  85599. */
  85600. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85601. /**
  85602. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85603. * or just falling back on setUniformXXX calls.
  85604. */
  85605. get useUbo(): boolean;
  85606. /**
  85607. * Indicates if the WebGL underlying uniform buffer is in sync
  85608. * with the javascript cache data.
  85609. */
  85610. get isSync(): boolean;
  85611. /**
  85612. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85613. * Also, a dynamic UniformBuffer will disable cache verification and always
  85614. * update the underlying WebGL uniform buffer to the GPU.
  85615. * @returns if Dynamic, otherwise false
  85616. */
  85617. isDynamic(): boolean;
  85618. /**
  85619. * The data cache on JS side.
  85620. * @returns the underlying data as a float array
  85621. */
  85622. getData(): Float32Array;
  85623. /**
  85624. * The underlying WebGL Uniform buffer.
  85625. * @returns the webgl buffer
  85626. */
  85627. getBuffer(): Nullable<DataBuffer>;
  85628. /**
  85629. * std140 layout specifies how to align data within an UBO structure.
  85630. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85631. * for specs.
  85632. */
  85633. private _fillAlignment;
  85634. /**
  85635. * Adds an uniform in the buffer.
  85636. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85637. * for the layout to be correct !
  85638. * @param name Name of the uniform, as used in the uniform block in the shader.
  85639. * @param size Data size, or data directly.
  85640. */
  85641. addUniform(name: string, size: number | number[]): void;
  85642. /**
  85643. * Adds a Matrix 4x4 to the uniform buffer.
  85644. * @param name Name of the uniform, as used in the uniform block in the shader.
  85645. * @param mat A 4x4 matrix.
  85646. */
  85647. addMatrix(name: string, mat: Matrix): void;
  85648. /**
  85649. * Adds a vec2 to the uniform buffer.
  85650. * @param name Name of the uniform, as used in the uniform block in the shader.
  85651. * @param x Define the x component value of the vec2
  85652. * @param y Define the y component value of the vec2
  85653. */
  85654. addFloat2(name: string, x: number, y: number): void;
  85655. /**
  85656. * Adds a vec3 to the uniform buffer.
  85657. * @param name Name of the uniform, as used in the uniform block in the shader.
  85658. * @param x Define the x component value of the vec3
  85659. * @param y Define the y component value of the vec3
  85660. * @param z Define the z component value of the vec3
  85661. */
  85662. addFloat3(name: string, x: number, y: number, z: number): void;
  85663. /**
  85664. * Adds a vec3 to the uniform buffer.
  85665. * @param name Name of the uniform, as used in the uniform block in the shader.
  85666. * @param color Define the vec3 from a Color
  85667. */
  85668. addColor3(name: string, color: Color3): void;
  85669. /**
  85670. * Adds a vec4 to the uniform buffer.
  85671. * @param name Name of the uniform, as used in the uniform block in the shader.
  85672. * @param color Define the rgb components from a Color
  85673. * @param alpha Define the a component of the vec4
  85674. */
  85675. addColor4(name: string, color: Color3, alpha: number): void;
  85676. /**
  85677. * Adds a vec3 to the uniform buffer.
  85678. * @param name Name of the uniform, as used in the uniform block in the shader.
  85679. * @param vector Define the vec3 components from a Vector
  85680. */
  85681. addVector3(name: string, vector: Vector3): void;
  85682. /**
  85683. * Adds a Matrix 3x3 to the uniform buffer.
  85684. * @param name Name of the uniform, as used in the uniform block in the shader.
  85685. */
  85686. addMatrix3x3(name: string): void;
  85687. /**
  85688. * Adds a Matrix 2x2 to the uniform buffer.
  85689. * @param name Name of the uniform, as used in the uniform block in the shader.
  85690. */
  85691. addMatrix2x2(name: string): void;
  85692. /**
  85693. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85694. */
  85695. create(): void;
  85696. /** @hidden */
  85697. _rebuild(): void;
  85698. /**
  85699. * Updates the WebGL Uniform Buffer on the GPU.
  85700. * If the `dynamic` flag is set to true, no cache comparison is done.
  85701. * Otherwise, the buffer will be updated only if the cache differs.
  85702. */
  85703. update(): void;
  85704. /**
  85705. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85706. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85707. * @param data Define the flattened data
  85708. * @param size Define the size of the data.
  85709. */
  85710. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85711. private _valueCache;
  85712. private _cacheMatrix;
  85713. private _updateMatrix3x3ForUniform;
  85714. private _updateMatrix3x3ForEffect;
  85715. private _updateMatrix2x2ForEffect;
  85716. private _updateMatrix2x2ForUniform;
  85717. private _updateFloatForEffect;
  85718. private _updateFloatForUniform;
  85719. private _updateFloat2ForEffect;
  85720. private _updateFloat2ForUniform;
  85721. private _updateFloat3ForEffect;
  85722. private _updateFloat3ForUniform;
  85723. private _updateFloat4ForEffect;
  85724. private _updateFloat4ForUniform;
  85725. private _updateMatrixForEffect;
  85726. private _updateMatrixForUniform;
  85727. private _updateVector3ForEffect;
  85728. private _updateVector3ForUniform;
  85729. private _updateVector4ForEffect;
  85730. private _updateVector4ForUniform;
  85731. private _updateColor3ForEffect;
  85732. private _updateColor3ForUniform;
  85733. private _updateColor4ForEffect;
  85734. private _updateColor4ForUniform;
  85735. /**
  85736. * Sets a sampler uniform on the effect.
  85737. * @param name Define the name of the sampler.
  85738. * @param texture Define the texture to set in the sampler
  85739. */
  85740. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85741. /**
  85742. * Directly updates the value of the uniform in the cache AND on the GPU.
  85743. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85744. * @param data Define the flattened data
  85745. */
  85746. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85747. /**
  85748. * Binds this uniform buffer to an effect.
  85749. * @param effect Define the effect to bind the buffer to
  85750. * @param name Name of the uniform block in the shader.
  85751. */
  85752. bindToEffect(effect: Effect, name: string): void;
  85753. /**
  85754. * Disposes the uniform buffer.
  85755. */
  85756. dispose(): void;
  85757. }
  85758. }
  85759. declare module BABYLON {
  85760. /**
  85761. * Enum that determines the text-wrapping mode to use.
  85762. */
  85763. export enum InspectableType {
  85764. /**
  85765. * Checkbox for booleans
  85766. */
  85767. Checkbox = 0,
  85768. /**
  85769. * Sliders for numbers
  85770. */
  85771. Slider = 1,
  85772. /**
  85773. * Vector3
  85774. */
  85775. Vector3 = 2,
  85776. /**
  85777. * Quaternions
  85778. */
  85779. Quaternion = 3,
  85780. /**
  85781. * Color3
  85782. */
  85783. Color3 = 4,
  85784. /**
  85785. * String
  85786. */
  85787. String = 5
  85788. }
  85789. /**
  85790. * Interface used to define custom inspectable properties.
  85791. * This interface is used by the inspector to display custom property grids
  85792. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85793. */
  85794. export interface IInspectable {
  85795. /**
  85796. * Gets the label to display
  85797. */
  85798. label: string;
  85799. /**
  85800. * Gets the name of the property to edit
  85801. */
  85802. propertyName: string;
  85803. /**
  85804. * Gets the type of the editor to use
  85805. */
  85806. type: InspectableType;
  85807. /**
  85808. * Gets the minimum value of the property when using in "slider" mode
  85809. */
  85810. min?: number;
  85811. /**
  85812. * Gets the maximum value of the property when using in "slider" mode
  85813. */
  85814. max?: number;
  85815. /**
  85816. * Gets the setp to use when using in "slider" mode
  85817. */
  85818. step?: number;
  85819. }
  85820. }
  85821. declare module BABYLON {
  85822. /**
  85823. * Class used to provide helper for timing
  85824. */
  85825. export class TimingTools {
  85826. /**
  85827. * Polyfill for setImmediate
  85828. * @param action defines the action to execute after the current execution block
  85829. */
  85830. static SetImmediate(action: () => void): void;
  85831. }
  85832. }
  85833. declare module BABYLON {
  85834. /**
  85835. * Class used to enable instatition of objects by class name
  85836. */
  85837. export class InstantiationTools {
  85838. /**
  85839. * Use this object to register external classes like custom textures or material
  85840. * to allow the laoders to instantiate them
  85841. */
  85842. static RegisteredExternalClasses: {
  85843. [key: string]: Object;
  85844. };
  85845. /**
  85846. * Tries to instantiate a new object from a given class name
  85847. * @param className defines the class name to instantiate
  85848. * @returns the new object or null if the system was not able to do the instantiation
  85849. */
  85850. static Instantiate(className: string): any;
  85851. }
  85852. }
  85853. declare module BABYLON {
  85854. /**
  85855. * Define options used to create a depth texture
  85856. */
  85857. export class DepthTextureCreationOptions {
  85858. /** Specifies whether or not a stencil should be allocated in the texture */
  85859. generateStencil?: boolean;
  85860. /** Specifies whether or not bilinear filtering is enable on the texture */
  85861. bilinearFiltering?: boolean;
  85862. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85863. comparisonFunction?: number;
  85864. /** Specifies if the created texture is a cube texture */
  85865. isCube?: boolean;
  85866. }
  85867. }
  85868. declare module BABYLON {
  85869. interface ThinEngine {
  85870. /**
  85871. * Creates a depth stencil cube texture.
  85872. * This is only available in WebGL 2.
  85873. * @param size The size of face edge in the cube texture.
  85874. * @param options The options defining the cube texture.
  85875. * @returns The cube texture
  85876. */
  85877. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  85878. /**
  85879. * Creates a cube texture
  85880. * @param rootUrl defines the url where the files to load is located
  85881. * @param scene defines the current scene
  85882. * @param files defines the list of files to load (1 per face)
  85883. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85884. * @param onLoad defines an optional callback raised when the texture is loaded
  85885. * @param onError defines an optional callback raised if there is an issue to load the texture
  85886. * @param format defines the format of the data
  85887. * @param forcedExtension defines the extension to use to pick the right loader
  85888. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85889. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85890. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85891. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85892. * @returns the cube texture as an InternalTexture
  85893. */
  85894. 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;
  85895. /**
  85896. * Creates a cube texture
  85897. * @param rootUrl defines the url where the files to load is located
  85898. * @param scene defines the current scene
  85899. * @param files defines the list of files to load (1 per face)
  85900. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85901. * @param onLoad defines an optional callback raised when the texture is loaded
  85902. * @param onError defines an optional callback raised if there is an issue to load the texture
  85903. * @param format defines the format of the data
  85904. * @param forcedExtension defines the extension to use to pick the right loader
  85905. * @returns the cube texture as an InternalTexture
  85906. */
  85907. 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;
  85908. /**
  85909. * Creates a cube texture
  85910. * @param rootUrl defines the url where the files to load is located
  85911. * @param scene defines the current scene
  85912. * @param files defines the list of files to load (1 per face)
  85913. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85914. * @param onLoad defines an optional callback raised when the texture is loaded
  85915. * @param onError defines an optional callback raised if there is an issue to load the texture
  85916. * @param format defines the format of the data
  85917. * @param forcedExtension defines the extension to use to pick the right loader
  85918. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85919. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85920. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85921. * @returns the cube texture as an InternalTexture
  85922. */
  85923. 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;
  85924. /** @hidden */
  85925. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  85926. /** @hidden */
  85927. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  85928. /** @hidden */
  85929. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85930. /** @hidden */
  85931. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85932. /**
  85933. * @hidden
  85934. */
  85935. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85936. }
  85937. }
  85938. declare module BABYLON {
  85939. /**
  85940. * Class for creating a cube texture
  85941. */
  85942. export class CubeTexture extends BaseTexture {
  85943. private _delayedOnLoad;
  85944. /**
  85945. * Observable triggered once the texture has been loaded.
  85946. */
  85947. onLoadObservable: Observable<CubeTexture>;
  85948. /**
  85949. * The url of the texture
  85950. */
  85951. url: string;
  85952. /**
  85953. * Gets or sets the center of the bounding box associated with the cube texture.
  85954. * It must define where the camera used to render the texture was set
  85955. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85956. */
  85957. boundingBoxPosition: Vector3;
  85958. private _boundingBoxSize;
  85959. /**
  85960. * Gets or sets the size of the bounding box associated with the cube texture
  85961. * When defined, the cubemap will switch to local mode
  85962. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85963. * @example https://www.babylonjs-playground.com/#RNASML
  85964. */
  85965. set boundingBoxSize(value: Vector3);
  85966. /**
  85967. * Returns the bounding box size
  85968. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85969. */
  85970. get boundingBoxSize(): Vector3;
  85971. protected _rotationY: number;
  85972. /**
  85973. * Sets texture matrix rotation angle around Y axis in radians.
  85974. */
  85975. set rotationY(value: number);
  85976. /**
  85977. * Gets texture matrix rotation angle around Y axis radians.
  85978. */
  85979. get rotationY(): number;
  85980. /**
  85981. * Are mip maps generated for this texture or not.
  85982. */
  85983. get noMipmap(): boolean;
  85984. private _noMipmap;
  85985. private _files;
  85986. protected _forcedExtension: Nullable<string>;
  85987. private _extensions;
  85988. private _textureMatrix;
  85989. private _format;
  85990. private _createPolynomials;
  85991. /**
  85992. * Creates a cube texture from an array of image urls
  85993. * @param files defines an array of image urls
  85994. * @param scene defines the hosting scene
  85995. * @param noMipmap specifies if mip maps are not used
  85996. * @returns a cube texture
  85997. */
  85998. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  85999. /**
  86000. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  86001. * @param url defines the url of the prefiltered texture
  86002. * @param scene defines the scene the texture is attached to
  86003. * @param forcedExtension defines the extension of the file if different from the url
  86004. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86005. * @return the prefiltered texture
  86006. */
  86007. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  86008. /**
  86009. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  86010. * as prefiltered data.
  86011. * @param rootUrl defines the url of the texture or the root name of the six images
  86012. * @param null defines the scene or engine the texture is attached to
  86013. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86014. * @param noMipmap defines if mipmaps should be created or not
  86015. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86016. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86017. * @param onError defines a callback triggered in case of error during load
  86018. * @param format defines the internal format to use for the texture once loaded
  86019. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86020. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86021. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86022. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86023. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86024. * @return the cube texture
  86025. */
  86026. 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);
  86027. /**
  86028. * Get the current class name of the texture useful for serialization or dynamic coding.
  86029. * @returns "CubeTexture"
  86030. */
  86031. getClassName(): string;
  86032. /**
  86033. * Update the url (and optional buffer) of this texture if url was null during construction.
  86034. * @param url the url of the texture
  86035. * @param forcedExtension defines the extension to use
  86036. * @param onLoad callback called when the texture is loaded (defaults to null)
  86037. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86038. */
  86039. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86040. /**
  86041. * Delays loading of the cube texture
  86042. * @param forcedExtension defines the extension to use
  86043. */
  86044. delayLoad(forcedExtension?: string): void;
  86045. /**
  86046. * Returns the reflection texture matrix
  86047. * @returns the reflection texture matrix
  86048. */
  86049. getReflectionTextureMatrix(): Matrix;
  86050. /**
  86051. * Sets the reflection texture matrix
  86052. * @param value Reflection texture matrix
  86053. */
  86054. setReflectionTextureMatrix(value: Matrix): void;
  86055. /**
  86056. * Parses text to create a cube texture
  86057. * @param parsedTexture define the serialized text to read from
  86058. * @param scene defines the hosting scene
  86059. * @param rootUrl defines the root url of the cube texture
  86060. * @returns a cube texture
  86061. */
  86062. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86063. /**
  86064. * Makes a clone, or deep copy, of the cube texture
  86065. * @returns a new cube texture
  86066. */
  86067. clone(): CubeTexture;
  86068. }
  86069. }
  86070. declare module BABYLON {
  86071. /**
  86072. * Manages the defines for the Material
  86073. */
  86074. export class MaterialDefines {
  86075. /** @hidden */
  86076. protected _keys: string[];
  86077. private _isDirty;
  86078. /** @hidden */
  86079. _renderId: number;
  86080. /** @hidden */
  86081. _areLightsDirty: boolean;
  86082. /** @hidden */
  86083. _areLightsDisposed: boolean;
  86084. /** @hidden */
  86085. _areAttributesDirty: boolean;
  86086. /** @hidden */
  86087. _areTexturesDirty: boolean;
  86088. /** @hidden */
  86089. _areFresnelDirty: boolean;
  86090. /** @hidden */
  86091. _areMiscDirty: boolean;
  86092. /** @hidden */
  86093. _areImageProcessingDirty: boolean;
  86094. /** @hidden */
  86095. _normals: boolean;
  86096. /** @hidden */
  86097. _uvs: boolean;
  86098. /** @hidden */
  86099. _needNormals: boolean;
  86100. /** @hidden */
  86101. _needUVs: boolean;
  86102. [id: string]: any;
  86103. /**
  86104. * Specifies if the material needs to be re-calculated
  86105. */
  86106. get isDirty(): boolean;
  86107. /**
  86108. * Marks the material to indicate that it has been re-calculated
  86109. */
  86110. markAsProcessed(): void;
  86111. /**
  86112. * Marks the material to indicate that it needs to be re-calculated
  86113. */
  86114. markAsUnprocessed(): void;
  86115. /**
  86116. * Marks the material to indicate all of its defines need to be re-calculated
  86117. */
  86118. markAllAsDirty(): void;
  86119. /**
  86120. * Marks the material to indicate that image processing needs to be re-calculated
  86121. */
  86122. markAsImageProcessingDirty(): void;
  86123. /**
  86124. * Marks the material to indicate the lights need to be re-calculated
  86125. * @param disposed Defines whether the light is dirty due to dispose or not
  86126. */
  86127. markAsLightDirty(disposed?: boolean): void;
  86128. /**
  86129. * Marks the attribute state as changed
  86130. */
  86131. markAsAttributesDirty(): void;
  86132. /**
  86133. * Marks the texture state as changed
  86134. */
  86135. markAsTexturesDirty(): void;
  86136. /**
  86137. * Marks the fresnel state as changed
  86138. */
  86139. markAsFresnelDirty(): void;
  86140. /**
  86141. * Marks the misc state as changed
  86142. */
  86143. markAsMiscDirty(): void;
  86144. /**
  86145. * Rebuilds the material defines
  86146. */
  86147. rebuild(): void;
  86148. /**
  86149. * Specifies if two material defines are equal
  86150. * @param other - A material define instance to compare to
  86151. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  86152. */
  86153. isEqual(other: MaterialDefines): boolean;
  86154. /**
  86155. * Clones this instance's defines to another instance
  86156. * @param other - material defines to clone values to
  86157. */
  86158. cloneTo(other: MaterialDefines): void;
  86159. /**
  86160. * Resets the material define values
  86161. */
  86162. reset(): void;
  86163. /**
  86164. * Converts the material define values to a string
  86165. * @returns - String of material define information
  86166. */
  86167. toString(): string;
  86168. }
  86169. }
  86170. declare module BABYLON {
  86171. /**
  86172. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86173. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86174. * 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;
  86175. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86176. */
  86177. export class ColorCurves {
  86178. private _dirty;
  86179. private _tempColor;
  86180. private _globalCurve;
  86181. private _highlightsCurve;
  86182. private _midtonesCurve;
  86183. private _shadowsCurve;
  86184. private _positiveCurve;
  86185. private _negativeCurve;
  86186. private _globalHue;
  86187. private _globalDensity;
  86188. private _globalSaturation;
  86189. private _globalExposure;
  86190. /**
  86191. * Gets the global Hue value.
  86192. * 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).
  86193. */
  86194. get globalHue(): number;
  86195. /**
  86196. * Sets the global Hue value.
  86197. * 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).
  86198. */
  86199. set globalHue(value: number);
  86200. /**
  86201. * Gets the global Density value.
  86202. * 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.
  86203. * Values less than zero provide a filter of opposite hue.
  86204. */
  86205. get globalDensity(): number;
  86206. /**
  86207. * Sets the global Density value.
  86208. * 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.
  86209. * Values less than zero provide a filter of opposite hue.
  86210. */
  86211. set globalDensity(value: number);
  86212. /**
  86213. * Gets the global Saturation value.
  86214. * 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.
  86215. */
  86216. get globalSaturation(): number;
  86217. /**
  86218. * Sets the global Saturation value.
  86219. * 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.
  86220. */
  86221. set globalSaturation(value: number);
  86222. /**
  86223. * Gets the global Exposure value.
  86224. * 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.
  86225. */
  86226. get globalExposure(): number;
  86227. /**
  86228. * Sets the global Exposure value.
  86229. * 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.
  86230. */
  86231. set globalExposure(value: number);
  86232. private _highlightsHue;
  86233. private _highlightsDensity;
  86234. private _highlightsSaturation;
  86235. private _highlightsExposure;
  86236. /**
  86237. * Gets the highlights Hue value.
  86238. * 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).
  86239. */
  86240. get highlightsHue(): number;
  86241. /**
  86242. * Sets the highlights Hue value.
  86243. * 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).
  86244. */
  86245. set highlightsHue(value: number);
  86246. /**
  86247. * Gets the highlights Density value.
  86248. * 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.
  86249. * Values less than zero provide a filter of opposite hue.
  86250. */
  86251. get highlightsDensity(): number;
  86252. /**
  86253. * Sets the highlights Density value.
  86254. * 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.
  86255. * Values less than zero provide a filter of opposite hue.
  86256. */
  86257. set highlightsDensity(value: number);
  86258. /**
  86259. * Gets the highlights Saturation value.
  86260. * 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.
  86261. */
  86262. get highlightsSaturation(): number;
  86263. /**
  86264. * Sets the highlights Saturation value.
  86265. * 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.
  86266. */
  86267. set highlightsSaturation(value: number);
  86268. /**
  86269. * Gets the highlights Exposure value.
  86270. * 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.
  86271. */
  86272. get highlightsExposure(): number;
  86273. /**
  86274. * Sets the highlights Exposure value.
  86275. * 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.
  86276. */
  86277. set highlightsExposure(value: number);
  86278. private _midtonesHue;
  86279. private _midtonesDensity;
  86280. private _midtonesSaturation;
  86281. private _midtonesExposure;
  86282. /**
  86283. * Gets the midtones Hue value.
  86284. * 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).
  86285. */
  86286. get midtonesHue(): number;
  86287. /**
  86288. * Sets the midtones Hue value.
  86289. * 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).
  86290. */
  86291. set midtonesHue(value: number);
  86292. /**
  86293. * Gets the midtones Density value.
  86294. * 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.
  86295. * Values less than zero provide a filter of opposite hue.
  86296. */
  86297. get midtonesDensity(): number;
  86298. /**
  86299. * Sets the midtones Density value.
  86300. * 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.
  86301. * Values less than zero provide a filter of opposite hue.
  86302. */
  86303. set midtonesDensity(value: number);
  86304. /**
  86305. * Gets the midtones Saturation value.
  86306. * 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.
  86307. */
  86308. get midtonesSaturation(): number;
  86309. /**
  86310. * Sets the midtones Saturation value.
  86311. * 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.
  86312. */
  86313. set midtonesSaturation(value: number);
  86314. /**
  86315. * Gets the midtones Exposure value.
  86316. * 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.
  86317. */
  86318. get midtonesExposure(): number;
  86319. /**
  86320. * Sets the midtones Exposure value.
  86321. * 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.
  86322. */
  86323. set midtonesExposure(value: number);
  86324. private _shadowsHue;
  86325. private _shadowsDensity;
  86326. private _shadowsSaturation;
  86327. private _shadowsExposure;
  86328. /**
  86329. * Gets the shadows Hue value.
  86330. * 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).
  86331. */
  86332. get shadowsHue(): number;
  86333. /**
  86334. * Sets the shadows Hue value.
  86335. * 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).
  86336. */
  86337. set shadowsHue(value: number);
  86338. /**
  86339. * Gets the shadows Density value.
  86340. * 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.
  86341. * Values less than zero provide a filter of opposite hue.
  86342. */
  86343. get shadowsDensity(): number;
  86344. /**
  86345. * Sets the shadows Density value.
  86346. * 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.
  86347. * Values less than zero provide a filter of opposite hue.
  86348. */
  86349. set shadowsDensity(value: number);
  86350. /**
  86351. * Gets the shadows Saturation value.
  86352. * 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.
  86353. */
  86354. get shadowsSaturation(): number;
  86355. /**
  86356. * Sets the shadows Saturation value.
  86357. * 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.
  86358. */
  86359. set shadowsSaturation(value: number);
  86360. /**
  86361. * Gets the shadows Exposure value.
  86362. * 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.
  86363. */
  86364. get shadowsExposure(): number;
  86365. /**
  86366. * Sets the shadows Exposure value.
  86367. * 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.
  86368. */
  86369. set shadowsExposure(value: number);
  86370. /**
  86371. * Returns the class name
  86372. * @returns The class name
  86373. */
  86374. getClassName(): string;
  86375. /**
  86376. * Binds the color curves to the shader.
  86377. * @param colorCurves The color curve to bind
  86378. * @param effect The effect to bind to
  86379. * @param positiveUniform The positive uniform shader parameter
  86380. * @param neutralUniform The neutral uniform shader parameter
  86381. * @param negativeUniform The negative uniform shader parameter
  86382. */
  86383. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86384. /**
  86385. * Prepare the list of uniforms associated with the ColorCurves effects.
  86386. * @param uniformsList The list of uniforms used in the effect
  86387. */
  86388. static PrepareUniforms(uniformsList: string[]): void;
  86389. /**
  86390. * Returns color grading data based on a hue, density, saturation and exposure value.
  86391. * @param filterHue The hue of the color filter.
  86392. * @param filterDensity The density of the color filter.
  86393. * @param saturation The saturation.
  86394. * @param exposure The exposure.
  86395. * @param result The result data container.
  86396. */
  86397. private getColorGradingDataToRef;
  86398. /**
  86399. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86400. * @param value The input slider value in range [-100,100].
  86401. * @returns Adjusted value.
  86402. */
  86403. private static applyColorGradingSliderNonlinear;
  86404. /**
  86405. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86406. * @param hue The hue (H) input.
  86407. * @param saturation The saturation (S) input.
  86408. * @param brightness The brightness (B) input.
  86409. * @result An RGBA color represented as Vector4.
  86410. */
  86411. private static fromHSBToRef;
  86412. /**
  86413. * Returns a value clamped between min and max
  86414. * @param value The value to clamp
  86415. * @param min The minimum of value
  86416. * @param max The maximum of value
  86417. * @returns The clamped value.
  86418. */
  86419. private static clamp;
  86420. /**
  86421. * Clones the current color curve instance.
  86422. * @return The cloned curves
  86423. */
  86424. clone(): ColorCurves;
  86425. /**
  86426. * Serializes the current color curve instance to a json representation.
  86427. * @return a JSON representation
  86428. */
  86429. serialize(): any;
  86430. /**
  86431. * Parses the color curve from a json representation.
  86432. * @param source the JSON source to parse
  86433. * @return The parsed curves
  86434. */
  86435. static Parse(source: any): ColorCurves;
  86436. }
  86437. }
  86438. declare module BABYLON {
  86439. /**
  86440. * Interface to follow in your material defines to integrate easily the
  86441. * Image proccessing functions.
  86442. * @hidden
  86443. */
  86444. export interface IImageProcessingConfigurationDefines {
  86445. IMAGEPROCESSING: boolean;
  86446. VIGNETTE: boolean;
  86447. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86448. VIGNETTEBLENDMODEOPAQUE: boolean;
  86449. TONEMAPPING: boolean;
  86450. TONEMAPPING_ACES: boolean;
  86451. CONTRAST: boolean;
  86452. EXPOSURE: boolean;
  86453. COLORCURVES: boolean;
  86454. COLORGRADING: boolean;
  86455. COLORGRADING3D: boolean;
  86456. SAMPLER3DGREENDEPTH: boolean;
  86457. SAMPLER3DBGRMAP: boolean;
  86458. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86459. }
  86460. /**
  86461. * @hidden
  86462. */
  86463. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86464. IMAGEPROCESSING: boolean;
  86465. VIGNETTE: boolean;
  86466. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86467. VIGNETTEBLENDMODEOPAQUE: boolean;
  86468. TONEMAPPING: boolean;
  86469. TONEMAPPING_ACES: boolean;
  86470. CONTRAST: boolean;
  86471. COLORCURVES: boolean;
  86472. COLORGRADING: boolean;
  86473. COLORGRADING3D: boolean;
  86474. SAMPLER3DGREENDEPTH: boolean;
  86475. SAMPLER3DBGRMAP: boolean;
  86476. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86477. EXPOSURE: boolean;
  86478. constructor();
  86479. }
  86480. /**
  86481. * This groups together the common properties used for image processing either in direct forward pass
  86482. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86483. * or not.
  86484. */
  86485. export class ImageProcessingConfiguration {
  86486. /**
  86487. * Default tone mapping applied in BabylonJS.
  86488. */
  86489. static readonly TONEMAPPING_STANDARD: number;
  86490. /**
  86491. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86492. * to other engines rendering to increase portability.
  86493. */
  86494. static readonly TONEMAPPING_ACES: number;
  86495. /**
  86496. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86497. */
  86498. colorCurves: Nullable<ColorCurves>;
  86499. private _colorCurvesEnabled;
  86500. /**
  86501. * Gets wether the color curves effect is enabled.
  86502. */
  86503. get colorCurvesEnabled(): boolean;
  86504. /**
  86505. * Sets wether the color curves effect is enabled.
  86506. */
  86507. set colorCurvesEnabled(value: boolean);
  86508. private _colorGradingTexture;
  86509. /**
  86510. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86511. */
  86512. get colorGradingTexture(): Nullable<BaseTexture>;
  86513. /**
  86514. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86515. */
  86516. set colorGradingTexture(value: Nullable<BaseTexture>);
  86517. private _colorGradingEnabled;
  86518. /**
  86519. * Gets wether the color grading effect is enabled.
  86520. */
  86521. get colorGradingEnabled(): boolean;
  86522. /**
  86523. * Sets wether the color grading effect is enabled.
  86524. */
  86525. set colorGradingEnabled(value: boolean);
  86526. private _colorGradingWithGreenDepth;
  86527. /**
  86528. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86529. */
  86530. get colorGradingWithGreenDepth(): boolean;
  86531. /**
  86532. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86533. */
  86534. set colorGradingWithGreenDepth(value: boolean);
  86535. private _colorGradingBGR;
  86536. /**
  86537. * Gets wether the color grading texture contains BGR values.
  86538. */
  86539. get colorGradingBGR(): boolean;
  86540. /**
  86541. * Sets wether the color grading texture contains BGR values.
  86542. */
  86543. set colorGradingBGR(value: boolean);
  86544. /** @hidden */
  86545. _exposure: number;
  86546. /**
  86547. * Gets the Exposure used in the effect.
  86548. */
  86549. get exposure(): number;
  86550. /**
  86551. * Sets the Exposure used in the effect.
  86552. */
  86553. set exposure(value: number);
  86554. private _toneMappingEnabled;
  86555. /**
  86556. * Gets wether the tone mapping effect is enabled.
  86557. */
  86558. get toneMappingEnabled(): boolean;
  86559. /**
  86560. * Sets wether the tone mapping effect is enabled.
  86561. */
  86562. set toneMappingEnabled(value: boolean);
  86563. private _toneMappingType;
  86564. /**
  86565. * Gets the type of tone mapping effect.
  86566. */
  86567. get toneMappingType(): number;
  86568. /**
  86569. * Sets the type of tone mapping effect used in BabylonJS.
  86570. */
  86571. set toneMappingType(value: number);
  86572. protected _contrast: number;
  86573. /**
  86574. * Gets the contrast used in the effect.
  86575. */
  86576. get contrast(): number;
  86577. /**
  86578. * Sets the contrast used in the effect.
  86579. */
  86580. set contrast(value: number);
  86581. /**
  86582. * Vignette stretch size.
  86583. */
  86584. vignetteStretch: number;
  86585. /**
  86586. * Vignette centre X Offset.
  86587. */
  86588. vignetteCentreX: number;
  86589. /**
  86590. * Vignette centre Y Offset.
  86591. */
  86592. vignetteCentreY: number;
  86593. /**
  86594. * Vignette weight or intensity of the vignette effect.
  86595. */
  86596. vignetteWeight: number;
  86597. /**
  86598. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86599. * if vignetteEnabled is set to true.
  86600. */
  86601. vignetteColor: Color4;
  86602. /**
  86603. * Camera field of view used by the Vignette effect.
  86604. */
  86605. vignetteCameraFov: number;
  86606. private _vignetteBlendMode;
  86607. /**
  86608. * Gets the vignette blend mode allowing different kind of effect.
  86609. */
  86610. get vignetteBlendMode(): number;
  86611. /**
  86612. * Sets the vignette blend mode allowing different kind of effect.
  86613. */
  86614. set vignetteBlendMode(value: number);
  86615. private _vignetteEnabled;
  86616. /**
  86617. * Gets wether the vignette effect is enabled.
  86618. */
  86619. get vignetteEnabled(): boolean;
  86620. /**
  86621. * Sets wether the vignette effect is enabled.
  86622. */
  86623. set vignetteEnabled(value: boolean);
  86624. private _applyByPostProcess;
  86625. /**
  86626. * Gets wether the image processing is applied through a post process or not.
  86627. */
  86628. get applyByPostProcess(): boolean;
  86629. /**
  86630. * Sets wether the image processing is applied through a post process or not.
  86631. */
  86632. set applyByPostProcess(value: boolean);
  86633. private _isEnabled;
  86634. /**
  86635. * Gets wether the image processing is enabled or not.
  86636. */
  86637. get isEnabled(): boolean;
  86638. /**
  86639. * Sets wether the image processing is enabled or not.
  86640. */
  86641. set isEnabled(value: boolean);
  86642. /**
  86643. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86644. */
  86645. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86646. /**
  86647. * Method called each time the image processing information changes requires to recompile the effect.
  86648. */
  86649. protected _updateParameters(): void;
  86650. /**
  86651. * Gets the current class name.
  86652. * @return "ImageProcessingConfiguration"
  86653. */
  86654. getClassName(): string;
  86655. /**
  86656. * Prepare the list of uniforms associated with the Image Processing effects.
  86657. * @param uniforms The list of uniforms used in the effect
  86658. * @param defines the list of defines currently in use
  86659. */
  86660. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86661. /**
  86662. * Prepare the list of samplers associated with the Image Processing effects.
  86663. * @param samplersList The list of uniforms used in the effect
  86664. * @param defines the list of defines currently in use
  86665. */
  86666. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86667. /**
  86668. * Prepare the list of defines associated to the shader.
  86669. * @param defines the list of defines to complete
  86670. * @param forPostProcess Define if we are currently in post process mode or not
  86671. */
  86672. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86673. /**
  86674. * Returns true if all the image processing information are ready.
  86675. * @returns True if ready, otherwise, false
  86676. */
  86677. isReady(): boolean;
  86678. /**
  86679. * Binds the image processing to the shader.
  86680. * @param effect The effect to bind to
  86681. * @param overrideAspectRatio Override the aspect ratio of the effect
  86682. */
  86683. bind(effect: Effect, overrideAspectRatio?: number): void;
  86684. /**
  86685. * Clones the current image processing instance.
  86686. * @return The cloned image processing
  86687. */
  86688. clone(): ImageProcessingConfiguration;
  86689. /**
  86690. * Serializes the current image processing instance to a json representation.
  86691. * @return a JSON representation
  86692. */
  86693. serialize(): any;
  86694. /**
  86695. * Parses the image processing from a json representation.
  86696. * @param source the JSON source to parse
  86697. * @return The parsed image processing
  86698. */
  86699. static Parse(source: any): ImageProcessingConfiguration;
  86700. private static _VIGNETTEMODE_MULTIPLY;
  86701. private static _VIGNETTEMODE_OPAQUE;
  86702. /**
  86703. * Used to apply the vignette as a mix with the pixel color.
  86704. */
  86705. static get VIGNETTEMODE_MULTIPLY(): number;
  86706. /**
  86707. * Used to apply the vignette as a replacement of the pixel color.
  86708. */
  86709. static get VIGNETTEMODE_OPAQUE(): number;
  86710. }
  86711. }
  86712. declare module BABYLON {
  86713. /** @hidden */
  86714. export var postprocessVertexShader: {
  86715. name: string;
  86716. shader: string;
  86717. };
  86718. }
  86719. declare module BABYLON {
  86720. interface ThinEngine {
  86721. /**
  86722. * Creates a new render target texture
  86723. * @param size defines the size of the texture
  86724. * @param options defines the options used to create the texture
  86725. * @returns a new render target texture stored in an InternalTexture
  86726. */
  86727. createRenderTargetTexture(size: number | {
  86728. width: number;
  86729. height: number;
  86730. layers?: number;
  86731. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86732. /**
  86733. * Creates a depth stencil texture.
  86734. * This is only available in WebGL 2 or with the depth texture extension available.
  86735. * @param size The size of face edge in the texture.
  86736. * @param options The options defining the texture.
  86737. * @returns The texture
  86738. */
  86739. createDepthStencilTexture(size: number | {
  86740. width: number;
  86741. height: number;
  86742. layers?: number;
  86743. }, options: DepthTextureCreationOptions): InternalTexture;
  86744. /** @hidden */
  86745. _createDepthStencilTexture(size: number | {
  86746. width: number;
  86747. height: number;
  86748. layers?: number;
  86749. }, options: DepthTextureCreationOptions): InternalTexture;
  86750. }
  86751. }
  86752. declare module BABYLON {
  86753. /**
  86754. * Defines the kind of connection point for node based material
  86755. */
  86756. export enum NodeMaterialBlockConnectionPointTypes {
  86757. /** Float */
  86758. Float = 1,
  86759. /** Int */
  86760. Int = 2,
  86761. /** Vector2 */
  86762. Vector2 = 4,
  86763. /** Vector3 */
  86764. Vector3 = 8,
  86765. /** Vector4 */
  86766. Vector4 = 16,
  86767. /** Color3 */
  86768. Color3 = 32,
  86769. /** Color4 */
  86770. Color4 = 64,
  86771. /** Matrix */
  86772. Matrix = 128,
  86773. /** Custom object */
  86774. Object = 256,
  86775. /** Detect type based on connection */
  86776. AutoDetect = 1024,
  86777. /** Output type that will be defined by input type */
  86778. BasedOnInput = 2048
  86779. }
  86780. }
  86781. declare module BABYLON {
  86782. /**
  86783. * Enum used to define the target of a block
  86784. */
  86785. export enum NodeMaterialBlockTargets {
  86786. /** Vertex shader */
  86787. Vertex = 1,
  86788. /** Fragment shader */
  86789. Fragment = 2,
  86790. /** Neutral */
  86791. Neutral = 4,
  86792. /** Vertex and Fragment */
  86793. VertexAndFragment = 3
  86794. }
  86795. }
  86796. declare module BABYLON {
  86797. /**
  86798. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  86799. */
  86800. export enum NodeMaterialBlockConnectionPointMode {
  86801. /** Value is an uniform */
  86802. Uniform = 0,
  86803. /** Value is a mesh attribute */
  86804. Attribute = 1,
  86805. /** Value is a varying between vertex and fragment shaders */
  86806. Varying = 2,
  86807. /** Mode is undefined */
  86808. Undefined = 3
  86809. }
  86810. }
  86811. declare module BABYLON {
  86812. /**
  86813. * Enum used to define system values e.g. values automatically provided by the system
  86814. */
  86815. export enum NodeMaterialSystemValues {
  86816. /** World */
  86817. World = 1,
  86818. /** View */
  86819. View = 2,
  86820. /** Projection */
  86821. Projection = 3,
  86822. /** ViewProjection */
  86823. ViewProjection = 4,
  86824. /** WorldView */
  86825. WorldView = 5,
  86826. /** WorldViewProjection */
  86827. WorldViewProjection = 6,
  86828. /** CameraPosition */
  86829. CameraPosition = 7,
  86830. /** Fog Color */
  86831. FogColor = 8,
  86832. /** Delta time */
  86833. DeltaTime = 9
  86834. }
  86835. }
  86836. declare module BABYLON {
  86837. /** Defines supported spaces */
  86838. export enum Space {
  86839. /** Local (object) space */
  86840. LOCAL = 0,
  86841. /** World space */
  86842. WORLD = 1,
  86843. /** Bone space */
  86844. BONE = 2
  86845. }
  86846. /** Defines the 3 main axes */
  86847. export class Axis {
  86848. /** X axis */
  86849. static X: Vector3;
  86850. /** Y axis */
  86851. static Y: Vector3;
  86852. /** Z axis */
  86853. static Z: Vector3;
  86854. }
  86855. }
  86856. declare module BABYLON {
  86857. /**
  86858. * Represents a camera frustum
  86859. */
  86860. export class Frustum {
  86861. /**
  86862. * Gets the planes representing the frustum
  86863. * @param transform matrix to be applied to the returned planes
  86864. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  86865. */
  86866. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  86867. /**
  86868. * Gets the near frustum plane transformed by the transform matrix
  86869. * @param transform transformation matrix to be applied to the resulting frustum plane
  86870. * @param frustumPlane the resuling frustum plane
  86871. */
  86872. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86873. /**
  86874. * Gets the far frustum plane transformed by the transform matrix
  86875. * @param transform transformation matrix to be applied to the resulting frustum plane
  86876. * @param frustumPlane the resuling frustum plane
  86877. */
  86878. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86879. /**
  86880. * Gets the left frustum plane transformed by the transform matrix
  86881. * @param transform transformation matrix to be applied to the resulting frustum plane
  86882. * @param frustumPlane the resuling frustum plane
  86883. */
  86884. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86885. /**
  86886. * Gets the right frustum plane transformed by the transform matrix
  86887. * @param transform transformation matrix to be applied to the resulting frustum plane
  86888. * @param frustumPlane the resuling frustum plane
  86889. */
  86890. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86891. /**
  86892. * Gets the top frustum plane transformed by the transform matrix
  86893. * @param transform transformation matrix to be applied to the resulting frustum plane
  86894. * @param frustumPlane the resuling frustum plane
  86895. */
  86896. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86897. /**
  86898. * Gets the bottom frustum plane transformed by the transform matrix
  86899. * @param transform transformation matrix to be applied to the resulting frustum plane
  86900. * @param frustumPlane the resuling frustum plane
  86901. */
  86902. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86903. /**
  86904. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  86905. * @param transform transformation matrix to be applied to the resulting frustum planes
  86906. * @param frustumPlanes the resuling frustum planes
  86907. */
  86908. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  86909. }
  86910. }
  86911. declare module BABYLON {
  86912. /**
  86913. * Interface for the size containing width and height
  86914. */
  86915. export interface ISize {
  86916. /**
  86917. * Width
  86918. */
  86919. width: number;
  86920. /**
  86921. * Heighht
  86922. */
  86923. height: number;
  86924. }
  86925. /**
  86926. * Size containing widht and height
  86927. */
  86928. export class Size implements ISize {
  86929. /**
  86930. * Width
  86931. */
  86932. width: number;
  86933. /**
  86934. * Height
  86935. */
  86936. height: number;
  86937. /**
  86938. * Creates a Size object from the given width and height (floats).
  86939. * @param width width of the new size
  86940. * @param height height of the new size
  86941. */
  86942. constructor(width: number, height: number);
  86943. /**
  86944. * Returns a string with the Size width and height
  86945. * @returns a string with the Size width and height
  86946. */
  86947. toString(): string;
  86948. /**
  86949. * "Size"
  86950. * @returns the string "Size"
  86951. */
  86952. getClassName(): string;
  86953. /**
  86954. * Returns the Size hash code.
  86955. * @returns a hash code for a unique width and height
  86956. */
  86957. getHashCode(): number;
  86958. /**
  86959. * Updates the current size from the given one.
  86960. * @param src the given size
  86961. */
  86962. copyFrom(src: Size): void;
  86963. /**
  86964. * Updates in place the current Size from the given floats.
  86965. * @param width width of the new size
  86966. * @param height height of the new size
  86967. * @returns the updated Size.
  86968. */
  86969. copyFromFloats(width: number, height: number): Size;
  86970. /**
  86971. * Updates in place the current Size from the given floats.
  86972. * @param width width to set
  86973. * @param height height to set
  86974. * @returns the updated Size.
  86975. */
  86976. set(width: number, height: number): Size;
  86977. /**
  86978. * Multiplies the width and height by numbers
  86979. * @param w factor to multiple the width by
  86980. * @param h factor to multiple the height by
  86981. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86982. */
  86983. multiplyByFloats(w: number, h: number): Size;
  86984. /**
  86985. * Clones the size
  86986. * @returns a new Size copied from the given one.
  86987. */
  86988. clone(): Size;
  86989. /**
  86990. * True if the current Size and the given one width and height are strictly equal.
  86991. * @param other the other size to compare against
  86992. * @returns True if the current Size and the given one width and height are strictly equal.
  86993. */
  86994. equals(other: Size): boolean;
  86995. /**
  86996. * The surface of the Size : width * height (float).
  86997. */
  86998. get surface(): number;
  86999. /**
  87000. * Create a new size of zero
  87001. * @returns a new Size set to (0.0, 0.0)
  87002. */
  87003. static Zero(): Size;
  87004. /**
  87005. * Sums the width and height of two sizes
  87006. * @param otherSize size to add to this size
  87007. * @returns a new Size set as the addition result of the current Size and the given one.
  87008. */
  87009. add(otherSize: Size): Size;
  87010. /**
  87011. * Subtracts the width and height of two
  87012. * @param otherSize size to subtract to this size
  87013. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87014. */
  87015. subtract(otherSize: Size): Size;
  87016. /**
  87017. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87018. * @param start starting size to lerp between
  87019. * @param end end size to lerp between
  87020. * @param amount amount to lerp between the start and end values
  87021. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87022. */
  87023. static Lerp(start: Size, end: Size, amount: number): Size;
  87024. }
  87025. }
  87026. declare module BABYLON {
  87027. /**
  87028. * Contains position and normal vectors for a vertex
  87029. */
  87030. export class PositionNormalVertex {
  87031. /** the position of the vertex (defaut: 0,0,0) */
  87032. position: Vector3;
  87033. /** the normal of the vertex (defaut: 0,1,0) */
  87034. normal: Vector3;
  87035. /**
  87036. * Creates a PositionNormalVertex
  87037. * @param position the position of the vertex (defaut: 0,0,0)
  87038. * @param normal the normal of the vertex (defaut: 0,1,0)
  87039. */
  87040. constructor(
  87041. /** the position of the vertex (defaut: 0,0,0) */
  87042. position?: Vector3,
  87043. /** the normal of the vertex (defaut: 0,1,0) */
  87044. normal?: Vector3);
  87045. /**
  87046. * Clones the PositionNormalVertex
  87047. * @returns the cloned PositionNormalVertex
  87048. */
  87049. clone(): PositionNormalVertex;
  87050. }
  87051. /**
  87052. * Contains position, normal and uv vectors for a vertex
  87053. */
  87054. export class PositionNormalTextureVertex {
  87055. /** the position of the vertex (defaut: 0,0,0) */
  87056. position: Vector3;
  87057. /** the normal of the vertex (defaut: 0,1,0) */
  87058. normal: Vector3;
  87059. /** the uv of the vertex (default: 0,0) */
  87060. uv: Vector2;
  87061. /**
  87062. * Creates a PositionNormalTextureVertex
  87063. * @param position the position of the vertex (defaut: 0,0,0)
  87064. * @param normal the normal of the vertex (defaut: 0,1,0)
  87065. * @param uv the uv of the vertex (default: 0,0)
  87066. */
  87067. constructor(
  87068. /** the position of the vertex (defaut: 0,0,0) */
  87069. position?: Vector3,
  87070. /** the normal of the vertex (defaut: 0,1,0) */
  87071. normal?: Vector3,
  87072. /** the uv of the vertex (default: 0,0) */
  87073. uv?: Vector2);
  87074. /**
  87075. * Clones the PositionNormalTextureVertex
  87076. * @returns the cloned PositionNormalTextureVertex
  87077. */
  87078. clone(): PositionNormalTextureVertex;
  87079. }
  87080. }
  87081. declare module BABYLON {
  87082. /**
  87083. * Enum defining the type of animations supported by InputBlock
  87084. */
  87085. export enum AnimatedInputBlockTypes {
  87086. /** No animation */
  87087. None = 0,
  87088. /** Time based animation. Will only work for floats */
  87089. Time = 1
  87090. }
  87091. }
  87092. declare module BABYLON {
  87093. /**
  87094. * Interface describing all the common properties and methods a shadow light needs to implement.
  87095. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87096. * as well as binding the different shadow properties to the effects.
  87097. */
  87098. export interface IShadowLight extends Light {
  87099. /**
  87100. * The light id in the scene (used in scene.findLighById for instance)
  87101. */
  87102. id: string;
  87103. /**
  87104. * The position the shdow will be casted from.
  87105. */
  87106. position: Vector3;
  87107. /**
  87108. * In 2d mode (needCube being false), the direction used to cast the shadow.
  87109. */
  87110. direction: Vector3;
  87111. /**
  87112. * The transformed position. Position of the light in world space taking parenting in account.
  87113. */
  87114. transformedPosition: Vector3;
  87115. /**
  87116. * The transformed direction. Direction of the light in world space taking parenting in account.
  87117. */
  87118. transformedDirection: Vector3;
  87119. /**
  87120. * The friendly name of the light in the scene.
  87121. */
  87122. name: string;
  87123. /**
  87124. * Defines the shadow projection clipping minimum z value.
  87125. */
  87126. shadowMinZ: number;
  87127. /**
  87128. * Defines the shadow projection clipping maximum z value.
  87129. */
  87130. shadowMaxZ: number;
  87131. /**
  87132. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87133. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87134. */
  87135. computeTransformedInformation(): boolean;
  87136. /**
  87137. * Gets the scene the light belongs to.
  87138. * @returns The scene
  87139. */
  87140. getScene(): Scene;
  87141. /**
  87142. * Callback defining a custom Projection Matrix Builder.
  87143. * This can be used to override the default projection matrix computation.
  87144. */
  87145. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87146. /**
  87147. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87148. * @param matrix The materix to updated with the projection information
  87149. * @param viewMatrix The transform matrix of the light
  87150. * @param renderList The list of mesh to render in the map
  87151. * @returns The current light
  87152. */
  87153. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87154. /**
  87155. * Gets the current depth scale used in ESM.
  87156. * @returns The scale
  87157. */
  87158. getDepthScale(): number;
  87159. /**
  87160. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87161. * @returns true if a cube texture needs to be use
  87162. */
  87163. needCube(): boolean;
  87164. /**
  87165. * Detects if the projection matrix requires to be recomputed this frame.
  87166. * @returns true if it requires to be recomputed otherwise, false.
  87167. */
  87168. needProjectionMatrixCompute(): boolean;
  87169. /**
  87170. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87171. */
  87172. forceProjectionMatrixCompute(): void;
  87173. /**
  87174. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87175. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87176. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87177. */
  87178. getShadowDirection(faceIndex?: number): Vector3;
  87179. /**
  87180. * Gets the minZ used for shadow according to both the scene and the light.
  87181. * @param activeCamera The camera we are returning the min for
  87182. * @returns the depth min z
  87183. */
  87184. getDepthMinZ(activeCamera: Camera): number;
  87185. /**
  87186. * Gets the maxZ used for shadow according to both the scene and the light.
  87187. * @param activeCamera The camera we are returning the max for
  87188. * @returns the depth max z
  87189. */
  87190. getDepthMaxZ(activeCamera: Camera): number;
  87191. }
  87192. /**
  87193. * Base implementation IShadowLight
  87194. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  87195. */
  87196. export abstract class ShadowLight extends Light implements IShadowLight {
  87197. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  87198. protected _position: Vector3;
  87199. protected _setPosition(value: Vector3): void;
  87200. /**
  87201. * Sets the position the shadow will be casted from. Also use as the light position for both
  87202. * point and spot lights.
  87203. */
  87204. get position(): Vector3;
  87205. /**
  87206. * Sets the position the shadow will be casted from. Also use as the light position for both
  87207. * point and spot lights.
  87208. */
  87209. set position(value: Vector3);
  87210. protected _direction: Vector3;
  87211. protected _setDirection(value: Vector3): void;
  87212. /**
  87213. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  87214. * Also use as the light direction on spot and directional lights.
  87215. */
  87216. get direction(): Vector3;
  87217. /**
  87218. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  87219. * Also use as the light direction on spot and directional lights.
  87220. */
  87221. set direction(value: Vector3);
  87222. protected _shadowMinZ: number;
  87223. /**
  87224. * Gets the shadow projection clipping minimum z value.
  87225. */
  87226. get shadowMinZ(): number;
  87227. /**
  87228. * Sets the shadow projection clipping minimum z value.
  87229. */
  87230. set shadowMinZ(value: number);
  87231. protected _shadowMaxZ: number;
  87232. /**
  87233. * Sets the shadow projection clipping maximum z value.
  87234. */
  87235. get shadowMaxZ(): number;
  87236. /**
  87237. * Gets the shadow projection clipping maximum z value.
  87238. */
  87239. set shadowMaxZ(value: number);
  87240. /**
  87241. * Callback defining a custom Projection Matrix Builder.
  87242. * This can be used to override the default projection matrix computation.
  87243. */
  87244. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87245. /**
  87246. * The transformed position. Position of the light in world space taking parenting in account.
  87247. */
  87248. transformedPosition: Vector3;
  87249. /**
  87250. * The transformed direction. Direction of the light in world space taking parenting in account.
  87251. */
  87252. transformedDirection: Vector3;
  87253. private _needProjectionMatrixCompute;
  87254. /**
  87255. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87256. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87257. */
  87258. computeTransformedInformation(): boolean;
  87259. /**
  87260. * Return the depth scale used for the shadow map.
  87261. * @returns the depth scale.
  87262. */
  87263. getDepthScale(): number;
  87264. /**
  87265. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87266. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87267. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87268. */
  87269. getShadowDirection(faceIndex?: number): Vector3;
  87270. /**
  87271. * Returns the ShadowLight absolute position in the World.
  87272. * @returns the position vector in world space
  87273. */
  87274. getAbsolutePosition(): Vector3;
  87275. /**
  87276. * Sets the ShadowLight direction toward the passed target.
  87277. * @param target The point to target in local space
  87278. * @returns the updated ShadowLight direction
  87279. */
  87280. setDirectionToTarget(target: Vector3): Vector3;
  87281. /**
  87282. * Returns the light rotation in euler definition.
  87283. * @returns the x y z rotation in local space.
  87284. */
  87285. getRotation(): Vector3;
  87286. /**
  87287. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87288. * @returns true if a cube texture needs to be use
  87289. */
  87290. needCube(): boolean;
  87291. /**
  87292. * Detects if the projection matrix requires to be recomputed this frame.
  87293. * @returns true if it requires to be recomputed otherwise, false.
  87294. */
  87295. needProjectionMatrixCompute(): boolean;
  87296. /**
  87297. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87298. */
  87299. forceProjectionMatrixCompute(): void;
  87300. /** @hidden */
  87301. _initCache(): void;
  87302. /** @hidden */
  87303. _isSynchronized(): boolean;
  87304. /**
  87305. * Computes the world matrix of the node
  87306. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87307. * @returns the world matrix
  87308. */
  87309. computeWorldMatrix(force?: boolean): Matrix;
  87310. /**
  87311. * Gets the minZ used for shadow according to both the scene and the light.
  87312. * @param activeCamera The camera we are returning the min for
  87313. * @returns the depth min z
  87314. */
  87315. getDepthMinZ(activeCamera: Camera): number;
  87316. /**
  87317. * Gets the maxZ used for shadow according to both the scene and the light.
  87318. * @param activeCamera The camera we are returning the max for
  87319. * @returns the depth max z
  87320. */
  87321. getDepthMaxZ(activeCamera: Camera): number;
  87322. /**
  87323. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87324. * @param matrix The materix to updated with the projection information
  87325. * @param viewMatrix The transform matrix of the light
  87326. * @param renderList The list of mesh to render in the map
  87327. * @returns The current light
  87328. */
  87329. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87330. }
  87331. }
  87332. declare module BABYLON {
  87333. /** @hidden */
  87334. export var packingFunctions: {
  87335. name: string;
  87336. shader: string;
  87337. };
  87338. }
  87339. declare module BABYLON {
  87340. /** @hidden */
  87341. export var bayerDitherFunctions: {
  87342. name: string;
  87343. shader: string;
  87344. };
  87345. }
  87346. declare module BABYLON {
  87347. /** @hidden */
  87348. export var shadowMapFragmentDeclaration: {
  87349. name: string;
  87350. shader: string;
  87351. };
  87352. }
  87353. declare module BABYLON {
  87354. /** @hidden */
  87355. export var clipPlaneFragmentDeclaration: {
  87356. name: string;
  87357. shader: string;
  87358. };
  87359. }
  87360. declare module BABYLON {
  87361. /** @hidden */
  87362. export var clipPlaneFragment: {
  87363. name: string;
  87364. shader: string;
  87365. };
  87366. }
  87367. declare module BABYLON {
  87368. /** @hidden */
  87369. export var shadowMapFragment: {
  87370. name: string;
  87371. shader: string;
  87372. };
  87373. }
  87374. declare module BABYLON {
  87375. /** @hidden */
  87376. export var shadowMapPixelShader: {
  87377. name: string;
  87378. shader: string;
  87379. };
  87380. }
  87381. declare module BABYLON {
  87382. /** @hidden */
  87383. export var bonesDeclaration: {
  87384. name: string;
  87385. shader: string;
  87386. };
  87387. }
  87388. declare module BABYLON {
  87389. /** @hidden */
  87390. export var morphTargetsVertexGlobalDeclaration: {
  87391. name: string;
  87392. shader: string;
  87393. };
  87394. }
  87395. declare module BABYLON {
  87396. /** @hidden */
  87397. export var morphTargetsVertexDeclaration: {
  87398. name: string;
  87399. shader: string;
  87400. };
  87401. }
  87402. declare module BABYLON {
  87403. /** @hidden */
  87404. export var instancesDeclaration: {
  87405. name: string;
  87406. shader: string;
  87407. };
  87408. }
  87409. declare module BABYLON {
  87410. /** @hidden */
  87411. export var helperFunctions: {
  87412. name: string;
  87413. shader: string;
  87414. };
  87415. }
  87416. declare module BABYLON {
  87417. /** @hidden */
  87418. export var shadowMapVertexDeclaration: {
  87419. name: string;
  87420. shader: string;
  87421. };
  87422. }
  87423. declare module BABYLON {
  87424. /** @hidden */
  87425. export var clipPlaneVertexDeclaration: {
  87426. name: string;
  87427. shader: string;
  87428. };
  87429. }
  87430. declare module BABYLON {
  87431. /** @hidden */
  87432. export var morphTargetsVertex: {
  87433. name: string;
  87434. shader: string;
  87435. };
  87436. }
  87437. declare module BABYLON {
  87438. /** @hidden */
  87439. export var instancesVertex: {
  87440. name: string;
  87441. shader: string;
  87442. };
  87443. }
  87444. declare module BABYLON {
  87445. /** @hidden */
  87446. export var bonesVertex: {
  87447. name: string;
  87448. shader: string;
  87449. };
  87450. }
  87451. declare module BABYLON {
  87452. /** @hidden */
  87453. export var shadowMapVertexNormalBias: {
  87454. name: string;
  87455. shader: string;
  87456. };
  87457. }
  87458. declare module BABYLON {
  87459. /** @hidden */
  87460. export var shadowMapVertexMetric: {
  87461. name: string;
  87462. shader: string;
  87463. };
  87464. }
  87465. declare module BABYLON {
  87466. /** @hidden */
  87467. export var clipPlaneVertex: {
  87468. name: string;
  87469. shader: string;
  87470. };
  87471. }
  87472. declare module BABYLON {
  87473. /** @hidden */
  87474. export var shadowMapVertexShader: {
  87475. name: string;
  87476. shader: string;
  87477. };
  87478. }
  87479. declare module BABYLON {
  87480. /** @hidden */
  87481. export var depthBoxBlurPixelShader: {
  87482. name: string;
  87483. shader: string;
  87484. };
  87485. }
  87486. declare module BABYLON {
  87487. /** @hidden */
  87488. export var shadowMapFragmentSoftTransparentShadow: {
  87489. name: string;
  87490. shader: string;
  87491. };
  87492. }
  87493. declare module BABYLON {
  87494. /**
  87495. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87496. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87497. */
  87498. export class EffectFallbacks implements IEffectFallbacks {
  87499. private _defines;
  87500. private _currentRank;
  87501. private _maxRank;
  87502. private _mesh;
  87503. /**
  87504. * Removes the fallback from the bound mesh.
  87505. */
  87506. unBindMesh(): void;
  87507. /**
  87508. * Adds a fallback on the specified property.
  87509. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87510. * @param define The name of the define in the shader
  87511. */
  87512. addFallback(rank: number, define: string): void;
  87513. /**
  87514. * Sets the mesh to use CPU skinning when needing to fallback.
  87515. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87516. * @param mesh The mesh to use the fallbacks.
  87517. */
  87518. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87519. /**
  87520. * Checks to see if more fallbacks are still availible.
  87521. */
  87522. get hasMoreFallbacks(): boolean;
  87523. /**
  87524. * Removes the defines that should be removed when falling back.
  87525. * @param currentDefines defines the current define statements for the shader.
  87526. * @param effect defines the current effect we try to compile
  87527. * @returns The resulting defines with defines of the current rank removed.
  87528. */
  87529. reduce(currentDefines: string, effect: Effect): string;
  87530. }
  87531. }
  87532. declare module BABYLON {
  87533. /**
  87534. * Interface used to define Action
  87535. */
  87536. export interface IAction {
  87537. /**
  87538. * Trigger for the action
  87539. */
  87540. trigger: number;
  87541. /** Options of the trigger */
  87542. triggerOptions: any;
  87543. /**
  87544. * Gets the trigger parameters
  87545. * @returns the trigger parameters
  87546. */
  87547. getTriggerParameter(): any;
  87548. /**
  87549. * Internal only - executes current action event
  87550. * @hidden
  87551. */
  87552. _executeCurrent(evt?: ActionEvent): void;
  87553. /**
  87554. * Serialize placeholder for child classes
  87555. * @param parent of child
  87556. * @returns the serialized object
  87557. */
  87558. serialize(parent: any): any;
  87559. /**
  87560. * Internal only
  87561. * @hidden
  87562. */
  87563. _prepare(): void;
  87564. /**
  87565. * Internal only - manager for action
  87566. * @hidden
  87567. */
  87568. _actionManager: AbstractActionManager;
  87569. /**
  87570. * Adds action to chain of actions, may be a DoNothingAction
  87571. * @param action defines the next action to execute
  87572. * @returns The action passed in
  87573. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87574. */
  87575. then(action: IAction): IAction;
  87576. }
  87577. /**
  87578. * The action to be carried out following a trigger
  87579. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  87580. */
  87581. export class Action implements IAction {
  87582. /** the trigger, with or without parameters, for the action */
  87583. triggerOptions: any;
  87584. /**
  87585. * Trigger for the action
  87586. */
  87587. trigger: number;
  87588. /**
  87589. * Internal only - manager for action
  87590. * @hidden
  87591. */
  87592. _actionManager: ActionManager;
  87593. private _nextActiveAction;
  87594. private _child;
  87595. private _condition?;
  87596. private _triggerParameter;
  87597. /**
  87598. * An event triggered prior to action being executed.
  87599. */
  87600. onBeforeExecuteObservable: Observable<Action>;
  87601. /**
  87602. * Creates a new Action
  87603. * @param triggerOptions the trigger, with or without parameters, for the action
  87604. * @param condition an optional determinant of action
  87605. */
  87606. constructor(
  87607. /** the trigger, with or without parameters, for the action */
  87608. triggerOptions: any, condition?: Condition);
  87609. /**
  87610. * Internal only
  87611. * @hidden
  87612. */
  87613. _prepare(): void;
  87614. /**
  87615. * Gets the trigger parameters
  87616. * @returns the trigger parameters
  87617. */
  87618. getTriggerParameter(): any;
  87619. /**
  87620. * Internal only - executes current action event
  87621. * @hidden
  87622. */
  87623. _executeCurrent(evt?: ActionEvent): void;
  87624. /**
  87625. * Execute placeholder for child classes
  87626. * @param evt optional action event
  87627. */
  87628. execute(evt?: ActionEvent): void;
  87629. /**
  87630. * Skips to next active action
  87631. */
  87632. skipToNextActiveAction(): void;
  87633. /**
  87634. * Adds action to chain of actions, may be a DoNothingAction
  87635. * @param action defines the next action to execute
  87636. * @returns The action passed in
  87637. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87638. */
  87639. then(action: Action): Action;
  87640. /**
  87641. * Internal only
  87642. * @hidden
  87643. */
  87644. _getProperty(propertyPath: string): string;
  87645. /**
  87646. * Internal only
  87647. * @hidden
  87648. */
  87649. _getEffectiveTarget(target: any, propertyPath: string): any;
  87650. /**
  87651. * Serialize placeholder for child classes
  87652. * @param parent of child
  87653. * @returns the serialized object
  87654. */
  87655. serialize(parent: any): any;
  87656. /**
  87657. * Internal only called by serialize
  87658. * @hidden
  87659. */
  87660. protected _serialize(serializedAction: any, parent?: any): any;
  87661. /**
  87662. * Internal only
  87663. * @hidden
  87664. */
  87665. static _SerializeValueAsString: (value: any) => string;
  87666. /**
  87667. * Internal only
  87668. * @hidden
  87669. */
  87670. static _GetTargetProperty: (target: Scene | Node) => {
  87671. name: string;
  87672. targetType: string;
  87673. value: string;
  87674. };
  87675. }
  87676. }
  87677. declare module BABYLON {
  87678. /**
  87679. * A Condition applied to an Action
  87680. */
  87681. export class Condition {
  87682. /**
  87683. * Internal only - manager for action
  87684. * @hidden
  87685. */
  87686. _actionManager: ActionManager;
  87687. /**
  87688. * Internal only
  87689. * @hidden
  87690. */
  87691. _evaluationId: number;
  87692. /**
  87693. * Internal only
  87694. * @hidden
  87695. */
  87696. _currentResult: boolean;
  87697. /**
  87698. * Creates a new Condition
  87699. * @param actionManager the manager of the action the condition is applied to
  87700. */
  87701. constructor(actionManager: ActionManager);
  87702. /**
  87703. * Check if the current condition is valid
  87704. * @returns a boolean
  87705. */
  87706. isValid(): boolean;
  87707. /**
  87708. * Internal only
  87709. * @hidden
  87710. */
  87711. _getProperty(propertyPath: string): string;
  87712. /**
  87713. * Internal only
  87714. * @hidden
  87715. */
  87716. _getEffectiveTarget(target: any, propertyPath: string): any;
  87717. /**
  87718. * Serialize placeholder for child classes
  87719. * @returns the serialized object
  87720. */
  87721. serialize(): any;
  87722. /**
  87723. * Internal only
  87724. * @hidden
  87725. */
  87726. protected _serialize(serializedCondition: any): any;
  87727. }
  87728. /**
  87729. * Defines specific conditional operators as extensions of Condition
  87730. */
  87731. export class ValueCondition extends Condition {
  87732. /** path to specify the property of the target the conditional operator uses */
  87733. propertyPath: string;
  87734. /** the value compared by the conditional operator against the current value of the property */
  87735. value: any;
  87736. /** the conditional operator, default ValueCondition.IsEqual */
  87737. operator: number;
  87738. /**
  87739. * Internal only
  87740. * @hidden
  87741. */
  87742. private static _IsEqual;
  87743. /**
  87744. * Internal only
  87745. * @hidden
  87746. */
  87747. private static _IsDifferent;
  87748. /**
  87749. * Internal only
  87750. * @hidden
  87751. */
  87752. private static _IsGreater;
  87753. /**
  87754. * Internal only
  87755. * @hidden
  87756. */
  87757. private static _IsLesser;
  87758. /**
  87759. * returns the number for IsEqual
  87760. */
  87761. static get IsEqual(): number;
  87762. /**
  87763. * Returns the number for IsDifferent
  87764. */
  87765. static get IsDifferent(): number;
  87766. /**
  87767. * Returns the number for IsGreater
  87768. */
  87769. static get IsGreater(): number;
  87770. /**
  87771. * Returns the number for IsLesser
  87772. */
  87773. static get IsLesser(): number;
  87774. /**
  87775. * Internal only The action manager for the condition
  87776. * @hidden
  87777. */
  87778. _actionManager: ActionManager;
  87779. /**
  87780. * Internal only
  87781. * @hidden
  87782. */
  87783. private _target;
  87784. /**
  87785. * Internal only
  87786. * @hidden
  87787. */
  87788. private _effectiveTarget;
  87789. /**
  87790. * Internal only
  87791. * @hidden
  87792. */
  87793. private _property;
  87794. /**
  87795. * Creates a new ValueCondition
  87796. * @param actionManager manager for the action the condition applies to
  87797. * @param target for the action
  87798. * @param propertyPath path to specify the property of the target the conditional operator uses
  87799. * @param value the value compared by the conditional operator against the current value of the property
  87800. * @param operator the conditional operator, default ValueCondition.IsEqual
  87801. */
  87802. constructor(actionManager: ActionManager, target: any,
  87803. /** path to specify the property of the target the conditional operator uses */
  87804. propertyPath: string,
  87805. /** the value compared by the conditional operator against the current value of the property */
  87806. value: any,
  87807. /** the conditional operator, default ValueCondition.IsEqual */
  87808. operator?: number);
  87809. /**
  87810. * Compares the given value with the property value for the specified conditional operator
  87811. * @returns the result of the comparison
  87812. */
  87813. isValid(): boolean;
  87814. /**
  87815. * Serialize the ValueCondition into a JSON compatible object
  87816. * @returns serialization object
  87817. */
  87818. serialize(): any;
  87819. /**
  87820. * Gets the name of the conditional operator for the ValueCondition
  87821. * @param operator the conditional operator
  87822. * @returns the name
  87823. */
  87824. static GetOperatorName(operator: number): string;
  87825. }
  87826. /**
  87827. * Defines a predicate condition as an extension of Condition
  87828. */
  87829. export class PredicateCondition extends Condition {
  87830. /** defines the predicate function used to validate the condition */
  87831. predicate: () => boolean;
  87832. /**
  87833. * Internal only - manager for action
  87834. * @hidden
  87835. */
  87836. _actionManager: ActionManager;
  87837. /**
  87838. * Creates a new PredicateCondition
  87839. * @param actionManager manager for the action the condition applies to
  87840. * @param predicate defines the predicate function used to validate the condition
  87841. */
  87842. constructor(actionManager: ActionManager,
  87843. /** defines the predicate function used to validate the condition */
  87844. predicate: () => boolean);
  87845. /**
  87846. * @returns the validity of the predicate condition
  87847. */
  87848. isValid(): boolean;
  87849. }
  87850. /**
  87851. * Defines a state condition as an extension of Condition
  87852. */
  87853. export class StateCondition extends Condition {
  87854. /** Value to compare with target state */
  87855. value: string;
  87856. /**
  87857. * Internal only - manager for action
  87858. * @hidden
  87859. */
  87860. _actionManager: ActionManager;
  87861. /**
  87862. * Internal only
  87863. * @hidden
  87864. */
  87865. private _target;
  87866. /**
  87867. * Creates a new StateCondition
  87868. * @param actionManager manager for the action the condition applies to
  87869. * @param target of the condition
  87870. * @param value to compare with target state
  87871. */
  87872. constructor(actionManager: ActionManager, target: any,
  87873. /** Value to compare with target state */
  87874. value: string);
  87875. /**
  87876. * Gets a boolean indicating if the current condition is met
  87877. * @returns the validity of the state
  87878. */
  87879. isValid(): boolean;
  87880. /**
  87881. * Serialize the StateCondition into a JSON compatible object
  87882. * @returns serialization object
  87883. */
  87884. serialize(): any;
  87885. }
  87886. }
  87887. declare module BABYLON {
  87888. /**
  87889. * This defines an action responsible to toggle a boolean once triggered.
  87890. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87891. */
  87892. export class SwitchBooleanAction extends Action {
  87893. /**
  87894. * The path to the boolean property in the target object
  87895. */
  87896. propertyPath: string;
  87897. private _target;
  87898. private _effectiveTarget;
  87899. private _property;
  87900. /**
  87901. * Instantiate the action
  87902. * @param triggerOptions defines the trigger options
  87903. * @param target defines the object containing the boolean
  87904. * @param propertyPath defines the path to the boolean property in the target object
  87905. * @param condition defines the trigger related conditions
  87906. */
  87907. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  87908. /** @hidden */
  87909. _prepare(): void;
  87910. /**
  87911. * Execute the action toggle the boolean value.
  87912. */
  87913. execute(): void;
  87914. /**
  87915. * Serializes the actions and its related information.
  87916. * @param parent defines the object to serialize in
  87917. * @returns the serialized object
  87918. */
  87919. serialize(parent: any): any;
  87920. }
  87921. /**
  87922. * This defines an action responsible to set a the state field of the target
  87923. * to a desired value once triggered.
  87924. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87925. */
  87926. export class SetStateAction extends Action {
  87927. /**
  87928. * The value to store in the state field.
  87929. */
  87930. value: string;
  87931. private _target;
  87932. /**
  87933. * Instantiate the action
  87934. * @param triggerOptions defines the trigger options
  87935. * @param target defines the object containing the state property
  87936. * @param value defines the value to store in the state field
  87937. * @param condition defines the trigger related conditions
  87938. */
  87939. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  87940. /**
  87941. * Execute the action and store the value on the target state property.
  87942. */
  87943. execute(): void;
  87944. /**
  87945. * Serializes the actions and its related information.
  87946. * @param parent defines the object to serialize in
  87947. * @returns the serialized object
  87948. */
  87949. serialize(parent: any): any;
  87950. }
  87951. /**
  87952. * This defines an action responsible to set a property of the target
  87953. * to a desired value once triggered.
  87954. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87955. */
  87956. export class SetValueAction extends Action {
  87957. /**
  87958. * The path of the property to set in the target.
  87959. */
  87960. propertyPath: string;
  87961. /**
  87962. * The value to set in the property
  87963. */
  87964. value: any;
  87965. private _target;
  87966. private _effectiveTarget;
  87967. private _property;
  87968. /**
  87969. * Instantiate the action
  87970. * @param triggerOptions defines the trigger options
  87971. * @param target defines the object containing the property
  87972. * @param propertyPath defines the path of the property to set in the target
  87973. * @param value defines the value to set in the property
  87974. * @param condition defines the trigger related conditions
  87975. */
  87976. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87977. /** @hidden */
  87978. _prepare(): void;
  87979. /**
  87980. * Execute the action and set the targetted property to the desired value.
  87981. */
  87982. execute(): void;
  87983. /**
  87984. * Serializes the actions and its related information.
  87985. * @param parent defines the object to serialize in
  87986. * @returns the serialized object
  87987. */
  87988. serialize(parent: any): any;
  87989. }
  87990. /**
  87991. * This defines an action responsible to increment the target value
  87992. * to a desired value once triggered.
  87993. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87994. */
  87995. export class IncrementValueAction extends Action {
  87996. /**
  87997. * The path of the property to increment in the target.
  87998. */
  87999. propertyPath: string;
  88000. /**
  88001. * The value we should increment the property by.
  88002. */
  88003. value: any;
  88004. private _target;
  88005. private _effectiveTarget;
  88006. private _property;
  88007. /**
  88008. * Instantiate the action
  88009. * @param triggerOptions defines the trigger options
  88010. * @param target defines the object containing the property
  88011. * @param propertyPath defines the path of the property to increment in the target
  88012. * @param value defines the value value we should increment the property by
  88013. * @param condition defines the trigger related conditions
  88014. */
  88015. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88016. /** @hidden */
  88017. _prepare(): void;
  88018. /**
  88019. * Execute the action and increment the target of the value amount.
  88020. */
  88021. execute(): void;
  88022. /**
  88023. * Serializes the actions and its related information.
  88024. * @param parent defines the object to serialize in
  88025. * @returns the serialized object
  88026. */
  88027. serialize(parent: any): any;
  88028. }
  88029. /**
  88030. * This defines an action responsible to start an animation once triggered.
  88031. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88032. */
  88033. export class PlayAnimationAction extends Action {
  88034. /**
  88035. * Where the animation should start (animation frame)
  88036. */
  88037. from: number;
  88038. /**
  88039. * Where the animation should stop (animation frame)
  88040. */
  88041. to: number;
  88042. /**
  88043. * Define if the animation should loop or stop after the first play.
  88044. */
  88045. loop?: boolean;
  88046. private _target;
  88047. /**
  88048. * Instantiate the action
  88049. * @param triggerOptions defines the trigger options
  88050. * @param target defines the target animation or animation name
  88051. * @param from defines from where the animation should start (animation frame)
  88052. * @param end defines where the animation should stop (animation frame)
  88053. * @param loop defines if the animation should loop or stop after the first play
  88054. * @param condition defines the trigger related conditions
  88055. */
  88056. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88057. /** @hidden */
  88058. _prepare(): void;
  88059. /**
  88060. * Execute the action and play the animation.
  88061. */
  88062. execute(): void;
  88063. /**
  88064. * Serializes the actions and its related information.
  88065. * @param parent defines the object to serialize in
  88066. * @returns the serialized object
  88067. */
  88068. serialize(parent: any): any;
  88069. }
  88070. /**
  88071. * This defines an action responsible to stop an animation once triggered.
  88072. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88073. */
  88074. export class StopAnimationAction extends Action {
  88075. private _target;
  88076. /**
  88077. * Instantiate the action
  88078. * @param triggerOptions defines the trigger options
  88079. * @param target defines the target animation or animation name
  88080. * @param condition defines the trigger related conditions
  88081. */
  88082. constructor(triggerOptions: any, target: any, condition?: Condition);
  88083. /** @hidden */
  88084. _prepare(): void;
  88085. /**
  88086. * Execute the action and stop the animation.
  88087. */
  88088. execute(): void;
  88089. /**
  88090. * Serializes the actions and its related information.
  88091. * @param parent defines the object to serialize in
  88092. * @returns the serialized object
  88093. */
  88094. serialize(parent: any): any;
  88095. }
  88096. /**
  88097. * This defines an action responsible that does nothing once triggered.
  88098. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88099. */
  88100. export class DoNothingAction extends Action {
  88101. /**
  88102. * Instantiate the action
  88103. * @param triggerOptions defines the trigger options
  88104. * @param condition defines the trigger related conditions
  88105. */
  88106. constructor(triggerOptions?: any, condition?: Condition);
  88107. /**
  88108. * Execute the action and do nothing.
  88109. */
  88110. execute(): void;
  88111. /**
  88112. * Serializes the actions and its related information.
  88113. * @param parent defines the object to serialize in
  88114. * @returns the serialized object
  88115. */
  88116. serialize(parent: any): any;
  88117. }
  88118. /**
  88119. * This defines an action responsible to trigger several actions once triggered.
  88120. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88121. */
  88122. export class CombineAction extends Action {
  88123. /**
  88124. * The list of aggregated animations to run.
  88125. */
  88126. children: Action[];
  88127. /**
  88128. * Instantiate the action
  88129. * @param triggerOptions defines the trigger options
  88130. * @param children defines the list of aggregated animations to run
  88131. * @param condition defines the trigger related conditions
  88132. */
  88133. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  88134. /** @hidden */
  88135. _prepare(): void;
  88136. /**
  88137. * Execute the action and executes all the aggregated actions.
  88138. */
  88139. execute(evt: ActionEvent): void;
  88140. /**
  88141. * Serializes the actions and its related information.
  88142. * @param parent defines the object to serialize in
  88143. * @returns the serialized object
  88144. */
  88145. serialize(parent: any): any;
  88146. }
  88147. /**
  88148. * This defines an action responsible to run code (external event) once triggered.
  88149. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88150. */
  88151. export class ExecuteCodeAction extends Action {
  88152. /**
  88153. * The callback function to run.
  88154. */
  88155. func: (evt: ActionEvent) => void;
  88156. /**
  88157. * Instantiate the action
  88158. * @param triggerOptions defines the trigger options
  88159. * @param func defines the callback function to run
  88160. * @param condition defines the trigger related conditions
  88161. */
  88162. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  88163. /**
  88164. * Execute the action and run the attached code.
  88165. */
  88166. execute(evt: ActionEvent): void;
  88167. }
  88168. /**
  88169. * This defines an action responsible to set the parent property of the target once triggered.
  88170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88171. */
  88172. export class SetParentAction extends Action {
  88173. private _parent;
  88174. private _target;
  88175. /**
  88176. * Instantiate the action
  88177. * @param triggerOptions defines the trigger options
  88178. * @param target defines the target containing the parent property
  88179. * @param parent defines from where the animation should start (animation frame)
  88180. * @param condition defines the trigger related conditions
  88181. */
  88182. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  88183. /** @hidden */
  88184. _prepare(): void;
  88185. /**
  88186. * Execute the action and set the parent property.
  88187. */
  88188. execute(): void;
  88189. /**
  88190. * Serializes the actions and its related information.
  88191. * @param parent defines the object to serialize in
  88192. * @returns the serialized object
  88193. */
  88194. serialize(parent: any): any;
  88195. }
  88196. }
  88197. declare module BABYLON {
  88198. /**
  88199. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  88200. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  88201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88202. */
  88203. export class ActionManager extends AbstractActionManager {
  88204. /**
  88205. * Nothing
  88206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88207. */
  88208. static readonly NothingTrigger: number;
  88209. /**
  88210. * On pick
  88211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88212. */
  88213. static readonly OnPickTrigger: number;
  88214. /**
  88215. * On left pick
  88216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88217. */
  88218. static readonly OnLeftPickTrigger: number;
  88219. /**
  88220. * On right pick
  88221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88222. */
  88223. static readonly OnRightPickTrigger: number;
  88224. /**
  88225. * On center pick
  88226. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88227. */
  88228. static readonly OnCenterPickTrigger: number;
  88229. /**
  88230. * On pick down
  88231. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88232. */
  88233. static readonly OnPickDownTrigger: number;
  88234. /**
  88235. * On double pick
  88236. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88237. */
  88238. static readonly OnDoublePickTrigger: number;
  88239. /**
  88240. * On pick up
  88241. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88242. */
  88243. static readonly OnPickUpTrigger: number;
  88244. /**
  88245. * On pick out.
  88246. * This trigger will only be raised if you also declared a OnPickDown
  88247. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88248. */
  88249. static readonly OnPickOutTrigger: number;
  88250. /**
  88251. * On long press
  88252. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88253. */
  88254. static readonly OnLongPressTrigger: number;
  88255. /**
  88256. * On pointer over
  88257. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88258. */
  88259. static readonly OnPointerOverTrigger: number;
  88260. /**
  88261. * On pointer out
  88262. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88263. */
  88264. static readonly OnPointerOutTrigger: number;
  88265. /**
  88266. * On every frame
  88267. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88268. */
  88269. static readonly OnEveryFrameTrigger: number;
  88270. /**
  88271. * On intersection enter
  88272. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88273. */
  88274. static readonly OnIntersectionEnterTrigger: number;
  88275. /**
  88276. * On intersection exit
  88277. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88278. */
  88279. static readonly OnIntersectionExitTrigger: number;
  88280. /**
  88281. * On key down
  88282. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88283. */
  88284. static readonly OnKeyDownTrigger: number;
  88285. /**
  88286. * On key up
  88287. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88288. */
  88289. static readonly OnKeyUpTrigger: number;
  88290. private _scene;
  88291. /**
  88292. * Creates a new action manager
  88293. * @param scene defines the hosting scene
  88294. */
  88295. constructor(scene: Scene);
  88296. /**
  88297. * Releases all associated resources
  88298. */
  88299. dispose(): void;
  88300. /**
  88301. * Gets hosting scene
  88302. * @returns the hosting scene
  88303. */
  88304. getScene(): Scene;
  88305. /**
  88306. * Does this action manager handles actions of any of the given triggers
  88307. * @param triggers defines the triggers to be tested
  88308. * @return a boolean indicating whether one (or more) of the triggers is handled
  88309. */
  88310. hasSpecificTriggers(triggers: number[]): boolean;
  88311. /**
  88312. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88313. * speed.
  88314. * @param triggerA defines the trigger to be tested
  88315. * @param triggerB defines the trigger to be tested
  88316. * @return a boolean indicating whether one (or more) of the triggers is handled
  88317. */
  88318. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88319. /**
  88320. * Does this action manager handles actions of a given trigger
  88321. * @param trigger defines the trigger to be tested
  88322. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88323. * @return whether the trigger is handled
  88324. */
  88325. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88326. /**
  88327. * Does this action manager has pointer triggers
  88328. */
  88329. get hasPointerTriggers(): boolean;
  88330. /**
  88331. * Does this action manager has pick triggers
  88332. */
  88333. get hasPickTriggers(): boolean;
  88334. /**
  88335. * Registers an action to this action manager
  88336. * @param action defines the action to be registered
  88337. * @return the action amended (prepared) after registration
  88338. */
  88339. registerAction(action: IAction): Nullable<IAction>;
  88340. /**
  88341. * Unregisters an action to this action manager
  88342. * @param action defines the action to be unregistered
  88343. * @return a boolean indicating whether the action has been unregistered
  88344. */
  88345. unregisterAction(action: IAction): Boolean;
  88346. /**
  88347. * Process a specific trigger
  88348. * @param trigger defines the trigger to process
  88349. * @param evt defines the event details to be processed
  88350. */
  88351. processTrigger(trigger: number, evt?: IActionEvent): void;
  88352. /** @hidden */
  88353. _getEffectiveTarget(target: any, propertyPath: string): any;
  88354. /** @hidden */
  88355. _getProperty(propertyPath: string): string;
  88356. /**
  88357. * Serialize this manager to a JSON object
  88358. * @param name defines the property name to store this manager
  88359. * @returns a JSON representation of this manager
  88360. */
  88361. serialize(name: string): any;
  88362. /**
  88363. * Creates a new ActionManager from a JSON data
  88364. * @param parsedActions defines the JSON data to read from
  88365. * @param object defines the hosting mesh
  88366. * @param scene defines the hosting scene
  88367. */
  88368. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  88369. /**
  88370. * Get a trigger name by index
  88371. * @param trigger defines the trigger index
  88372. * @returns a trigger name
  88373. */
  88374. static GetTriggerName(trigger: number): string;
  88375. }
  88376. }
  88377. declare module BABYLON {
  88378. /**
  88379. * Class used to represent a sprite
  88380. * @see https://doc.babylonjs.com/babylon101/sprites
  88381. */
  88382. export class Sprite implements IAnimatable {
  88383. /** defines the name */
  88384. name: string;
  88385. /** Gets or sets the current world position */
  88386. position: Vector3;
  88387. /** Gets or sets the main color */
  88388. color: Color4;
  88389. /** Gets or sets the width */
  88390. width: number;
  88391. /** Gets or sets the height */
  88392. height: number;
  88393. /** Gets or sets rotation angle */
  88394. angle: number;
  88395. /** Gets or sets the cell index in the sprite sheet */
  88396. cellIndex: number;
  88397. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  88398. cellRef: string;
  88399. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  88400. invertU: boolean;
  88401. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  88402. invertV: boolean;
  88403. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  88404. disposeWhenFinishedAnimating: boolean;
  88405. /** Gets the list of attached animations */
  88406. animations: Nullable<Array<Animation>>;
  88407. /** Gets or sets a boolean indicating if the sprite can be picked */
  88408. isPickable: boolean;
  88409. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  88410. useAlphaForPicking: boolean;
  88411. /** @hidden */
  88412. _xOffset: number;
  88413. /** @hidden */
  88414. _yOffset: number;
  88415. /** @hidden */
  88416. _xSize: number;
  88417. /** @hidden */
  88418. _ySize: number;
  88419. /**
  88420. * Gets or sets the associated action manager
  88421. */
  88422. actionManager: Nullable<ActionManager>;
  88423. /**
  88424. * An event triggered when the control has been disposed
  88425. */
  88426. onDisposeObservable: Observable<Sprite>;
  88427. private _animationStarted;
  88428. private _loopAnimation;
  88429. private _fromIndex;
  88430. private _toIndex;
  88431. private _delay;
  88432. private _direction;
  88433. private _manager;
  88434. private _time;
  88435. private _onAnimationEnd;
  88436. /**
  88437. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  88438. */
  88439. isVisible: boolean;
  88440. /**
  88441. * Gets or sets the sprite size
  88442. */
  88443. get size(): number;
  88444. set size(value: number);
  88445. /**
  88446. * Returns a boolean indicating if the animation is started
  88447. */
  88448. get animationStarted(): boolean;
  88449. /**
  88450. * Gets or sets the unique id of the sprite
  88451. */
  88452. uniqueId: number;
  88453. /**
  88454. * Gets the manager of this sprite
  88455. */
  88456. get manager(): ISpriteManager;
  88457. /**
  88458. * Creates a new Sprite
  88459. * @param name defines the name
  88460. * @param manager defines the manager
  88461. */
  88462. constructor(
  88463. /** defines the name */
  88464. name: string, manager: ISpriteManager);
  88465. /**
  88466. * Returns the string "Sprite"
  88467. * @returns "Sprite"
  88468. */
  88469. getClassName(): string;
  88470. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  88471. get fromIndex(): number;
  88472. set fromIndex(value: number);
  88473. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  88474. get toIndex(): number;
  88475. set toIndex(value: number);
  88476. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  88477. get loopAnimation(): boolean;
  88478. set loopAnimation(value: boolean);
  88479. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  88480. get delay(): number;
  88481. set delay(value: number);
  88482. /**
  88483. * Starts an animation
  88484. * @param from defines the initial key
  88485. * @param to defines the end key
  88486. * @param loop defines if the animation must loop
  88487. * @param delay defines the start delay (in ms)
  88488. * @param onAnimationEnd defines a callback to call when animation ends
  88489. */
  88490. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  88491. /** Stops current animation (if any) */
  88492. stopAnimation(): void;
  88493. /** @hidden */
  88494. _animate(deltaTime: number): void;
  88495. /** Release associated resources */
  88496. dispose(): void;
  88497. /**
  88498. * Serializes the sprite to a JSON object
  88499. * @returns the JSON object
  88500. */
  88501. serialize(): any;
  88502. /**
  88503. * Parses a JSON object to create a new sprite
  88504. * @param parsedSprite The JSON object to parse
  88505. * @param manager defines the hosting manager
  88506. * @returns the new sprite
  88507. */
  88508. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  88509. }
  88510. }
  88511. declare module BABYLON {
  88512. /**
  88513. * Information about the result of picking within a scene
  88514. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  88515. */
  88516. export class PickingInfo {
  88517. /** @hidden */
  88518. _pickingUnavailable: boolean;
  88519. /**
  88520. * If the pick collided with an object
  88521. */
  88522. hit: boolean;
  88523. /**
  88524. * Distance away where the pick collided
  88525. */
  88526. distance: number;
  88527. /**
  88528. * The location of pick collision
  88529. */
  88530. pickedPoint: Nullable<Vector3>;
  88531. /**
  88532. * The mesh corresponding the the pick collision
  88533. */
  88534. pickedMesh: Nullable<AbstractMesh>;
  88535. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  88536. bu: number;
  88537. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  88538. bv: number;
  88539. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88540. faceId: number;
  88541. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88542. subMeshFaceId: number;
  88543. /** Id of the the submesh that was picked */
  88544. subMeshId: number;
  88545. /** If a sprite was picked, this will be the sprite the pick collided with */
  88546. pickedSprite: Nullable<Sprite>;
  88547. /**
  88548. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  88549. */
  88550. originMesh: Nullable<AbstractMesh>;
  88551. /**
  88552. * The ray that was used to perform the picking.
  88553. */
  88554. ray: Nullable<Ray>;
  88555. /**
  88556. * Gets the normal correspodning to the face the pick collided with
  88557. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  88558. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  88559. * @returns The normal correspodning to the face the pick collided with
  88560. */
  88561. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  88562. /**
  88563. * Gets the texture coordinates of where the pick occured
  88564. * @returns the vector containing the coordnates of the texture
  88565. */
  88566. getTextureCoordinates(): Nullable<Vector2>;
  88567. }
  88568. }
  88569. declare module BABYLON {
  88570. /**
  88571. * Class representing a ray with position and direction
  88572. */
  88573. export class Ray {
  88574. /** origin point */
  88575. origin: Vector3;
  88576. /** direction */
  88577. direction: Vector3;
  88578. /** length of the ray */
  88579. length: number;
  88580. private static readonly TmpVector3;
  88581. private _tmpRay;
  88582. /**
  88583. * Creates a new ray
  88584. * @param origin origin point
  88585. * @param direction direction
  88586. * @param length length of the ray
  88587. */
  88588. constructor(
  88589. /** origin point */
  88590. origin: Vector3,
  88591. /** direction */
  88592. direction: Vector3,
  88593. /** length of the ray */
  88594. length?: number);
  88595. /**
  88596. * Checks if the ray intersects a box
  88597. * This does not account for the ray lenght by design to improve perfs.
  88598. * @param minimum bound of the box
  88599. * @param maximum bound of the box
  88600. * @param intersectionTreshold extra extend to be added to the box in all direction
  88601. * @returns if the box was hit
  88602. */
  88603. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  88604. /**
  88605. * Checks if the ray intersects a box
  88606. * This does not account for the ray lenght by design to improve perfs.
  88607. * @param box the bounding box to check
  88608. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  88609. * @returns if the box was hit
  88610. */
  88611. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  88612. /**
  88613. * If the ray hits a sphere
  88614. * @param sphere the bounding sphere to check
  88615. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  88616. * @returns true if it hits the sphere
  88617. */
  88618. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  88619. /**
  88620. * If the ray hits a triange
  88621. * @param vertex0 triangle vertex
  88622. * @param vertex1 triangle vertex
  88623. * @param vertex2 triangle vertex
  88624. * @returns intersection information if hit
  88625. */
  88626. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  88627. /**
  88628. * Checks if ray intersects a plane
  88629. * @param plane the plane to check
  88630. * @returns the distance away it was hit
  88631. */
  88632. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  88633. /**
  88634. * Calculate the intercept of a ray on a given axis
  88635. * @param axis to check 'x' | 'y' | 'z'
  88636. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  88637. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  88638. */
  88639. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  88640. /**
  88641. * Checks if ray intersects a mesh
  88642. * @param mesh the mesh to check
  88643. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88644. * @returns picking info of the intersecton
  88645. */
  88646. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  88647. /**
  88648. * Checks if ray intersects a mesh
  88649. * @param meshes the meshes to check
  88650. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88651. * @param results array to store result in
  88652. * @returns Array of picking infos
  88653. */
  88654. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  88655. private _comparePickingInfo;
  88656. private static smallnum;
  88657. private static rayl;
  88658. /**
  88659. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  88660. * @param sega the first point of the segment to test the intersection against
  88661. * @param segb the second point of the segment to test the intersection against
  88662. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  88663. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  88664. */
  88665. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  88666. /**
  88667. * Update the ray from viewport position
  88668. * @param x position
  88669. * @param y y position
  88670. * @param viewportWidth viewport width
  88671. * @param viewportHeight viewport height
  88672. * @param world world matrix
  88673. * @param view view matrix
  88674. * @param projection projection matrix
  88675. * @returns this ray updated
  88676. */
  88677. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88678. /**
  88679. * Creates a ray with origin and direction of 0,0,0
  88680. * @returns the new ray
  88681. */
  88682. static Zero(): Ray;
  88683. /**
  88684. * Creates a new ray from screen space and viewport
  88685. * @param x position
  88686. * @param y y position
  88687. * @param viewportWidth viewport width
  88688. * @param viewportHeight viewport height
  88689. * @param world world matrix
  88690. * @param view view matrix
  88691. * @param projection projection matrix
  88692. * @returns new ray
  88693. */
  88694. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88695. /**
  88696. * 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
  88697. * transformed to the given world matrix.
  88698. * @param origin The origin point
  88699. * @param end The end point
  88700. * @param world a matrix to transform the ray to. Default is the identity matrix.
  88701. * @returns the new ray
  88702. */
  88703. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  88704. /**
  88705. * Transforms a ray by a matrix
  88706. * @param ray ray to transform
  88707. * @param matrix matrix to apply
  88708. * @returns the resulting new ray
  88709. */
  88710. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  88711. /**
  88712. * Transforms a ray by a matrix
  88713. * @param ray ray to transform
  88714. * @param matrix matrix to apply
  88715. * @param result ray to store result in
  88716. */
  88717. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  88718. /**
  88719. * Unproject a ray from screen space to object space
  88720. * @param sourceX defines the screen space x coordinate to use
  88721. * @param sourceY defines the screen space y coordinate to use
  88722. * @param viewportWidth defines the current width of the viewport
  88723. * @param viewportHeight defines the current height of the viewport
  88724. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88725. * @param view defines the view matrix to use
  88726. * @param projection defines the projection matrix to use
  88727. */
  88728. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  88729. }
  88730. /**
  88731. * Type used to define predicate used to select faces when a mesh intersection is detected
  88732. */
  88733. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  88734. interface Scene {
  88735. /** @hidden */
  88736. _tempPickingRay: Nullable<Ray>;
  88737. /** @hidden */
  88738. _cachedRayForTransform: Ray;
  88739. /** @hidden */
  88740. _pickWithRayInverseMatrix: Matrix;
  88741. /** @hidden */
  88742. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  88743. /** @hidden */
  88744. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  88745. }
  88746. }
  88747. declare module BABYLON {
  88748. /**
  88749. * Groups all the scene component constants in one place to ease maintenance.
  88750. * @hidden
  88751. */
  88752. export class SceneComponentConstants {
  88753. static readonly NAME_EFFECTLAYER: string;
  88754. static readonly NAME_LAYER: string;
  88755. static readonly NAME_LENSFLARESYSTEM: string;
  88756. static readonly NAME_BOUNDINGBOXRENDERER: string;
  88757. static readonly NAME_PARTICLESYSTEM: string;
  88758. static readonly NAME_GAMEPAD: string;
  88759. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  88760. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  88761. static readonly NAME_PREPASSRENDERER: string;
  88762. static readonly NAME_DEPTHRENDERER: string;
  88763. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  88764. static readonly NAME_SPRITE: string;
  88765. static readonly NAME_OUTLINERENDERER: string;
  88766. static readonly NAME_PROCEDURALTEXTURE: string;
  88767. static readonly NAME_SHADOWGENERATOR: string;
  88768. static readonly NAME_OCTREE: string;
  88769. static readonly NAME_PHYSICSENGINE: string;
  88770. static readonly NAME_AUDIO: string;
  88771. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  88772. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88773. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  88774. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88775. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  88776. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  88777. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  88778. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  88779. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  88780. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  88781. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  88782. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  88783. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  88784. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  88785. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  88786. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  88787. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  88788. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  88789. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  88790. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  88791. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  88792. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  88793. static readonly STEP_AFTERRENDER_AUDIO: number;
  88794. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  88795. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  88796. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  88797. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  88798. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  88799. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  88800. static readonly STEP_POINTERMOVE_SPRITE: number;
  88801. static readonly STEP_POINTERDOWN_SPRITE: number;
  88802. static readonly STEP_POINTERUP_SPRITE: number;
  88803. }
  88804. /**
  88805. * This represents a scene component.
  88806. *
  88807. * This is used to decouple the dependency the scene is having on the different workloads like
  88808. * layers, post processes...
  88809. */
  88810. export interface ISceneComponent {
  88811. /**
  88812. * The name of the component. Each component must have a unique name.
  88813. */
  88814. name: string;
  88815. /**
  88816. * The scene the component belongs to.
  88817. */
  88818. scene: Scene;
  88819. /**
  88820. * Register the component to one instance of a scene.
  88821. */
  88822. register(): void;
  88823. /**
  88824. * Rebuilds the elements related to this component in case of
  88825. * context lost for instance.
  88826. */
  88827. rebuild(): void;
  88828. /**
  88829. * Disposes the component and the associated ressources.
  88830. */
  88831. dispose(): void;
  88832. }
  88833. /**
  88834. * This represents a SERIALIZABLE scene component.
  88835. *
  88836. * This extends Scene Component to add Serialization methods on top.
  88837. */
  88838. export interface ISceneSerializableComponent extends ISceneComponent {
  88839. /**
  88840. * Adds all the elements from the container to the scene
  88841. * @param container the container holding the elements
  88842. */
  88843. addFromContainer(container: AbstractScene): void;
  88844. /**
  88845. * Removes all the elements in the container from the scene
  88846. * @param container contains the elements to remove
  88847. * @param dispose if the removed element should be disposed (default: false)
  88848. */
  88849. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  88850. /**
  88851. * Serializes the component data to the specified json object
  88852. * @param serializationObject The object to serialize to
  88853. */
  88854. serialize(serializationObject: any): void;
  88855. }
  88856. /**
  88857. * Strong typing of a Mesh related stage step action
  88858. */
  88859. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  88860. /**
  88861. * Strong typing of a Evaluate Sub Mesh related stage step action
  88862. */
  88863. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  88864. /**
  88865. * Strong typing of a Active Mesh related stage step action
  88866. */
  88867. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  88868. /**
  88869. * Strong typing of a Camera related stage step action
  88870. */
  88871. export type CameraStageAction = (camera: Camera) => void;
  88872. /**
  88873. * Strong typing of a Camera Frame buffer related stage step action
  88874. */
  88875. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  88876. /**
  88877. * Strong typing of a Render Target related stage step action
  88878. */
  88879. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  88880. /**
  88881. * Strong typing of a RenderingGroup related stage step action
  88882. */
  88883. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  88884. /**
  88885. * Strong typing of a Mesh Render related stage step action
  88886. */
  88887. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  88888. /**
  88889. * Strong typing of a simple stage step action
  88890. */
  88891. export type SimpleStageAction = () => void;
  88892. /**
  88893. * Strong typing of a render target action.
  88894. */
  88895. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  88896. /**
  88897. * Strong typing of a pointer move action.
  88898. */
  88899. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  88900. /**
  88901. * Strong typing of a pointer up/down action.
  88902. */
  88903. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  88904. /**
  88905. * Representation of a stage in the scene (Basically a list of ordered steps)
  88906. * @hidden
  88907. */
  88908. export class Stage<T extends Function> extends Array<{
  88909. index: number;
  88910. component: ISceneComponent;
  88911. action: T;
  88912. }> {
  88913. /**
  88914. * Hide ctor from the rest of the world.
  88915. * @param items The items to add.
  88916. */
  88917. private constructor();
  88918. /**
  88919. * Creates a new Stage.
  88920. * @returns A new instance of a Stage
  88921. */
  88922. static Create<T extends Function>(): Stage<T>;
  88923. /**
  88924. * Registers a step in an ordered way in the targeted stage.
  88925. * @param index Defines the position to register the step in
  88926. * @param component Defines the component attached to the step
  88927. * @param action Defines the action to launch during the step
  88928. */
  88929. registerStep(index: number, component: ISceneComponent, action: T): void;
  88930. /**
  88931. * Clears all the steps from the stage.
  88932. */
  88933. clear(): void;
  88934. }
  88935. }
  88936. declare module BABYLON {
  88937. interface Scene {
  88938. /** @hidden */
  88939. _pointerOverSprite: Nullable<Sprite>;
  88940. /** @hidden */
  88941. _pickedDownSprite: Nullable<Sprite>;
  88942. /** @hidden */
  88943. _tempSpritePickingRay: Nullable<Ray>;
  88944. /**
  88945. * All of the sprite managers added to this scene
  88946. * @see https://doc.babylonjs.com/babylon101/sprites
  88947. */
  88948. spriteManagers: Array<ISpriteManager>;
  88949. /**
  88950. * An event triggered when sprites rendering is about to start
  88951. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88952. */
  88953. onBeforeSpritesRenderingObservable: Observable<Scene>;
  88954. /**
  88955. * An event triggered when sprites rendering is done
  88956. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88957. */
  88958. onAfterSpritesRenderingObservable: Observable<Scene>;
  88959. /** @hidden */
  88960. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88961. /** Launch a ray to try to pick a sprite in the scene
  88962. * @param x position on screen
  88963. * @param y position on screen
  88964. * @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
  88965. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88966. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88967. * @returns a PickingInfo
  88968. */
  88969. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88970. /** Use the given ray to pick a sprite in the scene
  88971. * @param ray The ray (in world space) to use to pick meshes
  88972. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  88973. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88974. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88975. * @returns a PickingInfo
  88976. */
  88977. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88978. /** @hidden */
  88979. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88980. /** Launch a ray to try to pick sprites in the scene
  88981. * @param x position on screen
  88982. * @param y position on screen
  88983. * @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
  88984. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88985. * @returns a PickingInfo array
  88986. */
  88987. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88988. /** Use the given ray to pick sprites in the scene
  88989. * @param ray The ray (in world space) to use to pick meshes
  88990. * @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
  88991. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88992. * @returns a PickingInfo array
  88993. */
  88994. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88995. /**
  88996. * Force the sprite under the pointer
  88997. * @param sprite defines the sprite to use
  88998. */
  88999. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  89000. /**
  89001. * Gets the sprite under the pointer
  89002. * @returns a Sprite or null if no sprite is under the pointer
  89003. */
  89004. getPointerOverSprite(): Nullable<Sprite>;
  89005. }
  89006. /**
  89007. * Defines the sprite scene component responsible to manage sprites
  89008. * in a given scene.
  89009. */
  89010. export class SpriteSceneComponent implements ISceneComponent {
  89011. /**
  89012. * The component name helpfull to identify the component in the list of scene components.
  89013. */
  89014. readonly name: string;
  89015. /**
  89016. * The scene the component belongs to.
  89017. */
  89018. scene: Scene;
  89019. /** @hidden */
  89020. private _spritePredicate;
  89021. /**
  89022. * Creates a new instance of the component for the given scene
  89023. * @param scene Defines the scene to register the component in
  89024. */
  89025. constructor(scene: Scene);
  89026. /**
  89027. * Registers the component in a given scene
  89028. */
  89029. register(): void;
  89030. /**
  89031. * Rebuilds the elements related to this component in case of
  89032. * context lost for instance.
  89033. */
  89034. rebuild(): void;
  89035. /**
  89036. * Disposes the component and the associated ressources.
  89037. */
  89038. dispose(): void;
  89039. private _pickSpriteButKeepRay;
  89040. private _pointerMove;
  89041. private _pointerDown;
  89042. private _pointerUp;
  89043. }
  89044. }
  89045. declare module BABYLON {
  89046. /** @hidden */
  89047. export var fogFragmentDeclaration: {
  89048. name: string;
  89049. shader: string;
  89050. };
  89051. }
  89052. declare module BABYLON {
  89053. /** @hidden */
  89054. export var fogFragment: {
  89055. name: string;
  89056. shader: string;
  89057. };
  89058. }
  89059. declare module BABYLON {
  89060. /** @hidden */
  89061. export var spritesPixelShader: {
  89062. name: string;
  89063. shader: string;
  89064. };
  89065. }
  89066. declare module BABYLON {
  89067. /** @hidden */
  89068. export var fogVertexDeclaration: {
  89069. name: string;
  89070. shader: string;
  89071. };
  89072. }
  89073. declare module BABYLON {
  89074. /** @hidden */
  89075. export var spritesVertexShader: {
  89076. name: string;
  89077. shader: string;
  89078. };
  89079. }
  89080. declare module BABYLON {
  89081. /**
  89082. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89083. */
  89084. export interface ISpriteManager extends IDisposable {
  89085. /**
  89086. * Gets manager's name
  89087. */
  89088. name: string;
  89089. /**
  89090. * Restricts the camera to viewing objects with the same layerMask.
  89091. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89092. */
  89093. layerMask: number;
  89094. /**
  89095. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89096. */
  89097. isPickable: boolean;
  89098. /**
  89099. * Gets the hosting scene
  89100. */
  89101. scene: Scene;
  89102. /**
  89103. * Specifies the rendering group id for this mesh (0 by default)
  89104. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89105. */
  89106. renderingGroupId: number;
  89107. /**
  89108. * Defines the list of sprites managed by the manager.
  89109. */
  89110. sprites: Array<Sprite>;
  89111. /**
  89112. * Gets or sets the spritesheet texture
  89113. */
  89114. texture: Texture;
  89115. /** Defines the default width of a cell in the spritesheet */
  89116. cellWidth: number;
  89117. /** Defines the default height of a cell in the spritesheet */
  89118. cellHeight: number;
  89119. /**
  89120. * Tests the intersection of a sprite with a specific ray.
  89121. * @param ray The ray we are sending to test the collision
  89122. * @param camera The camera space we are sending rays in
  89123. * @param predicate A predicate allowing excluding sprites from the list of object to test
  89124. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89125. * @returns picking info or null.
  89126. */
  89127. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89128. /**
  89129. * Intersects the sprites with a ray
  89130. * @param ray defines the ray to intersect with
  89131. * @param camera defines the current active camera
  89132. * @param predicate defines a predicate used to select candidate sprites
  89133. * @returns null if no hit or a PickingInfo array
  89134. */
  89135. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89136. /**
  89137. * Renders the list of sprites on screen.
  89138. */
  89139. render(): void;
  89140. }
  89141. /**
  89142. * Class used to manage multiple sprites on the same spritesheet
  89143. * @see https://doc.babylonjs.com/babylon101/sprites
  89144. */
  89145. export class SpriteManager implements ISpriteManager {
  89146. /** defines the manager's name */
  89147. name: string;
  89148. /** Define the Url to load snippets */
  89149. static SnippetUrl: string;
  89150. /** Snippet ID if the manager was created from the snippet server */
  89151. snippetId: string;
  89152. /** Gets the list of sprites */
  89153. sprites: Sprite[];
  89154. /** Gets or sets the rendering group id (0 by default) */
  89155. renderingGroupId: number;
  89156. /** Gets or sets camera layer mask */
  89157. layerMask: number;
  89158. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  89159. fogEnabled: boolean;
  89160. /** Gets or sets a boolean indicating if the sprites are pickable */
  89161. isPickable: boolean;
  89162. /** Defines the default width of a cell in the spritesheet */
  89163. cellWidth: number;
  89164. /** Defines the default height of a cell in the spritesheet */
  89165. cellHeight: number;
  89166. /** Associative array from JSON sprite data file */
  89167. private _cellData;
  89168. /** Array of sprite names from JSON sprite data file */
  89169. private _spriteMap;
  89170. /** True when packed cell data from JSON file is ready*/
  89171. private _packedAndReady;
  89172. private _textureContent;
  89173. /**
  89174. * An event triggered when the manager is disposed.
  89175. */
  89176. onDisposeObservable: Observable<SpriteManager>;
  89177. private _onDisposeObserver;
  89178. /**
  89179. * Callback called when the manager is disposed
  89180. */
  89181. set onDispose(callback: () => void);
  89182. private _capacity;
  89183. private _fromPacked;
  89184. private _spriteTexture;
  89185. private _epsilon;
  89186. private _scene;
  89187. private _vertexData;
  89188. private _buffer;
  89189. private _vertexBuffers;
  89190. private _indexBuffer;
  89191. private _effectBase;
  89192. private _effectFog;
  89193. /**
  89194. * Gets or sets the unique id of the sprite
  89195. */
  89196. uniqueId: number;
  89197. /**
  89198. * Gets the array of sprites
  89199. */
  89200. get children(): Sprite[];
  89201. /**
  89202. * Gets the hosting scene
  89203. */
  89204. get scene(): Scene;
  89205. /**
  89206. * Gets the capacity of the manager
  89207. */
  89208. get capacity(): number;
  89209. /**
  89210. * Gets or sets the spritesheet texture
  89211. */
  89212. get texture(): Texture;
  89213. set texture(value: Texture);
  89214. private _blendMode;
  89215. /**
  89216. * Blend mode use to render the particle, it can be any of
  89217. * the static Constants.ALPHA_x properties provided in this class.
  89218. * Default value is Constants.ALPHA_COMBINE
  89219. */
  89220. get blendMode(): number;
  89221. set blendMode(blendMode: number);
  89222. /** Disables writing to the depth buffer when rendering the sprites.
  89223. * It can be handy to disable depth writing when using textures without alpha channel
  89224. * and setting some specific blend modes.
  89225. */
  89226. disableDepthWrite: boolean;
  89227. /**
  89228. * Creates a new sprite manager
  89229. * @param name defines the manager's name
  89230. * @param imgUrl defines the sprite sheet url
  89231. * @param capacity defines the maximum allowed number of sprites
  89232. * @param cellSize defines the size of a sprite cell
  89233. * @param scene defines the hosting scene
  89234. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  89235. * @param samplingMode defines the smapling mode to use with spritesheet
  89236. * @param fromPacked set to false; do not alter
  89237. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  89238. */
  89239. constructor(
  89240. /** defines the manager's name */
  89241. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  89242. /**
  89243. * Returns the string "SpriteManager"
  89244. * @returns "SpriteManager"
  89245. */
  89246. getClassName(): string;
  89247. private _makePacked;
  89248. private _appendSpriteVertex;
  89249. private _checkTextureAlpha;
  89250. /**
  89251. * Intersects the sprites with a ray
  89252. * @param ray defines the ray to intersect with
  89253. * @param camera defines the current active camera
  89254. * @param predicate defines a predicate used to select candidate sprites
  89255. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  89256. * @returns null if no hit or a PickingInfo
  89257. */
  89258. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89259. /**
  89260. * Intersects the sprites with a ray
  89261. * @param ray defines the ray to intersect with
  89262. * @param camera defines the current active camera
  89263. * @param predicate defines a predicate used to select candidate sprites
  89264. * @returns null if no hit or a PickingInfo array
  89265. */
  89266. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89267. /**
  89268. * Render all child sprites
  89269. */
  89270. render(): void;
  89271. /**
  89272. * Release associated resources
  89273. */
  89274. dispose(): void;
  89275. /**
  89276. * Serializes the sprite manager to a JSON object
  89277. * @param serializeTexture defines if the texture must be serialized as well
  89278. * @returns the JSON object
  89279. */
  89280. serialize(serializeTexture?: boolean): any;
  89281. /**
  89282. * Parses a JSON object to create a new sprite manager.
  89283. * @param parsedManager The JSON object to parse
  89284. * @param scene The scene to create the sprite managerin
  89285. * @param rootUrl The root url to use to load external dependencies like texture
  89286. * @returns the new sprite manager
  89287. */
  89288. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  89289. /**
  89290. * Creates a sprite manager from a snippet saved in a remote file
  89291. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  89292. * @param url defines the url to load from
  89293. * @param scene defines the hosting scene
  89294. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89295. * @returns a promise that will resolve to the new sprite manager
  89296. */
  89297. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89298. /**
  89299. * Creates a sprite manager from a snippet saved by the sprite editor
  89300. * @param snippetId defines the snippet to load
  89301. * @param scene defines the hosting scene
  89302. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89303. * @returns a promise that will resolve to the new sprite manager
  89304. */
  89305. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89306. }
  89307. }
  89308. declare module BABYLON {
  89309. /** Interface used by value gradients (color, factor, ...) */
  89310. export interface IValueGradient {
  89311. /**
  89312. * Gets or sets the gradient value (between 0 and 1)
  89313. */
  89314. gradient: number;
  89315. }
  89316. /** Class used to store color4 gradient */
  89317. export class ColorGradient implements IValueGradient {
  89318. /**
  89319. * Gets or sets the gradient value (between 0 and 1)
  89320. */
  89321. gradient: number;
  89322. /**
  89323. * Gets or sets first associated color
  89324. */
  89325. color1: Color4;
  89326. /**
  89327. * Gets or sets second associated color
  89328. */
  89329. color2?: Color4 | undefined;
  89330. /**
  89331. * Creates a new color4 gradient
  89332. * @param gradient gets or sets the gradient value (between 0 and 1)
  89333. * @param color1 gets or sets first associated color
  89334. * @param color2 gets or sets first second color
  89335. */
  89336. constructor(
  89337. /**
  89338. * Gets or sets the gradient value (between 0 and 1)
  89339. */
  89340. gradient: number,
  89341. /**
  89342. * Gets or sets first associated color
  89343. */
  89344. color1: Color4,
  89345. /**
  89346. * Gets or sets second associated color
  89347. */
  89348. color2?: Color4 | undefined);
  89349. /**
  89350. * Will get a color picked randomly between color1 and color2.
  89351. * If color2 is undefined then color1 will be used
  89352. * @param result defines the target Color4 to store the result in
  89353. */
  89354. getColorToRef(result: Color4): void;
  89355. }
  89356. /** Class used to store color 3 gradient */
  89357. export class Color3Gradient implements IValueGradient {
  89358. /**
  89359. * Gets or sets the gradient value (between 0 and 1)
  89360. */
  89361. gradient: number;
  89362. /**
  89363. * Gets or sets the associated color
  89364. */
  89365. color: Color3;
  89366. /**
  89367. * Creates a new color3 gradient
  89368. * @param gradient gets or sets the gradient value (between 0 and 1)
  89369. * @param color gets or sets associated color
  89370. */
  89371. constructor(
  89372. /**
  89373. * Gets or sets the gradient value (between 0 and 1)
  89374. */
  89375. gradient: number,
  89376. /**
  89377. * Gets or sets the associated color
  89378. */
  89379. color: Color3);
  89380. }
  89381. /** Class used to store factor gradient */
  89382. export class FactorGradient implements IValueGradient {
  89383. /**
  89384. * Gets or sets the gradient value (between 0 and 1)
  89385. */
  89386. gradient: number;
  89387. /**
  89388. * Gets or sets first associated factor
  89389. */
  89390. factor1: number;
  89391. /**
  89392. * Gets or sets second associated factor
  89393. */
  89394. factor2?: number | undefined;
  89395. /**
  89396. * Creates a new factor gradient
  89397. * @param gradient gets or sets the gradient value (between 0 and 1)
  89398. * @param factor1 gets or sets first associated factor
  89399. * @param factor2 gets or sets second associated factor
  89400. */
  89401. constructor(
  89402. /**
  89403. * Gets or sets the gradient value (between 0 and 1)
  89404. */
  89405. gradient: number,
  89406. /**
  89407. * Gets or sets first associated factor
  89408. */
  89409. factor1: number,
  89410. /**
  89411. * Gets or sets second associated factor
  89412. */
  89413. factor2?: number | undefined);
  89414. /**
  89415. * Will get a number picked randomly between factor1 and factor2.
  89416. * If factor2 is undefined then factor1 will be used
  89417. * @returns the picked number
  89418. */
  89419. getFactor(): number;
  89420. }
  89421. /**
  89422. * Helper used to simplify some generic gradient tasks
  89423. */
  89424. export class GradientHelper {
  89425. /**
  89426. * Gets the current gradient from an array of IValueGradient
  89427. * @param ratio defines the current ratio to get
  89428. * @param gradients defines the array of IValueGradient
  89429. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89430. */
  89431. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89432. }
  89433. }
  89434. declare module BABYLON {
  89435. interface ThinEngine {
  89436. /**
  89437. * Creates a raw texture
  89438. * @param data defines the data to store in the texture
  89439. * @param width defines the width of the texture
  89440. * @param height defines the height of the texture
  89441. * @param format defines the format of the data
  89442. * @param generateMipMaps defines if the engine should generate the mip levels
  89443. * @param invertY defines if data must be stored with Y axis inverted
  89444. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89445. * @param compression defines the compression used (null by default)
  89446. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89447. * @returns the raw texture inside an InternalTexture
  89448. */
  89449. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  89450. /**
  89451. * Update a raw texture
  89452. * @param texture defines the texture to update
  89453. * @param data defines the data to store in the texture
  89454. * @param format defines the format of the data
  89455. * @param invertY defines if data must be stored with Y axis inverted
  89456. */
  89457. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89458. /**
  89459. * Update a raw texture
  89460. * @param texture defines the texture to update
  89461. * @param data defines the data to store in the texture
  89462. * @param format defines the format of the data
  89463. * @param invertY defines if data must be stored with Y axis inverted
  89464. * @param compression defines the compression used (null by default)
  89465. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89466. */
  89467. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  89468. /**
  89469. * Creates a new raw cube texture
  89470. * @param data defines the array of data to use to create each face
  89471. * @param size defines the size of the textures
  89472. * @param format defines the format of the data
  89473. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89474. * @param generateMipMaps defines if the engine should generate the mip levels
  89475. * @param invertY defines if data must be stored with Y axis inverted
  89476. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89477. * @param compression defines the compression used (null by default)
  89478. * @returns the cube texture as an InternalTexture
  89479. */
  89480. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  89481. /**
  89482. * Update a raw cube texture
  89483. * @param texture defines the texture to udpdate
  89484. * @param data defines the data to store
  89485. * @param format defines the data format
  89486. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89487. * @param invertY defines if data must be stored with Y axis inverted
  89488. */
  89489. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  89490. /**
  89491. * Update a raw cube texture
  89492. * @param texture defines the texture to udpdate
  89493. * @param data defines the data to store
  89494. * @param format defines the data format
  89495. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89496. * @param invertY defines if data must be stored with Y axis inverted
  89497. * @param compression defines the compression used (null by default)
  89498. */
  89499. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  89500. /**
  89501. * Update a raw cube texture
  89502. * @param texture defines the texture to udpdate
  89503. * @param data defines the data to store
  89504. * @param format defines the data format
  89505. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89506. * @param invertY defines if data must be stored with Y axis inverted
  89507. * @param compression defines the compression used (null by default)
  89508. * @param level defines which level of the texture to update
  89509. */
  89510. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  89511. /**
  89512. * Creates a new raw cube texture from a specified url
  89513. * @param url defines the url where the data is located
  89514. * @param scene defines the current scene
  89515. * @param size defines the size of the textures
  89516. * @param format defines the format of the data
  89517. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89518. * @param noMipmap defines if the engine should avoid generating the mip levels
  89519. * @param callback defines a callback used to extract texture data from loaded data
  89520. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89521. * @param onLoad defines a callback called when texture is loaded
  89522. * @param onError defines a callback called if there is an error
  89523. * @returns the cube texture as an InternalTexture
  89524. */
  89525. 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;
  89526. /**
  89527. * Creates a new raw cube texture from a specified url
  89528. * @param url defines the url where the data is located
  89529. * @param scene defines the current scene
  89530. * @param size defines the size of the textures
  89531. * @param format defines the format of the data
  89532. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89533. * @param noMipmap defines if the engine should avoid generating the mip levels
  89534. * @param callback defines a callback used to extract texture data from loaded data
  89535. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89536. * @param onLoad defines a callback called when texture is loaded
  89537. * @param onError defines a callback called if there is an error
  89538. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89539. * @param invertY defines if data must be stored with Y axis inverted
  89540. * @returns the cube texture as an InternalTexture
  89541. */
  89542. 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;
  89543. /**
  89544. * Creates a new raw 3D texture
  89545. * @param data defines the data used to create the texture
  89546. * @param width defines the width of the texture
  89547. * @param height defines the height of the texture
  89548. * @param depth defines the depth of the texture
  89549. * @param format defines the format of the texture
  89550. * @param generateMipMaps defines if the engine must generate mip levels
  89551. * @param invertY defines if data must be stored with Y axis inverted
  89552. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89553. * @param compression defines the compressed used (can be null)
  89554. * @param textureType defines the compressed used (can be null)
  89555. * @returns a new raw 3D texture (stored in an InternalTexture)
  89556. */
  89557. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89558. /**
  89559. * Update a raw 3D texture
  89560. * @param texture defines the texture to update
  89561. * @param data defines the data to store
  89562. * @param format defines the data format
  89563. * @param invertY defines if data must be stored with Y axis inverted
  89564. */
  89565. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89566. /**
  89567. * Update a raw 3D texture
  89568. * @param texture defines the texture to update
  89569. * @param data defines the data to store
  89570. * @param format defines the data format
  89571. * @param invertY defines if data must be stored with Y axis inverted
  89572. * @param compression defines the used compression (can be null)
  89573. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89574. */
  89575. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89576. /**
  89577. * Creates a new raw 2D array texture
  89578. * @param data defines the data used to create the texture
  89579. * @param width defines the width of the texture
  89580. * @param height defines the height of the texture
  89581. * @param depth defines the number of layers of the texture
  89582. * @param format defines the format of the texture
  89583. * @param generateMipMaps defines if the engine must generate mip levels
  89584. * @param invertY defines if data must be stored with Y axis inverted
  89585. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89586. * @param compression defines the compressed used (can be null)
  89587. * @param textureType defines the compressed used (can be null)
  89588. * @returns a new raw 2D array texture (stored in an InternalTexture)
  89589. */
  89590. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89591. /**
  89592. * Update a raw 2D array texture
  89593. * @param texture defines the texture to update
  89594. * @param data defines the data to store
  89595. * @param format defines the data format
  89596. * @param invertY defines if data must be stored with Y axis inverted
  89597. */
  89598. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89599. /**
  89600. * Update a raw 2D array texture
  89601. * @param texture defines the texture to update
  89602. * @param data defines the data to store
  89603. * @param format defines the data format
  89604. * @param invertY defines if data must be stored with Y axis inverted
  89605. * @param compression defines the used compression (can be null)
  89606. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89607. */
  89608. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89609. }
  89610. }
  89611. declare module BABYLON {
  89612. /**
  89613. * Raw texture can help creating a texture directly from an array of data.
  89614. * This can be super useful if you either get the data from an uncompressed source or
  89615. * if you wish to create your texture pixel by pixel.
  89616. */
  89617. export class RawTexture extends Texture {
  89618. /**
  89619. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89620. */
  89621. format: number;
  89622. /**
  89623. * Instantiates a new RawTexture.
  89624. * Raw texture can help creating a texture directly from an array of data.
  89625. * This can be super useful if you either get the data from an uncompressed source or
  89626. * if you wish to create your texture pixel by pixel.
  89627. * @param data define the array of data to use to create the texture
  89628. * @param width define the width of the texture
  89629. * @param height define the height of the texture
  89630. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89631. * @param scene define the scene the texture belongs to
  89632. * @param generateMipMaps define whether mip maps should be generated or not
  89633. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89634. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89635. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89636. */
  89637. constructor(data: ArrayBufferView, width: number, height: number,
  89638. /**
  89639. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89640. */
  89641. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  89642. /**
  89643. * Updates the texture underlying data.
  89644. * @param data Define the new data of the texture
  89645. */
  89646. update(data: ArrayBufferView): void;
  89647. /**
  89648. * Creates a luminance texture from some data.
  89649. * @param data Define the texture data
  89650. * @param width Define the width of the texture
  89651. * @param height Define the height of the texture
  89652. * @param scene Define the scene the texture belongs to
  89653. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89654. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89655. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89656. * @returns the luminance texture
  89657. */
  89658. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89659. /**
  89660. * Creates a luminance alpha texture from some data.
  89661. * @param data Define the texture data
  89662. * @param width Define the width of the texture
  89663. * @param height Define the height of the texture
  89664. * @param scene Define the scene the texture belongs to
  89665. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89666. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89667. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89668. * @returns the luminance alpha texture
  89669. */
  89670. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89671. /**
  89672. * Creates an alpha texture from some data.
  89673. * @param data Define the texture data
  89674. * @param width Define the width of the texture
  89675. * @param height Define the height of the texture
  89676. * @param scene Define the scene the texture belongs to
  89677. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89678. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89679. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89680. * @returns the alpha texture
  89681. */
  89682. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89683. /**
  89684. * Creates a RGB texture from some data.
  89685. * @param data Define the texture data
  89686. * @param width Define the width of the texture
  89687. * @param height Define the height of the texture
  89688. * @param scene Define the scene the texture belongs to
  89689. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89690. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89691. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89692. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89693. * @returns the RGB alpha texture
  89694. */
  89695. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89696. /**
  89697. * Creates a RGBA texture from some data.
  89698. * @param data Define the texture data
  89699. * @param width Define the width of the texture
  89700. * @param height Define the height of the texture
  89701. * @param scene Define the scene the texture belongs to
  89702. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89703. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89704. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89705. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89706. * @returns the RGBA texture
  89707. */
  89708. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89709. /**
  89710. * Creates a R texture from some data.
  89711. * @param data Define the texture data
  89712. * @param width Define the width of the texture
  89713. * @param height Define the height of the texture
  89714. * @param scene Define the scene the texture belongs to
  89715. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89716. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89717. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89718. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89719. * @returns the R texture
  89720. */
  89721. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89722. }
  89723. }
  89724. declare module BABYLON {
  89725. interface AbstractScene {
  89726. /**
  89727. * The list of procedural textures added to the scene
  89728. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89729. */
  89730. proceduralTextures: Array<ProceduralTexture>;
  89731. }
  89732. /**
  89733. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89734. * in a given scene.
  89735. */
  89736. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89737. /**
  89738. * The component name helpfull to identify the component in the list of scene components.
  89739. */
  89740. readonly name: string;
  89741. /**
  89742. * The scene the component belongs to.
  89743. */
  89744. scene: Scene;
  89745. /**
  89746. * Creates a new instance of the component for the given scene
  89747. * @param scene Defines the scene to register the component in
  89748. */
  89749. constructor(scene: Scene);
  89750. /**
  89751. * Registers the component in a given scene
  89752. */
  89753. register(): void;
  89754. /**
  89755. * Rebuilds the elements related to this component in case of
  89756. * context lost for instance.
  89757. */
  89758. rebuild(): void;
  89759. /**
  89760. * Disposes the component and the associated ressources.
  89761. */
  89762. dispose(): void;
  89763. private _beforeClear;
  89764. }
  89765. }
  89766. declare module BABYLON {
  89767. interface ThinEngine {
  89768. /**
  89769. * Creates a new render target cube texture
  89770. * @param size defines the size of the texture
  89771. * @param options defines the options used to create the texture
  89772. * @returns a new render target cube texture stored in an InternalTexture
  89773. */
  89774. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89775. }
  89776. }
  89777. declare module BABYLON {
  89778. /** @hidden */
  89779. export var proceduralVertexShader: {
  89780. name: string;
  89781. shader: string;
  89782. };
  89783. }
  89784. declare module BABYLON {
  89785. /**
  89786. * 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.
  89787. * This is the base class of any Procedural texture and contains most of the shareable code.
  89788. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89789. */
  89790. export class ProceduralTexture extends Texture {
  89791. isCube: boolean;
  89792. /**
  89793. * Define if the texture is enabled or not (disabled texture will not render)
  89794. */
  89795. isEnabled: boolean;
  89796. /**
  89797. * Define if the texture must be cleared before rendering (default is true)
  89798. */
  89799. autoClear: boolean;
  89800. /**
  89801. * Callback called when the texture is generated
  89802. */
  89803. onGenerated: () => void;
  89804. /**
  89805. * Event raised when the texture is generated
  89806. */
  89807. onGeneratedObservable: Observable<ProceduralTexture>;
  89808. /** @hidden */
  89809. _generateMipMaps: boolean;
  89810. /** @hidden **/
  89811. _effect: Effect;
  89812. /** @hidden */
  89813. _textures: {
  89814. [key: string]: Texture;
  89815. };
  89816. /** @hidden */
  89817. protected _fallbackTexture: Nullable<Texture>;
  89818. private _size;
  89819. private _currentRefreshId;
  89820. private _frameId;
  89821. private _refreshRate;
  89822. private _vertexBuffers;
  89823. private _indexBuffer;
  89824. private _uniforms;
  89825. private _samplers;
  89826. private _fragment;
  89827. private _floats;
  89828. private _ints;
  89829. private _floatsArrays;
  89830. private _colors3;
  89831. private _colors4;
  89832. private _vectors2;
  89833. private _vectors3;
  89834. private _matrices;
  89835. private _fallbackTextureUsed;
  89836. private _fullEngine;
  89837. private _cachedDefines;
  89838. private _contentUpdateId;
  89839. private _contentData;
  89840. /**
  89841. * Instantiates a new procedural texture.
  89842. * 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.
  89843. * This is the base class of any Procedural texture and contains most of the shareable code.
  89844. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89845. * @param name Define the name of the texture
  89846. * @param size Define the size of the texture to create
  89847. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89848. * @param scene Define the scene the texture belongs to
  89849. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89850. * @param generateMipMaps Define if the texture should creates mip maps or not
  89851. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89852. */
  89853. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89854. /**
  89855. * The effect that is created when initializing the post process.
  89856. * @returns The created effect corresponding the the postprocess.
  89857. */
  89858. getEffect(): Effect;
  89859. /**
  89860. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89861. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89862. */
  89863. getContent(): Nullable<ArrayBufferView>;
  89864. private _createIndexBuffer;
  89865. /** @hidden */
  89866. _rebuild(): void;
  89867. /**
  89868. * Resets the texture in order to recreate its associated resources.
  89869. * This can be called in case of context loss
  89870. */
  89871. reset(): void;
  89872. protected _getDefines(): string;
  89873. /**
  89874. * Is the texture ready to be used ? (rendered at least once)
  89875. * @returns true if ready, otherwise, false.
  89876. */
  89877. isReady(): boolean;
  89878. /**
  89879. * Resets the refresh counter of the texture and start bak from scratch.
  89880. * Could be useful to regenerate the texture if it is setup to render only once.
  89881. */
  89882. resetRefreshCounter(): void;
  89883. /**
  89884. * Set the fragment shader to use in order to render the texture.
  89885. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89886. */
  89887. setFragment(fragment: any): void;
  89888. /**
  89889. * Define the refresh rate of the texture or the rendering frequency.
  89890. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89891. */
  89892. get refreshRate(): number;
  89893. set refreshRate(value: number);
  89894. /** @hidden */
  89895. _shouldRender(): boolean;
  89896. /**
  89897. * Get the size the texture is rendering at.
  89898. * @returns the size (texture is always squared)
  89899. */
  89900. getRenderSize(): number;
  89901. /**
  89902. * Resize the texture to new value.
  89903. * @param size Define the new size the texture should have
  89904. * @param generateMipMaps Define whether the new texture should create mip maps
  89905. */
  89906. resize(size: number, generateMipMaps: boolean): void;
  89907. private _checkUniform;
  89908. /**
  89909. * Set a texture in the shader program used to render.
  89910. * @param name Define the name of the uniform samplers as defined in the shader
  89911. * @param texture Define the texture to bind to this sampler
  89912. * @return the texture itself allowing "fluent" like uniform updates
  89913. */
  89914. setTexture(name: string, texture: Texture): ProceduralTexture;
  89915. /**
  89916. * Set a float in the shader.
  89917. * @param name Define the name of the uniform as defined in the shader
  89918. * @param value Define the value to give to the uniform
  89919. * @return the texture itself allowing "fluent" like uniform updates
  89920. */
  89921. setFloat(name: string, value: number): ProceduralTexture;
  89922. /**
  89923. * Set a int in the shader.
  89924. * @param name Define the name of the uniform as defined in the shader
  89925. * @param value Define the value to give to the uniform
  89926. * @return the texture itself allowing "fluent" like uniform updates
  89927. */
  89928. setInt(name: string, value: number): ProceduralTexture;
  89929. /**
  89930. * Set an array of floats in the shader.
  89931. * @param name Define the name of the uniform as defined in the shader
  89932. * @param value Define the value to give to the uniform
  89933. * @return the texture itself allowing "fluent" like uniform updates
  89934. */
  89935. setFloats(name: string, value: number[]): ProceduralTexture;
  89936. /**
  89937. * Set a vec3 in the shader from a Color3.
  89938. * @param name Define the name of the uniform as defined in the shader
  89939. * @param value Define the value to give to the uniform
  89940. * @return the texture itself allowing "fluent" like uniform updates
  89941. */
  89942. setColor3(name: string, value: Color3): ProceduralTexture;
  89943. /**
  89944. * Set a vec4 in the shader from a Color4.
  89945. * @param name Define the name of the uniform as defined in the shader
  89946. * @param value Define the value to give to the uniform
  89947. * @return the texture itself allowing "fluent" like uniform updates
  89948. */
  89949. setColor4(name: string, value: Color4): ProceduralTexture;
  89950. /**
  89951. * Set a vec2 in the shader from a Vector2.
  89952. * @param name Define the name of the uniform as defined in the shader
  89953. * @param value Define the value to give to the uniform
  89954. * @return the texture itself allowing "fluent" like uniform updates
  89955. */
  89956. setVector2(name: string, value: Vector2): ProceduralTexture;
  89957. /**
  89958. * Set a vec3 in the shader from a Vector3.
  89959. * @param name Define the name of the uniform as defined in the shader
  89960. * @param value Define the value to give to the uniform
  89961. * @return the texture itself allowing "fluent" like uniform updates
  89962. */
  89963. setVector3(name: string, value: Vector3): ProceduralTexture;
  89964. /**
  89965. * Set a mat4 in the shader from a MAtrix.
  89966. * @param name Define the name of the uniform as defined in the shader
  89967. * @param value Define the value to give to the uniform
  89968. * @return the texture itself allowing "fluent" like uniform updates
  89969. */
  89970. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89971. /**
  89972. * Render the texture to its associated render target.
  89973. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89974. */
  89975. render(useCameraPostProcess?: boolean): void;
  89976. /**
  89977. * Clone the texture.
  89978. * @returns the cloned texture
  89979. */
  89980. clone(): ProceduralTexture;
  89981. /**
  89982. * Dispose the texture and release its asoociated resources.
  89983. */
  89984. dispose(): void;
  89985. }
  89986. }
  89987. declare module BABYLON {
  89988. /**
  89989. * This represents the base class for particle system in Babylon.
  89990. * 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.
  89991. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89992. * @example https://doc.babylonjs.com/babylon101/particles
  89993. */
  89994. export class BaseParticleSystem {
  89995. /**
  89996. * Source color is added to the destination color without alpha affecting the result
  89997. */
  89998. static BLENDMODE_ONEONE: number;
  89999. /**
  90000. * Blend current color and particle color using particle’s alpha
  90001. */
  90002. static BLENDMODE_STANDARD: number;
  90003. /**
  90004. * Add current color and particle color multiplied by particle’s alpha
  90005. */
  90006. static BLENDMODE_ADD: number;
  90007. /**
  90008. * Multiply current color with particle color
  90009. */
  90010. static BLENDMODE_MULTIPLY: number;
  90011. /**
  90012. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90013. */
  90014. static BLENDMODE_MULTIPLYADD: number;
  90015. /**
  90016. * List of animations used by the particle system.
  90017. */
  90018. animations: Animation[];
  90019. /**
  90020. * Gets or sets the unique id of the particle system
  90021. */
  90022. uniqueId: number;
  90023. /**
  90024. * The id of the Particle system.
  90025. */
  90026. id: string;
  90027. /**
  90028. * The friendly name of the Particle system.
  90029. */
  90030. name: string;
  90031. /**
  90032. * Snippet ID if the particle system was created from the snippet server
  90033. */
  90034. snippetId: string;
  90035. /**
  90036. * The rendering group used by the Particle system to chose when to render.
  90037. */
  90038. renderingGroupId: number;
  90039. /**
  90040. * The emitter represents the Mesh or position we are attaching the particle system to.
  90041. */
  90042. emitter: Nullable<AbstractMesh | Vector3>;
  90043. /**
  90044. * The maximum number of particles to emit per frame
  90045. */
  90046. emitRate: number;
  90047. /**
  90048. * If you want to launch only a few particles at once, that can be done, as well.
  90049. */
  90050. manualEmitCount: number;
  90051. /**
  90052. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90053. */
  90054. updateSpeed: number;
  90055. /**
  90056. * The amount of time the particle system is running (depends of the overall update speed).
  90057. */
  90058. targetStopDuration: number;
  90059. /**
  90060. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90061. */
  90062. disposeOnStop: boolean;
  90063. /**
  90064. * Minimum power of emitting particles.
  90065. */
  90066. minEmitPower: number;
  90067. /**
  90068. * Maximum power of emitting particles.
  90069. */
  90070. maxEmitPower: number;
  90071. /**
  90072. * Minimum life time of emitting particles.
  90073. */
  90074. minLifeTime: number;
  90075. /**
  90076. * Maximum life time of emitting particles.
  90077. */
  90078. maxLifeTime: number;
  90079. /**
  90080. * Minimum Size of emitting particles.
  90081. */
  90082. minSize: number;
  90083. /**
  90084. * Maximum Size of emitting particles.
  90085. */
  90086. maxSize: number;
  90087. /**
  90088. * Minimum scale of emitting particles on X axis.
  90089. */
  90090. minScaleX: number;
  90091. /**
  90092. * Maximum scale of emitting particles on X axis.
  90093. */
  90094. maxScaleX: number;
  90095. /**
  90096. * Minimum scale of emitting particles on Y axis.
  90097. */
  90098. minScaleY: number;
  90099. /**
  90100. * Maximum scale of emitting particles on Y axis.
  90101. */
  90102. maxScaleY: number;
  90103. /**
  90104. * Gets or sets the minimal initial rotation in radians.
  90105. */
  90106. minInitialRotation: number;
  90107. /**
  90108. * Gets or sets the maximal initial rotation in radians.
  90109. */
  90110. maxInitialRotation: number;
  90111. /**
  90112. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90113. */
  90114. minAngularSpeed: number;
  90115. /**
  90116. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90117. */
  90118. maxAngularSpeed: number;
  90119. /**
  90120. * The texture used to render each particle. (this can be a spritesheet)
  90121. */
  90122. particleTexture: Nullable<Texture>;
  90123. /**
  90124. * The layer mask we are rendering the particles through.
  90125. */
  90126. layerMask: number;
  90127. /**
  90128. * This can help using your own shader to render the particle system.
  90129. * The according effect will be created
  90130. */
  90131. customShader: any;
  90132. /**
  90133. * By default particle system starts as soon as they are created. This prevents the
  90134. * automatic start to happen and let you decide when to start emitting particles.
  90135. */
  90136. preventAutoStart: boolean;
  90137. private _noiseTexture;
  90138. /**
  90139. * Gets or sets a texture used to add random noise to particle positions
  90140. */
  90141. get noiseTexture(): Nullable<ProceduralTexture>;
  90142. set noiseTexture(value: Nullable<ProceduralTexture>);
  90143. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90144. noiseStrength: Vector3;
  90145. /**
  90146. * Callback triggered when the particle animation is ending.
  90147. */
  90148. onAnimationEnd: Nullable<() => void>;
  90149. /**
  90150. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90151. */
  90152. blendMode: number;
  90153. /**
  90154. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90155. * to override the particles.
  90156. */
  90157. forceDepthWrite: boolean;
  90158. /** 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 */
  90159. preWarmCycles: number;
  90160. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  90161. preWarmStepOffset: number;
  90162. /**
  90163. * 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)
  90164. */
  90165. spriteCellChangeSpeed: number;
  90166. /**
  90167. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90168. */
  90169. startSpriteCellID: number;
  90170. /**
  90171. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90172. */
  90173. endSpriteCellID: number;
  90174. /**
  90175. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90176. */
  90177. spriteCellWidth: number;
  90178. /**
  90179. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90180. */
  90181. spriteCellHeight: number;
  90182. /**
  90183. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90184. */
  90185. spriteRandomStartCell: boolean;
  90186. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90187. translationPivot: Vector2;
  90188. /** @hidden */
  90189. protected _isAnimationSheetEnabled: boolean;
  90190. /**
  90191. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90192. */
  90193. beginAnimationOnStart: boolean;
  90194. /**
  90195. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90196. */
  90197. beginAnimationFrom: number;
  90198. /**
  90199. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90200. */
  90201. beginAnimationTo: number;
  90202. /**
  90203. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90204. */
  90205. beginAnimationLoop: boolean;
  90206. /**
  90207. * Gets or sets a world offset applied to all particles
  90208. */
  90209. worldOffset: Vector3;
  90210. /**
  90211. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  90212. */
  90213. get isAnimationSheetEnabled(): boolean;
  90214. set isAnimationSheetEnabled(value: boolean);
  90215. /**
  90216. * Get hosting scene
  90217. * @returns the scene
  90218. */
  90219. getScene(): Scene;
  90220. /**
  90221. * You can use gravity if you want to give an orientation to your particles.
  90222. */
  90223. gravity: Vector3;
  90224. protected _colorGradients: Nullable<Array<ColorGradient>>;
  90225. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  90226. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  90227. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  90228. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  90229. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  90230. protected _dragGradients: Nullable<Array<FactorGradient>>;
  90231. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  90232. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  90233. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  90234. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  90235. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  90236. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  90237. /**
  90238. * Defines the delay in milliseconds before starting the system (0 by default)
  90239. */
  90240. startDelay: number;
  90241. /**
  90242. * Gets the current list of drag gradients.
  90243. * You must use addDragGradient and removeDragGradient to udpate this list
  90244. * @returns the list of drag gradients
  90245. */
  90246. getDragGradients(): Nullable<Array<FactorGradient>>;
  90247. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90248. limitVelocityDamping: number;
  90249. /**
  90250. * Gets the current list of limit velocity gradients.
  90251. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90252. * @returns the list of limit velocity gradients
  90253. */
  90254. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90255. /**
  90256. * Gets the current list of color gradients.
  90257. * You must use addColorGradient and removeColorGradient to udpate this list
  90258. * @returns the list of color gradients
  90259. */
  90260. getColorGradients(): Nullable<Array<ColorGradient>>;
  90261. /**
  90262. * Gets the current list of size gradients.
  90263. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90264. * @returns the list of size gradients
  90265. */
  90266. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90267. /**
  90268. * Gets the current list of color remap gradients.
  90269. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90270. * @returns the list of color remap gradients
  90271. */
  90272. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90273. /**
  90274. * Gets the current list of alpha remap gradients.
  90275. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90276. * @returns the list of alpha remap gradients
  90277. */
  90278. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90279. /**
  90280. * Gets the current list of life time gradients.
  90281. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90282. * @returns the list of life time gradients
  90283. */
  90284. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  90285. /**
  90286. * Gets the current list of angular speed gradients.
  90287. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  90288. * @returns the list of angular speed gradients
  90289. */
  90290. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  90291. /**
  90292. * Gets the current list of velocity gradients.
  90293. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  90294. * @returns the list of velocity gradients
  90295. */
  90296. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  90297. /**
  90298. * Gets the current list of start size gradients.
  90299. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  90300. * @returns the list of start size gradients
  90301. */
  90302. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  90303. /**
  90304. * Gets the current list of emit rate gradients.
  90305. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  90306. * @returns the list of emit rate gradients
  90307. */
  90308. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  90309. /**
  90310. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90311. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90312. */
  90313. get direction1(): Vector3;
  90314. set direction1(value: Vector3);
  90315. /**
  90316. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90317. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90318. */
  90319. get direction2(): Vector3;
  90320. set direction2(value: Vector3);
  90321. /**
  90322. * 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.
  90323. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90324. */
  90325. get minEmitBox(): Vector3;
  90326. set minEmitBox(value: Vector3);
  90327. /**
  90328. * 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.
  90329. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90330. */
  90331. get maxEmitBox(): Vector3;
  90332. set maxEmitBox(value: Vector3);
  90333. /**
  90334. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90335. */
  90336. color1: Color4;
  90337. /**
  90338. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90339. */
  90340. color2: Color4;
  90341. /**
  90342. * Color the particle will have at the end of its lifetime
  90343. */
  90344. colorDead: Color4;
  90345. /**
  90346. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  90347. */
  90348. textureMask: Color4;
  90349. /**
  90350. * The particle emitter type defines the emitter used by the particle system.
  90351. * It can be for example box, sphere, or cone...
  90352. */
  90353. particleEmitterType: IParticleEmitterType;
  90354. /** @hidden */
  90355. _isSubEmitter: boolean;
  90356. /**
  90357. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90358. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90359. */
  90360. billboardMode: number;
  90361. protected _isBillboardBased: boolean;
  90362. /**
  90363. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90364. */
  90365. get isBillboardBased(): boolean;
  90366. set isBillboardBased(value: boolean);
  90367. /**
  90368. * The scene the particle system belongs to.
  90369. */
  90370. protected _scene: Scene;
  90371. /**
  90372. * Local cache of defines for image processing.
  90373. */
  90374. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  90375. /**
  90376. * Default configuration related to image processing available in the standard Material.
  90377. */
  90378. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90379. /**
  90380. * Gets the image processing configuration used either in this material.
  90381. */
  90382. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  90383. /**
  90384. * Sets the Default image processing configuration used either in the this material.
  90385. *
  90386. * If sets to null, the scene one is in use.
  90387. */
  90388. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  90389. /**
  90390. * Attaches a new image processing configuration to the Standard Material.
  90391. * @param configuration
  90392. */
  90393. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  90394. /** @hidden */
  90395. protected _reset(): void;
  90396. /** @hidden */
  90397. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  90398. /**
  90399. * Instantiates a particle system.
  90400. * 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.
  90401. * @param name The name of the particle system
  90402. */
  90403. constructor(name: string);
  90404. /**
  90405. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90406. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90407. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90408. * @returns the emitter
  90409. */
  90410. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90411. /**
  90412. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90413. * @param radius The radius of the hemisphere to emit from
  90414. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90415. * @returns the emitter
  90416. */
  90417. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90418. /**
  90419. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90420. * @param radius The radius of the sphere to emit from
  90421. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90422. * @returns the emitter
  90423. */
  90424. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90425. /**
  90426. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90427. * @param radius The radius of the sphere to emit from
  90428. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90429. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90430. * @returns the emitter
  90431. */
  90432. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90433. /**
  90434. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90435. * @param radius The radius of the emission cylinder
  90436. * @param height The height of the emission cylinder
  90437. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90438. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90439. * @returns the emitter
  90440. */
  90441. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90442. /**
  90443. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90444. * @param radius The radius of the cylinder to emit from
  90445. * @param height The height of the emission cylinder
  90446. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90449. * @returns the emitter
  90450. */
  90451. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90452. /**
  90453. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90454. * @param radius The radius of the cone to emit from
  90455. * @param angle The base angle of the cone
  90456. * @returns the emitter
  90457. */
  90458. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90459. /**
  90460. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90461. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90462. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90463. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90464. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90465. * @returns the emitter
  90466. */
  90467. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90468. }
  90469. }
  90470. declare module BABYLON {
  90471. /**
  90472. * Type of sub emitter
  90473. */
  90474. export enum SubEmitterType {
  90475. /**
  90476. * Attached to the particle over it's lifetime
  90477. */
  90478. ATTACHED = 0,
  90479. /**
  90480. * Created when the particle dies
  90481. */
  90482. END = 1
  90483. }
  90484. /**
  90485. * Sub emitter class used to emit particles from an existing particle
  90486. */
  90487. export class SubEmitter {
  90488. /**
  90489. * the particle system to be used by the sub emitter
  90490. */
  90491. particleSystem: ParticleSystem;
  90492. /**
  90493. * Type of the submitter (Default: END)
  90494. */
  90495. type: SubEmitterType;
  90496. /**
  90497. * 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)
  90498. * Note: This only is supported when using an emitter of type Mesh
  90499. */
  90500. inheritDirection: boolean;
  90501. /**
  90502. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90503. */
  90504. inheritedVelocityAmount: number;
  90505. /**
  90506. * Creates a sub emitter
  90507. * @param particleSystem the particle system to be used by the sub emitter
  90508. */
  90509. constructor(
  90510. /**
  90511. * the particle system to be used by the sub emitter
  90512. */
  90513. particleSystem: ParticleSystem);
  90514. /**
  90515. * Clones the sub emitter
  90516. * @returns the cloned sub emitter
  90517. */
  90518. clone(): SubEmitter;
  90519. /**
  90520. * Serialize current object to a JSON object
  90521. * @returns the serialized object
  90522. */
  90523. serialize(): any;
  90524. /** @hidden */
  90525. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90526. /**
  90527. * Creates a new SubEmitter from a serialized JSON version
  90528. * @param serializationObject defines the JSON object to read from
  90529. * @param scene defines the hosting scene
  90530. * @param rootUrl defines the rootUrl for data loading
  90531. * @returns a new SubEmitter
  90532. */
  90533. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90534. /** Release associated resources */
  90535. dispose(): void;
  90536. }
  90537. }
  90538. declare module BABYLON {
  90539. /** @hidden */
  90540. export var imageProcessingDeclaration: {
  90541. name: string;
  90542. shader: string;
  90543. };
  90544. }
  90545. declare module BABYLON {
  90546. /** @hidden */
  90547. export var imageProcessingFunctions: {
  90548. name: string;
  90549. shader: string;
  90550. };
  90551. }
  90552. declare module BABYLON {
  90553. /** @hidden */
  90554. export var particlesPixelShader: {
  90555. name: string;
  90556. shader: string;
  90557. };
  90558. }
  90559. declare module BABYLON {
  90560. /** @hidden */
  90561. export var particlesVertexShader: {
  90562. name: string;
  90563. shader: string;
  90564. };
  90565. }
  90566. declare module BABYLON {
  90567. /**
  90568. * This represents a particle system in Babylon.
  90569. * 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.
  90570. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90571. * @example https://doc.babylonjs.com/babylon101/particles
  90572. */
  90573. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90574. /**
  90575. * Billboard mode will only apply to Y axis
  90576. */
  90577. static readonly BILLBOARDMODE_Y: number;
  90578. /**
  90579. * Billboard mode will apply to all axes
  90580. */
  90581. static readonly BILLBOARDMODE_ALL: number;
  90582. /**
  90583. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90584. */
  90585. static readonly BILLBOARDMODE_STRETCHED: number;
  90586. /**
  90587. * This function can be defined to provide custom update for active particles.
  90588. * This function will be called instead of regular update (age, position, color, etc.).
  90589. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90590. */
  90591. updateFunction: (particles: Particle[]) => void;
  90592. private _emitterWorldMatrix;
  90593. /**
  90594. * This function can be defined to specify initial direction for every new particle.
  90595. * It by default use the emitterType defined function
  90596. */
  90597. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90598. /**
  90599. * This function can be defined to specify initial position for every new particle.
  90600. * It by default use the emitterType defined function
  90601. */
  90602. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90603. /**
  90604. * @hidden
  90605. */
  90606. _inheritedVelocityOffset: Vector3;
  90607. /**
  90608. * An event triggered when the system is disposed
  90609. */
  90610. onDisposeObservable: Observable<IParticleSystem>;
  90611. private _onDisposeObserver;
  90612. /**
  90613. * Sets a callback that will be triggered when the system is disposed
  90614. */
  90615. set onDispose(callback: () => void);
  90616. private _particles;
  90617. private _epsilon;
  90618. private _capacity;
  90619. private _stockParticles;
  90620. private _newPartsExcess;
  90621. private _vertexData;
  90622. private _vertexBuffer;
  90623. private _vertexBuffers;
  90624. private _spriteBuffer;
  90625. private _indexBuffer;
  90626. private _effect;
  90627. private _customEffect;
  90628. private _cachedDefines;
  90629. private _scaledColorStep;
  90630. private _colorDiff;
  90631. private _scaledDirection;
  90632. private _scaledGravity;
  90633. private _currentRenderId;
  90634. private _alive;
  90635. private _useInstancing;
  90636. private _started;
  90637. private _stopped;
  90638. private _actualFrame;
  90639. private _scaledUpdateSpeed;
  90640. private _vertexBufferSize;
  90641. /** @hidden */
  90642. _currentEmitRateGradient: Nullable<FactorGradient>;
  90643. /** @hidden */
  90644. _currentEmitRate1: number;
  90645. /** @hidden */
  90646. _currentEmitRate2: number;
  90647. /** @hidden */
  90648. _currentStartSizeGradient: Nullable<FactorGradient>;
  90649. /** @hidden */
  90650. _currentStartSize1: number;
  90651. /** @hidden */
  90652. _currentStartSize2: number;
  90653. private readonly _rawTextureWidth;
  90654. private _rampGradientsTexture;
  90655. private _useRampGradients;
  90656. /** Gets or sets a boolean indicating that ramp gradients must be used
  90657. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90658. */
  90659. get useRampGradients(): boolean;
  90660. set useRampGradients(value: boolean);
  90661. /**
  90662. * 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.
  90663. * 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: [])
  90664. */
  90665. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90666. private _subEmitters;
  90667. /**
  90668. * @hidden
  90669. * If the particle systems emitter should be disposed when the particle system is disposed
  90670. */
  90671. _disposeEmitterOnDispose: boolean;
  90672. /**
  90673. * The current active Sub-systems, this property is used by the root particle system only.
  90674. */
  90675. activeSubSystems: Array<ParticleSystem>;
  90676. /**
  90677. * Specifies if the particles are updated in emitter local space or world space
  90678. */
  90679. isLocal: boolean;
  90680. private _rootParticleSystem;
  90681. /**
  90682. * Gets the current list of active particles
  90683. */
  90684. get particles(): Particle[];
  90685. /**
  90686. * Gets the number of particles active at the same time.
  90687. * @returns The number of active particles.
  90688. */
  90689. getActiveCount(): number;
  90690. /**
  90691. * Returns the string "ParticleSystem"
  90692. * @returns a string containing the class name
  90693. */
  90694. getClassName(): string;
  90695. /**
  90696. * Gets a boolean indicating that the system is stopping
  90697. * @returns true if the system is currently stopping
  90698. */
  90699. isStopping(): boolean;
  90700. /**
  90701. * Gets the custom effect used to render the particles
  90702. * @param blendMode Blend mode for which the effect should be retrieved
  90703. * @returns The effect
  90704. */
  90705. getCustomEffect(blendMode?: number): Nullable<Effect>;
  90706. /**
  90707. * Sets the custom effect used to render the particles
  90708. * @param effect The effect to set
  90709. * @param blendMode Blend mode for which the effect should be set
  90710. */
  90711. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  90712. /** @hidden */
  90713. private _onBeforeDrawParticlesObservable;
  90714. /**
  90715. * Observable that will be called just before the particles are drawn
  90716. */
  90717. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  90718. /**
  90719. * Gets the name of the particle vertex shader
  90720. */
  90721. get vertexShaderName(): string;
  90722. /**
  90723. * Instantiates a particle system.
  90724. * 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.
  90725. * @param name The name of the particle system
  90726. * @param capacity The max number of particles alive at the same time
  90727. * @param scene The scene the particle system belongs to
  90728. * @param customEffect a custom effect used to change the way particles are rendered by default
  90729. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90730. * @param epsilon Offset used to render the particles
  90731. */
  90732. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90733. private _addFactorGradient;
  90734. private _removeFactorGradient;
  90735. /**
  90736. * Adds a new life time gradient
  90737. * @param gradient defines the gradient to use (between 0 and 1)
  90738. * @param factor defines the life time factor to affect to the specified gradient
  90739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90740. * @returns the current particle system
  90741. */
  90742. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90743. /**
  90744. * Remove a specific life time gradient
  90745. * @param gradient defines the gradient to remove
  90746. * @returns the current particle system
  90747. */
  90748. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90749. /**
  90750. * Adds a new size gradient
  90751. * @param gradient defines the gradient to use (between 0 and 1)
  90752. * @param factor defines the size factor to affect to the specified gradient
  90753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90754. * @returns the current particle system
  90755. */
  90756. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90757. /**
  90758. * Remove a specific size gradient
  90759. * @param gradient defines the gradient to remove
  90760. * @returns the current particle system
  90761. */
  90762. removeSizeGradient(gradient: number): IParticleSystem;
  90763. /**
  90764. * Adds a new color remap gradient
  90765. * @param gradient defines the gradient to use (between 0 and 1)
  90766. * @param min defines the color remap minimal range
  90767. * @param max defines the color remap maximal range
  90768. * @returns the current particle system
  90769. */
  90770. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90771. /**
  90772. * Remove a specific color remap gradient
  90773. * @param gradient defines the gradient to remove
  90774. * @returns the current particle system
  90775. */
  90776. removeColorRemapGradient(gradient: number): IParticleSystem;
  90777. /**
  90778. * Adds a new alpha remap gradient
  90779. * @param gradient defines the gradient to use (between 0 and 1)
  90780. * @param min defines the alpha remap minimal range
  90781. * @param max defines the alpha remap maximal range
  90782. * @returns the current particle system
  90783. */
  90784. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90785. /**
  90786. * Remove a specific alpha remap gradient
  90787. * @param gradient defines the gradient to remove
  90788. * @returns the current particle system
  90789. */
  90790. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90791. /**
  90792. * Adds a new angular speed gradient
  90793. * @param gradient defines the gradient to use (between 0 and 1)
  90794. * @param factor defines the angular speed to affect to the specified gradient
  90795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90796. * @returns the current particle system
  90797. */
  90798. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90799. /**
  90800. * Remove a specific angular speed gradient
  90801. * @param gradient defines the gradient to remove
  90802. * @returns the current particle system
  90803. */
  90804. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90805. /**
  90806. * Adds a new velocity gradient
  90807. * @param gradient defines the gradient to use (between 0 and 1)
  90808. * @param factor defines the velocity to affect to the specified gradient
  90809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90810. * @returns the current particle system
  90811. */
  90812. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90813. /**
  90814. * Remove a specific velocity gradient
  90815. * @param gradient defines the gradient to remove
  90816. * @returns the current particle system
  90817. */
  90818. removeVelocityGradient(gradient: number): IParticleSystem;
  90819. /**
  90820. * Adds a new limit velocity gradient
  90821. * @param gradient defines the gradient to use (between 0 and 1)
  90822. * @param factor defines the limit velocity value to affect to the specified gradient
  90823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90824. * @returns the current particle system
  90825. */
  90826. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90827. /**
  90828. * Remove a specific limit velocity gradient
  90829. * @param gradient defines the gradient to remove
  90830. * @returns the current particle system
  90831. */
  90832. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90833. /**
  90834. * Adds a new drag gradient
  90835. * @param gradient defines the gradient to use (between 0 and 1)
  90836. * @param factor defines the drag value to affect to the specified gradient
  90837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90838. * @returns the current particle system
  90839. */
  90840. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90841. /**
  90842. * Remove a specific drag gradient
  90843. * @param gradient defines the gradient to remove
  90844. * @returns the current particle system
  90845. */
  90846. removeDragGradient(gradient: number): IParticleSystem;
  90847. /**
  90848. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90849. * @param gradient defines the gradient to use (between 0 and 1)
  90850. * @param factor defines the emit rate value to affect to the specified gradient
  90851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90852. * @returns the current particle system
  90853. */
  90854. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90855. /**
  90856. * Remove a specific emit rate gradient
  90857. * @param gradient defines the gradient to remove
  90858. * @returns the current particle system
  90859. */
  90860. removeEmitRateGradient(gradient: number): IParticleSystem;
  90861. /**
  90862. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90863. * @param gradient defines the gradient to use (between 0 and 1)
  90864. * @param factor defines the start size value to affect to the specified gradient
  90865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90866. * @returns the current particle system
  90867. */
  90868. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90869. /**
  90870. * Remove a specific start size gradient
  90871. * @param gradient defines the gradient to remove
  90872. * @returns the current particle system
  90873. */
  90874. removeStartSizeGradient(gradient: number): IParticleSystem;
  90875. private _createRampGradientTexture;
  90876. /**
  90877. * Gets the current list of ramp gradients.
  90878. * You must use addRampGradient and removeRampGradient to udpate this list
  90879. * @returns the list of ramp gradients
  90880. */
  90881. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90882. /** Force the system to rebuild all gradients that need to be resync */
  90883. forceRefreshGradients(): void;
  90884. private _syncRampGradientTexture;
  90885. /**
  90886. * Adds a new ramp gradient used to remap particle colors
  90887. * @param gradient defines the gradient to use (between 0 and 1)
  90888. * @param color defines the color to affect to the specified gradient
  90889. * @returns the current particle system
  90890. */
  90891. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90892. /**
  90893. * Remove a specific ramp gradient
  90894. * @param gradient defines the gradient to remove
  90895. * @returns the current particle system
  90896. */
  90897. removeRampGradient(gradient: number): ParticleSystem;
  90898. /**
  90899. * Adds a new color gradient
  90900. * @param gradient defines the gradient to use (between 0 and 1)
  90901. * @param color1 defines the color to affect to the specified gradient
  90902. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90903. * @returns this particle system
  90904. */
  90905. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90906. /**
  90907. * Remove a specific color gradient
  90908. * @param gradient defines the gradient to remove
  90909. * @returns this particle system
  90910. */
  90911. removeColorGradient(gradient: number): IParticleSystem;
  90912. private _fetchR;
  90913. protected _reset(): void;
  90914. private _resetEffect;
  90915. private _createVertexBuffers;
  90916. private _createIndexBuffer;
  90917. /**
  90918. * Gets the maximum number of particles active at the same time.
  90919. * @returns The max number of active particles.
  90920. */
  90921. getCapacity(): number;
  90922. /**
  90923. * Gets whether there are still active particles in the system.
  90924. * @returns True if it is alive, otherwise false.
  90925. */
  90926. isAlive(): boolean;
  90927. /**
  90928. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90929. * @returns True if it has been started, otherwise false.
  90930. */
  90931. isStarted(): boolean;
  90932. private _prepareSubEmitterInternalArray;
  90933. /**
  90934. * Starts the particle system and begins to emit
  90935. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90936. */
  90937. start(delay?: number): void;
  90938. /**
  90939. * Stops the particle system.
  90940. * @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.
  90941. */
  90942. stop(stopSubEmitters?: boolean): void;
  90943. /**
  90944. * Remove all active particles
  90945. */
  90946. reset(): void;
  90947. /**
  90948. * @hidden (for internal use only)
  90949. */
  90950. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90951. /**
  90952. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90953. * Its lifetime will start back at 0.
  90954. */
  90955. recycleParticle: (particle: Particle) => void;
  90956. private _stopSubEmitters;
  90957. private _createParticle;
  90958. private _removeFromRoot;
  90959. private _emitFromParticle;
  90960. private _update;
  90961. /** @hidden */
  90962. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90963. /** @hidden */
  90964. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90965. /**
  90966. * Fill the defines array according to the current settings of the particle system
  90967. * @param defines Array to be updated
  90968. * @param blendMode blend mode to take into account when updating the array
  90969. */
  90970. fillDefines(defines: Array<string>, blendMode: number): void;
  90971. /**
  90972. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90973. * @param uniforms Uniforms array to fill
  90974. * @param attributes Attributes array to fill
  90975. * @param samplers Samplers array to fill
  90976. */
  90977. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90978. /** @hidden */
  90979. private _getEffect;
  90980. /**
  90981. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90982. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90983. */
  90984. animate(preWarmOnly?: boolean): void;
  90985. private _appendParticleVertices;
  90986. /**
  90987. * Rebuilds the particle system.
  90988. */
  90989. rebuild(): void;
  90990. /**
  90991. * Is this system ready to be used/rendered
  90992. * @return true if the system is ready
  90993. */
  90994. isReady(): boolean;
  90995. private _render;
  90996. /**
  90997. * Renders the particle system in its current state.
  90998. * @returns the current number of particles
  90999. */
  91000. render(): number;
  91001. /**
  91002. * Disposes the particle system and free the associated resources
  91003. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91004. */
  91005. dispose(disposeTexture?: boolean): void;
  91006. /**
  91007. * Clones the particle system.
  91008. * @param name The name of the cloned object
  91009. * @param newEmitter The new emitter to use
  91010. * @returns the cloned particle system
  91011. */
  91012. clone(name: string, newEmitter: any): ParticleSystem;
  91013. /**
  91014. * Serializes the particle system to a JSON object
  91015. * @param serializeTexture defines if the texture must be serialized as well
  91016. * @returns the JSON object
  91017. */
  91018. serialize(serializeTexture?: boolean): any;
  91019. /** @hidden */
  91020. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91021. /** @hidden */
  91022. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  91023. /**
  91024. * Parses a JSON object to create a particle system.
  91025. * @param parsedParticleSystem The JSON object to parse
  91026. * @param scene The scene to create the particle system in
  91027. * @param rootUrl The root url to use to load external dependencies like texture
  91028. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91029. * @returns the Parsed particle system
  91030. */
  91031. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91032. }
  91033. }
  91034. declare module BABYLON {
  91035. /**
  91036. * A particle represents one of the element emitted by a particle system.
  91037. * This is mainly define by its coordinates, direction, velocity and age.
  91038. */
  91039. export class Particle {
  91040. /**
  91041. * The particle system the particle belongs to.
  91042. */
  91043. particleSystem: ParticleSystem;
  91044. private static _Count;
  91045. /**
  91046. * Unique ID of the particle
  91047. */
  91048. id: number;
  91049. /**
  91050. * The world position of the particle in the scene.
  91051. */
  91052. position: Vector3;
  91053. /**
  91054. * The world direction of the particle in the scene.
  91055. */
  91056. direction: Vector3;
  91057. /**
  91058. * The color of the particle.
  91059. */
  91060. color: Color4;
  91061. /**
  91062. * The color change of the particle per step.
  91063. */
  91064. colorStep: Color4;
  91065. /**
  91066. * Defines how long will the life of the particle be.
  91067. */
  91068. lifeTime: number;
  91069. /**
  91070. * The current age of the particle.
  91071. */
  91072. age: number;
  91073. /**
  91074. * The current size of the particle.
  91075. */
  91076. size: number;
  91077. /**
  91078. * The current scale of the particle.
  91079. */
  91080. scale: Vector2;
  91081. /**
  91082. * The current angle of the particle.
  91083. */
  91084. angle: number;
  91085. /**
  91086. * Defines how fast is the angle changing.
  91087. */
  91088. angularSpeed: number;
  91089. /**
  91090. * Defines the cell index used by the particle to be rendered from a sprite.
  91091. */
  91092. cellIndex: number;
  91093. /**
  91094. * The information required to support color remapping
  91095. */
  91096. remapData: Vector4;
  91097. /** @hidden */
  91098. _randomCellOffset?: number;
  91099. /** @hidden */
  91100. _initialDirection: Nullable<Vector3>;
  91101. /** @hidden */
  91102. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  91103. /** @hidden */
  91104. _initialStartSpriteCellID: number;
  91105. /** @hidden */
  91106. _initialEndSpriteCellID: number;
  91107. /** @hidden */
  91108. _currentColorGradient: Nullable<ColorGradient>;
  91109. /** @hidden */
  91110. _currentColor1: Color4;
  91111. /** @hidden */
  91112. _currentColor2: Color4;
  91113. /** @hidden */
  91114. _currentSizeGradient: Nullable<FactorGradient>;
  91115. /** @hidden */
  91116. _currentSize1: number;
  91117. /** @hidden */
  91118. _currentSize2: number;
  91119. /** @hidden */
  91120. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  91121. /** @hidden */
  91122. _currentAngularSpeed1: number;
  91123. /** @hidden */
  91124. _currentAngularSpeed2: number;
  91125. /** @hidden */
  91126. _currentVelocityGradient: Nullable<FactorGradient>;
  91127. /** @hidden */
  91128. _currentVelocity1: number;
  91129. /** @hidden */
  91130. _currentVelocity2: number;
  91131. /** @hidden */
  91132. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  91133. /** @hidden */
  91134. _currentLimitVelocity1: number;
  91135. /** @hidden */
  91136. _currentLimitVelocity2: number;
  91137. /** @hidden */
  91138. _currentDragGradient: Nullable<FactorGradient>;
  91139. /** @hidden */
  91140. _currentDrag1: number;
  91141. /** @hidden */
  91142. _currentDrag2: number;
  91143. /** @hidden */
  91144. _randomNoiseCoordinates1: Vector3;
  91145. /** @hidden */
  91146. _randomNoiseCoordinates2: Vector3;
  91147. /** @hidden */
  91148. _localPosition?: Vector3;
  91149. /**
  91150. * Creates a new instance Particle
  91151. * @param particleSystem the particle system the particle belongs to
  91152. */
  91153. constructor(
  91154. /**
  91155. * The particle system the particle belongs to.
  91156. */
  91157. particleSystem: ParticleSystem);
  91158. private updateCellInfoFromSystem;
  91159. /**
  91160. * Defines how the sprite cell index is updated for the particle
  91161. */
  91162. updateCellIndex(): void;
  91163. /** @hidden */
  91164. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  91165. /** @hidden */
  91166. _inheritParticleInfoToSubEmitters(): void;
  91167. /** @hidden */
  91168. _reset(): void;
  91169. /**
  91170. * Copy the properties of particle to another one.
  91171. * @param other the particle to copy the information to.
  91172. */
  91173. copyTo(other: Particle): void;
  91174. }
  91175. }
  91176. declare module BABYLON {
  91177. /**
  91178. * Particle emitter represents a volume emitting particles.
  91179. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  91180. */
  91181. export interface IParticleEmitterType {
  91182. /**
  91183. * Called by the particle System when the direction is computed for the created particle.
  91184. * @param worldMatrix is the world matrix of the particle system
  91185. * @param directionToUpdate is the direction vector to update with the result
  91186. * @param particle is the particle we are computed the direction for
  91187. * @param isLocal defines if the direction should be set in local space
  91188. */
  91189. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91190. /**
  91191. * Called by the particle System when the position is computed for the created particle.
  91192. * @param worldMatrix is the world matrix of the particle system
  91193. * @param positionToUpdate is the position vector to update with the result
  91194. * @param particle is the particle we are computed the position for
  91195. * @param isLocal defines if the position should be set in local space
  91196. */
  91197. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91198. /**
  91199. * Clones the current emitter and returns a copy of it
  91200. * @returns the new emitter
  91201. */
  91202. clone(): IParticleEmitterType;
  91203. /**
  91204. * Called by the GPUParticleSystem to setup the update shader
  91205. * @param effect defines the update shader
  91206. */
  91207. applyToShader(effect: Effect): void;
  91208. /**
  91209. * Returns a string to use to update the GPU particles update shader
  91210. * @returns the effect defines string
  91211. */
  91212. getEffectDefines(): string;
  91213. /**
  91214. * Returns a string representing the class name
  91215. * @returns a string containing the class name
  91216. */
  91217. getClassName(): string;
  91218. /**
  91219. * Serializes the particle system to a JSON object.
  91220. * @returns the JSON object
  91221. */
  91222. serialize(): any;
  91223. /**
  91224. * Parse properties from a JSON object
  91225. * @param serializationObject defines the JSON object
  91226. * @param scene defines the hosting scene
  91227. */
  91228. parse(serializationObject: any, scene: Scene): void;
  91229. }
  91230. }
  91231. declare module BABYLON {
  91232. /**
  91233. * Particle emitter emitting particles from the inside of a box.
  91234. * It emits the particles randomly between 2 given directions.
  91235. */
  91236. export class BoxParticleEmitter implements IParticleEmitterType {
  91237. /**
  91238. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91239. */
  91240. direction1: Vector3;
  91241. /**
  91242. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91243. */
  91244. direction2: Vector3;
  91245. /**
  91246. * 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.
  91247. */
  91248. minEmitBox: Vector3;
  91249. /**
  91250. * 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.
  91251. */
  91252. maxEmitBox: Vector3;
  91253. /**
  91254. * Creates a new instance BoxParticleEmitter
  91255. */
  91256. constructor();
  91257. /**
  91258. * Called by the particle System when the direction is computed for the created particle.
  91259. * @param worldMatrix is the world matrix of the particle system
  91260. * @param directionToUpdate is the direction vector to update with the result
  91261. * @param particle is the particle we are computed the direction for
  91262. * @param isLocal defines if the direction should be set in local space
  91263. */
  91264. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91265. /**
  91266. * Called by the particle System when the position is computed for the created particle.
  91267. * @param worldMatrix is the world matrix of the particle system
  91268. * @param positionToUpdate is the position vector to update with the result
  91269. * @param particle is the particle we are computed the position for
  91270. * @param isLocal defines if the position should be set in local space
  91271. */
  91272. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91273. /**
  91274. * Clones the current emitter and returns a copy of it
  91275. * @returns the new emitter
  91276. */
  91277. clone(): BoxParticleEmitter;
  91278. /**
  91279. * Called by the GPUParticleSystem to setup the update shader
  91280. * @param effect defines the update shader
  91281. */
  91282. applyToShader(effect: Effect): void;
  91283. /**
  91284. * Returns a string to use to update the GPU particles update shader
  91285. * @returns a string containng the defines string
  91286. */
  91287. getEffectDefines(): string;
  91288. /**
  91289. * Returns the string "BoxParticleEmitter"
  91290. * @returns a string containing the class name
  91291. */
  91292. getClassName(): string;
  91293. /**
  91294. * Serializes the particle system to a JSON object.
  91295. * @returns the JSON object
  91296. */
  91297. serialize(): any;
  91298. /**
  91299. * Parse properties from a JSON object
  91300. * @param serializationObject defines the JSON object
  91301. */
  91302. parse(serializationObject: any): void;
  91303. }
  91304. }
  91305. declare module BABYLON {
  91306. /**
  91307. * Particle emitter emitting particles from the inside of a cone.
  91308. * It emits the particles alongside the cone volume from the base to the particle.
  91309. * The emission direction might be randomized.
  91310. */
  91311. export class ConeParticleEmitter implements IParticleEmitterType {
  91312. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91313. directionRandomizer: number;
  91314. private _radius;
  91315. private _angle;
  91316. private _height;
  91317. /**
  91318. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  91319. */
  91320. radiusRange: number;
  91321. /**
  91322. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  91323. */
  91324. heightRange: number;
  91325. /**
  91326. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  91327. */
  91328. emitFromSpawnPointOnly: boolean;
  91329. /**
  91330. * Gets or sets the radius of the emission cone
  91331. */
  91332. get radius(): number;
  91333. set radius(value: number);
  91334. /**
  91335. * Gets or sets the angle of the emission cone
  91336. */
  91337. get angle(): number;
  91338. set angle(value: number);
  91339. private _buildHeight;
  91340. /**
  91341. * Creates a new instance ConeParticleEmitter
  91342. * @param radius the radius of the emission cone (1 by default)
  91343. * @param angle the cone base angle (PI by default)
  91344. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  91345. */
  91346. constructor(radius?: number, angle?: number,
  91347. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91348. directionRandomizer?: number);
  91349. /**
  91350. * Called by the particle System when the direction is computed for the created particle.
  91351. * @param worldMatrix is the world matrix of the particle system
  91352. * @param directionToUpdate is the direction vector to update with the result
  91353. * @param particle is the particle we are computed the direction for
  91354. * @param isLocal defines if the direction should be set in local space
  91355. */
  91356. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91357. /**
  91358. * Called by the particle System when the position is computed for the created particle.
  91359. * @param worldMatrix is the world matrix of the particle system
  91360. * @param positionToUpdate is the position vector to update with the result
  91361. * @param particle is the particle we are computed the position for
  91362. * @param isLocal defines if the position should be set in local space
  91363. */
  91364. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91365. /**
  91366. * Clones the current emitter and returns a copy of it
  91367. * @returns the new emitter
  91368. */
  91369. clone(): ConeParticleEmitter;
  91370. /**
  91371. * Called by the GPUParticleSystem to setup the update shader
  91372. * @param effect defines the update shader
  91373. */
  91374. applyToShader(effect: Effect): void;
  91375. /**
  91376. * Returns a string to use to update the GPU particles update shader
  91377. * @returns a string containng the defines string
  91378. */
  91379. getEffectDefines(): string;
  91380. /**
  91381. * Returns the string "ConeParticleEmitter"
  91382. * @returns a string containing the class name
  91383. */
  91384. getClassName(): string;
  91385. /**
  91386. * Serializes the particle system to a JSON object.
  91387. * @returns the JSON object
  91388. */
  91389. serialize(): any;
  91390. /**
  91391. * Parse properties from a JSON object
  91392. * @param serializationObject defines the JSON object
  91393. */
  91394. parse(serializationObject: any): void;
  91395. }
  91396. }
  91397. declare module BABYLON {
  91398. /**
  91399. * Particle emitter emitting particles from the inside of a cylinder.
  91400. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  91401. */
  91402. export class CylinderParticleEmitter implements IParticleEmitterType {
  91403. /**
  91404. * The radius of the emission cylinder.
  91405. */
  91406. radius: number;
  91407. /**
  91408. * The height of the emission cylinder.
  91409. */
  91410. height: number;
  91411. /**
  91412. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91413. */
  91414. radiusRange: number;
  91415. /**
  91416. * How much to randomize the particle direction [0-1].
  91417. */
  91418. directionRandomizer: number;
  91419. /**
  91420. * Creates a new instance CylinderParticleEmitter
  91421. * @param radius the radius of the emission cylinder (1 by default)
  91422. * @param height the height of the emission cylinder (1 by default)
  91423. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91424. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91425. */
  91426. constructor(
  91427. /**
  91428. * The radius of the emission cylinder.
  91429. */
  91430. radius?: number,
  91431. /**
  91432. * The height of the emission cylinder.
  91433. */
  91434. height?: number,
  91435. /**
  91436. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91437. */
  91438. radiusRange?: number,
  91439. /**
  91440. * How much to randomize the particle direction [0-1].
  91441. */
  91442. directionRandomizer?: number);
  91443. /**
  91444. * Called by the particle System when the direction is computed for the created particle.
  91445. * @param worldMatrix is the world matrix of the particle system
  91446. * @param directionToUpdate is the direction vector to update with the result
  91447. * @param particle is the particle we are computed the direction for
  91448. * @param isLocal defines if the direction should be set in local space
  91449. */
  91450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91451. /**
  91452. * Called by the particle System when the position is computed for the created particle.
  91453. * @param worldMatrix is the world matrix of the particle system
  91454. * @param positionToUpdate is the position vector to update with the result
  91455. * @param particle is the particle we are computed the position for
  91456. * @param isLocal defines if the position should be set in local space
  91457. */
  91458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91459. /**
  91460. * Clones the current emitter and returns a copy of it
  91461. * @returns the new emitter
  91462. */
  91463. clone(): CylinderParticleEmitter;
  91464. /**
  91465. * Called by the GPUParticleSystem to setup the update shader
  91466. * @param effect defines the update shader
  91467. */
  91468. applyToShader(effect: Effect): void;
  91469. /**
  91470. * Returns a string to use to update the GPU particles update shader
  91471. * @returns a string containng the defines string
  91472. */
  91473. getEffectDefines(): string;
  91474. /**
  91475. * Returns the string "CylinderParticleEmitter"
  91476. * @returns a string containing the class name
  91477. */
  91478. getClassName(): string;
  91479. /**
  91480. * Serializes the particle system to a JSON object.
  91481. * @returns the JSON object
  91482. */
  91483. serialize(): any;
  91484. /**
  91485. * Parse properties from a JSON object
  91486. * @param serializationObject defines the JSON object
  91487. */
  91488. parse(serializationObject: any): void;
  91489. }
  91490. /**
  91491. * Particle emitter emitting particles from the inside of a cylinder.
  91492. * It emits the particles randomly between two vectors.
  91493. */
  91494. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91495. /**
  91496. * The min limit of the emission direction.
  91497. */
  91498. direction1: Vector3;
  91499. /**
  91500. * The max limit of the emission direction.
  91501. */
  91502. direction2: Vector3;
  91503. /**
  91504. * Creates a new instance CylinderDirectedParticleEmitter
  91505. * @param radius the radius of the emission cylinder (1 by default)
  91506. * @param height the height of the emission cylinder (1 by default)
  91507. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91508. * @param direction1 the min limit of the emission direction (up vector by default)
  91509. * @param direction2 the max limit of the emission direction (up vector by default)
  91510. */
  91511. constructor(radius?: number, height?: number, radiusRange?: number,
  91512. /**
  91513. * The min limit of the emission direction.
  91514. */
  91515. direction1?: Vector3,
  91516. /**
  91517. * The max limit of the emission direction.
  91518. */
  91519. direction2?: Vector3);
  91520. /**
  91521. * Called by the particle System when the direction is computed for the created particle.
  91522. * @param worldMatrix is the world matrix of the particle system
  91523. * @param directionToUpdate is the direction vector to update with the result
  91524. * @param particle is the particle we are computed the direction for
  91525. */
  91526. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91527. /**
  91528. * Clones the current emitter and returns a copy of it
  91529. * @returns the new emitter
  91530. */
  91531. clone(): CylinderDirectedParticleEmitter;
  91532. /**
  91533. * Called by the GPUParticleSystem to setup the update shader
  91534. * @param effect defines the update shader
  91535. */
  91536. applyToShader(effect: Effect): void;
  91537. /**
  91538. * Returns a string to use to update the GPU particles update shader
  91539. * @returns a string containng the defines string
  91540. */
  91541. getEffectDefines(): string;
  91542. /**
  91543. * Returns the string "CylinderDirectedParticleEmitter"
  91544. * @returns a string containing the class name
  91545. */
  91546. getClassName(): string;
  91547. /**
  91548. * Serializes the particle system to a JSON object.
  91549. * @returns the JSON object
  91550. */
  91551. serialize(): any;
  91552. /**
  91553. * Parse properties from a JSON object
  91554. * @param serializationObject defines the JSON object
  91555. */
  91556. parse(serializationObject: any): void;
  91557. }
  91558. }
  91559. declare module BABYLON {
  91560. /**
  91561. * Particle emitter emitting particles from the inside of a hemisphere.
  91562. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91563. */
  91564. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91565. /**
  91566. * The radius of the emission hemisphere.
  91567. */
  91568. radius: number;
  91569. /**
  91570. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91571. */
  91572. radiusRange: number;
  91573. /**
  91574. * How much to randomize the particle direction [0-1].
  91575. */
  91576. directionRandomizer: number;
  91577. /**
  91578. * Creates a new instance HemisphericParticleEmitter
  91579. * @param radius the radius of the emission hemisphere (1 by default)
  91580. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91581. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91582. */
  91583. constructor(
  91584. /**
  91585. * The radius of the emission hemisphere.
  91586. */
  91587. radius?: number,
  91588. /**
  91589. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91590. */
  91591. radiusRange?: number,
  91592. /**
  91593. * How much to randomize the particle direction [0-1].
  91594. */
  91595. directionRandomizer?: number);
  91596. /**
  91597. * Called by the particle System when the direction is computed for the created particle.
  91598. * @param worldMatrix is the world matrix of the particle system
  91599. * @param directionToUpdate is the direction vector to update with the result
  91600. * @param particle is the particle we are computed the direction for
  91601. * @param isLocal defines if the direction should be set in local space
  91602. */
  91603. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91604. /**
  91605. * Called by the particle System when the position is computed for the created particle.
  91606. * @param worldMatrix is the world matrix of the particle system
  91607. * @param positionToUpdate is the position vector to update with the result
  91608. * @param particle is the particle we are computed the position for
  91609. * @param isLocal defines if the position should be set in local space
  91610. */
  91611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91612. /**
  91613. * Clones the current emitter and returns a copy of it
  91614. * @returns the new emitter
  91615. */
  91616. clone(): HemisphericParticleEmitter;
  91617. /**
  91618. * Called by the GPUParticleSystem to setup the update shader
  91619. * @param effect defines the update shader
  91620. */
  91621. applyToShader(effect: Effect): void;
  91622. /**
  91623. * Returns a string to use to update the GPU particles update shader
  91624. * @returns a string containng the defines string
  91625. */
  91626. getEffectDefines(): string;
  91627. /**
  91628. * Returns the string "HemisphericParticleEmitter"
  91629. * @returns a string containing the class name
  91630. */
  91631. getClassName(): string;
  91632. /**
  91633. * Serializes the particle system to a JSON object.
  91634. * @returns the JSON object
  91635. */
  91636. serialize(): any;
  91637. /**
  91638. * Parse properties from a JSON object
  91639. * @param serializationObject defines the JSON object
  91640. */
  91641. parse(serializationObject: any): void;
  91642. }
  91643. }
  91644. declare module BABYLON {
  91645. /**
  91646. * Particle emitter emitting particles from a point.
  91647. * It emits the particles randomly between 2 given directions.
  91648. */
  91649. export class PointParticleEmitter implements IParticleEmitterType {
  91650. /**
  91651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91652. */
  91653. direction1: Vector3;
  91654. /**
  91655. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91656. */
  91657. direction2: Vector3;
  91658. /**
  91659. * Creates a new instance PointParticleEmitter
  91660. */
  91661. constructor();
  91662. /**
  91663. * Called by the particle System when the direction is computed for the created particle.
  91664. * @param worldMatrix is the world matrix of the particle system
  91665. * @param directionToUpdate is the direction vector to update with the result
  91666. * @param particle is the particle we are computed the direction for
  91667. * @param isLocal defines if the direction should be set in local space
  91668. */
  91669. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91670. /**
  91671. * Called by the particle System when the position is computed for the created particle.
  91672. * @param worldMatrix is the world matrix of the particle system
  91673. * @param positionToUpdate is the position vector to update with the result
  91674. * @param particle is the particle we are computed the position for
  91675. * @param isLocal defines if the position should be set in local space
  91676. */
  91677. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91678. /**
  91679. * Clones the current emitter and returns a copy of it
  91680. * @returns the new emitter
  91681. */
  91682. clone(): PointParticleEmitter;
  91683. /**
  91684. * Called by the GPUParticleSystem to setup the update shader
  91685. * @param effect defines the update shader
  91686. */
  91687. applyToShader(effect: Effect): void;
  91688. /**
  91689. * Returns a string to use to update the GPU particles update shader
  91690. * @returns a string containng the defines string
  91691. */
  91692. getEffectDefines(): string;
  91693. /**
  91694. * Returns the string "PointParticleEmitter"
  91695. * @returns a string containing the class name
  91696. */
  91697. getClassName(): string;
  91698. /**
  91699. * Serializes the particle system to a JSON object.
  91700. * @returns the JSON object
  91701. */
  91702. serialize(): any;
  91703. /**
  91704. * Parse properties from a JSON object
  91705. * @param serializationObject defines the JSON object
  91706. */
  91707. parse(serializationObject: any): void;
  91708. }
  91709. }
  91710. declare module BABYLON {
  91711. /**
  91712. * Particle emitter emitting particles from the inside of a sphere.
  91713. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91714. */
  91715. export class SphereParticleEmitter implements IParticleEmitterType {
  91716. /**
  91717. * The radius of the emission sphere.
  91718. */
  91719. radius: number;
  91720. /**
  91721. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91722. */
  91723. radiusRange: number;
  91724. /**
  91725. * How much to randomize the particle direction [0-1].
  91726. */
  91727. directionRandomizer: number;
  91728. /**
  91729. * Creates a new instance SphereParticleEmitter
  91730. * @param radius the radius of the emission sphere (1 by default)
  91731. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91732. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91733. */
  91734. constructor(
  91735. /**
  91736. * The radius of the emission sphere.
  91737. */
  91738. radius?: number,
  91739. /**
  91740. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91741. */
  91742. radiusRange?: number,
  91743. /**
  91744. * How much to randomize the particle direction [0-1].
  91745. */
  91746. directionRandomizer?: number);
  91747. /**
  91748. * Called by the particle System when the direction is computed for the created particle.
  91749. * @param worldMatrix is the world matrix of the particle system
  91750. * @param directionToUpdate is the direction vector to update with the result
  91751. * @param particle is the particle we are computed the direction for
  91752. * @param isLocal defines if the direction should be set in local space
  91753. */
  91754. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91755. /**
  91756. * Called by the particle System when the position is computed for the created particle.
  91757. * @param worldMatrix is the world matrix of the particle system
  91758. * @param positionToUpdate is the position vector to update with the result
  91759. * @param particle is the particle we are computed the position for
  91760. * @param isLocal defines if the position should be set in local space
  91761. */
  91762. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91763. /**
  91764. * Clones the current emitter and returns a copy of it
  91765. * @returns the new emitter
  91766. */
  91767. clone(): SphereParticleEmitter;
  91768. /**
  91769. * Called by the GPUParticleSystem to setup the update shader
  91770. * @param effect defines the update shader
  91771. */
  91772. applyToShader(effect: Effect): void;
  91773. /**
  91774. * Returns a string to use to update the GPU particles update shader
  91775. * @returns a string containng the defines string
  91776. */
  91777. getEffectDefines(): string;
  91778. /**
  91779. * Returns the string "SphereParticleEmitter"
  91780. * @returns a string containing the class name
  91781. */
  91782. getClassName(): string;
  91783. /**
  91784. * Serializes the particle system to a JSON object.
  91785. * @returns the JSON object
  91786. */
  91787. serialize(): any;
  91788. /**
  91789. * Parse properties from a JSON object
  91790. * @param serializationObject defines the JSON object
  91791. */
  91792. parse(serializationObject: any): void;
  91793. }
  91794. /**
  91795. * Particle emitter emitting particles from the inside of a sphere.
  91796. * It emits the particles randomly between two vectors.
  91797. */
  91798. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91799. /**
  91800. * The min limit of the emission direction.
  91801. */
  91802. direction1: Vector3;
  91803. /**
  91804. * The max limit of the emission direction.
  91805. */
  91806. direction2: Vector3;
  91807. /**
  91808. * Creates a new instance SphereDirectedParticleEmitter
  91809. * @param radius the radius of the emission sphere (1 by default)
  91810. * @param direction1 the min limit of the emission direction (up vector by default)
  91811. * @param direction2 the max limit of the emission direction (up vector by default)
  91812. */
  91813. constructor(radius?: number,
  91814. /**
  91815. * The min limit of the emission direction.
  91816. */
  91817. direction1?: Vector3,
  91818. /**
  91819. * The max limit of the emission direction.
  91820. */
  91821. direction2?: Vector3);
  91822. /**
  91823. * Called by the particle System when the direction is computed for the created particle.
  91824. * @param worldMatrix is the world matrix of the particle system
  91825. * @param directionToUpdate is the direction vector to update with the result
  91826. * @param particle is the particle we are computed the direction for
  91827. */
  91828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91829. /**
  91830. * Clones the current emitter and returns a copy of it
  91831. * @returns the new emitter
  91832. */
  91833. clone(): SphereDirectedParticleEmitter;
  91834. /**
  91835. * Called by the GPUParticleSystem to setup the update shader
  91836. * @param effect defines the update shader
  91837. */
  91838. applyToShader(effect: Effect): void;
  91839. /**
  91840. * Returns a string to use to update the GPU particles update shader
  91841. * @returns a string containng the defines string
  91842. */
  91843. getEffectDefines(): string;
  91844. /**
  91845. * Returns the string "SphereDirectedParticleEmitter"
  91846. * @returns a string containing the class name
  91847. */
  91848. getClassName(): string;
  91849. /**
  91850. * Serializes the particle system to a JSON object.
  91851. * @returns the JSON object
  91852. */
  91853. serialize(): any;
  91854. /**
  91855. * Parse properties from a JSON object
  91856. * @param serializationObject defines the JSON object
  91857. */
  91858. parse(serializationObject: any): void;
  91859. }
  91860. }
  91861. declare module BABYLON {
  91862. /**
  91863. * Particle emitter emitting particles from a custom list of positions.
  91864. */
  91865. export class CustomParticleEmitter implements IParticleEmitterType {
  91866. /**
  91867. * Gets or sets the position generator that will create the inital position of each particle.
  91868. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91869. */
  91870. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91871. /**
  91872. * Gets or sets the destination generator that will create the final destination of each particle.
  91873. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91874. */
  91875. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91876. /**
  91877. * Creates a new instance CustomParticleEmitter
  91878. */
  91879. constructor();
  91880. /**
  91881. * Called by the particle System when the direction is computed for the created particle.
  91882. * @param worldMatrix is the world matrix of the particle system
  91883. * @param directionToUpdate is the direction vector to update with the result
  91884. * @param particle is the particle we are computed the direction for
  91885. * @param isLocal defines if the direction should be set in local space
  91886. */
  91887. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91888. /**
  91889. * Called by the particle System when the position is computed for the created particle.
  91890. * @param worldMatrix is the world matrix of the particle system
  91891. * @param positionToUpdate is the position vector to update with the result
  91892. * @param particle is the particle we are computed the position for
  91893. * @param isLocal defines if the position should be set in local space
  91894. */
  91895. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91896. /**
  91897. * Clones the current emitter and returns a copy of it
  91898. * @returns the new emitter
  91899. */
  91900. clone(): CustomParticleEmitter;
  91901. /**
  91902. * Called by the GPUParticleSystem to setup the update shader
  91903. * @param effect defines the update shader
  91904. */
  91905. applyToShader(effect: Effect): void;
  91906. /**
  91907. * Returns a string to use to update the GPU particles update shader
  91908. * @returns a string containng the defines string
  91909. */
  91910. getEffectDefines(): string;
  91911. /**
  91912. * Returns the string "PointParticleEmitter"
  91913. * @returns a string containing the class name
  91914. */
  91915. getClassName(): string;
  91916. /**
  91917. * Serializes the particle system to a JSON object.
  91918. * @returns the JSON object
  91919. */
  91920. serialize(): any;
  91921. /**
  91922. * Parse properties from a JSON object
  91923. * @param serializationObject defines the JSON object
  91924. */
  91925. parse(serializationObject: any): void;
  91926. }
  91927. }
  91928. declare module BABYLON {
  91929. /**
  91930. * Particle emitter emitting particles from the inside of a box.
  91931. * It emits the particles randomly between 2 given directions.
  91932. */
  91933. export class MeshParticleEmitter implements IParticleEmitterType {
  91934. private _indices;
  91935. private _positions;
  91936. private _normals;
  91937. private _storedNormal;
  91938. private _mesh;
  91939. /**
  91940. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91941. */
  91942. direction1: Vector3;
  91943. /**
  91944. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91945. */
  91946. direction2: Vector3;
  91947. /**
  91948. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  91949. */
  91950. useMeshNormalsForDirection: boolean;
  91951. /** Defines the mesh to use as source */
  91952. get mesh(): Nullable<AbstractMesh>;
  91953. set mesh(value: Nullable<AbstractMesh>);
  91954. /**
  91955. * Creates a new instance MeshParticleEmitter
  91956. * @param mesh defines the mesh to use as source
  91957. */
  91958. constructor(mesh?: Nullable<AbstractMesh>);
  91959. /**
  91960. * Called by the particle System when the direction is computed for the created particle.
  91961. * @param worldMatrix is the world matrix of the particle system
  91962. * @param directionToUpdate is the direction vector to update with the result
  91963. * @param particle is the particle we are computed the direction for
  91964. * @param isLocal defines if the direction should be set in local space
  91965. */
  91966. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91967. /**
  91968. * Called by the particle System when the position is computed for the created particle.
  91969. * @param worldMatrix is the world matrix of the particle system
  91970. * @param positionToUpdate is the position vector to update with the result
  91971. * @param particle is the particle we are computed the position for
  91972. * @param isLocal defines if the position should be set in local space
  91973. */
  91974. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91975. /**
  91976. * Clones the current emitter and returns a copy of it
  91977. * @returns the new emitter
  91978. */
  91979. clone(): MeshParticleEmitter;
  91980. /**
  91981. * Called by the GPUParticleSystem to setup the update shader
  91982. * @param effect defines the update shader
  91983. */
  91984. applyToShader(effect: Effect): void;
  91985. /**
  91986. * Returns a string to use to update the GPU particles update shader
  91987. * @returns a string containng the defines string
  91988. */
  91989. getEffectDefines(): string;
  91990. /**
  91991. * Returns the string "BoxParticleEmitter"
  91992. * @returns a string containing the class name
  91993. */
  91994. getClassName(): string;
  91995. /**
  91996. * Serializes the particle system to a JSON object.
  91997. * @returns the JSON object
  91998. */
  91999. serialize(): any;
  92000. /**
  92001. * Parse properties from a JSON object
  92002. * @param serializationObject defines the JSON object
  92003. * @param scene defines the hosting scene
  92004. */
  92005. parse(serializationObject: any, scene: Scene): void;
  92006. }
  92007. }
  92008. declare module BABYLON {
  92009. /**
  92010. * Interface representing a particle system in Babylon.js.
  92011. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92012. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92013. */
  92014. export interface IParticleSystem {
  92015. /**
  92016. * List of animations used by the particle system.
  92017. */
  92018. animations: Animation[];
  92019. /**
  92020. * The id of the Particle system.
  92021. */
  92022. id: string;
  92023. /**
  92024. * The name of the Particle system.
  92025. */
  92026. name: string;
  92027. /**
  92028. * The emitter represents the Mesh or position we are attaching the particle system to.
  92029. */
  92030. emitter: Nullable<AbstractMesh | Vector3>;
  92031. /**
  92032. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92033. */
  92034. isBillboardBased: boolean;
  92035. /**
  92036. * The rendering group used by the Particle system to chose when to render.
  92037. */
  92038. renderingGroupId: number;
  92039. /**
  92040. * The layer mask we are rendering the particles through.
  92041. */
  92042. layerMask: number;
  92043. /**
  92044. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92045. */
  92046. updateSpeed: number;
  92047. /**
  92048. * The amount of time the particle system is running (depends of the overall update speed).
  92049. */
  92050. targetStopDuration: number;
  92051. /**
  92052. * The texture used to render each particle. (this can be a spritesheet)
  92053. */
  92054. particleTexture: Nullable<Texture>;
  92055. /**
  92056. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92057. */
  92058. blendMode: number;
  92059. /**
  92060. * Minimum life time of emitting particles.
  92061. */
  92062. minLifeTime: number;
  92063. /**
  92064. * Maximum life time of emitting particles.
  92065. */
  92066. maxLifeTime: number;
  92067. /**
  92068. * Minimum Size of emitting particles.
  92069. */
  92070. minSize: number;
  92071. /**
  92072. * Maximum Size of emitting particles.
  92073. */
  92074. maxSize: number;
  92075. /**
  92076. * Minimum scale of emitting particles on X axis.
  92077. */
  92078. minScaleX: number;
  92079. /**
  92080. * Maximum scale of emitting particles on X axis.
  92081. */
  92082. maxScaleX: number;
  92083. /**
  92084. * Minimum scale of emitting particles on Y axis.
  92085. */
  92086. minScaleY: number;
  92087. /**
  92088. * Maximum scale of emitting particles on Y axis.
  92089. */
  92090. maxScaleY: number;
  92091. /**
  92092. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92093. */
  92094. color1: Color4;
  92095. /**
  92096. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92097. */
  92098. color2: Color4;
  92099. /**
  92100. * Color the particle will have at the end of its lifetime.
  92101. */
  92102. colorDead: Color4;
  92103. /**
  92104. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  92105. */
  92106. emitRate: number;
  92107. /**
  92108. * You can use gravity if you want to give an orientation to your particles.
  92109. */
  92110. gravity: Vector3;
  92111. /**
  92112. * Minimum power of emitting particles.
  92113. */
  92114. minEmitPower: number;
  92115. /**
  92116. * Maximum power of emitting particles.
  92117. */
  92118. maxEmitPower: number;
  92119. /**
  92120. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92121. */
  92122. minAngularSpeed: number;
  92123. /**
  92124. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92125. */
  92126. maxAngularSpeed: number;
  92127. /**
  92128. * Gets or sets the minimal initial rotation in radians.
  92129. */
  92130. minInitialRotation: number;
  92131. /**
  92132. * Gets or sets the maximal initial rotation in radians.
  92133. */
  92134. maxInitialRotation: number;
  92135. /**
  92136. * The particle emitter type defines the emitter used by the particle system.
  92137. * It can be for example box, sphere, or cone...
  92138. */
  92139. particleEmitterType: Nullable<IParticleEmitterType>;
  92140. /**
  92141. * Defines the delay in milliseconds before starting the system (0 by default)
  92142. */
  92143. startDelay: number;
  92144. /**
  92145. * 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
  92146. */
  92147. preWarmCycles: number;
  92148. /**
  92149. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  92150. */
  92151. preWarmStepOffset: number;
  92152. /**
  92153. * 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)
  92154. */
  92155. spriteCellChangeSpeed: number;
  92156. /**
  92157. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92158. */
  92159. startSpriteCellID: number;
  92160. /**
  92161. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92162. */
  92163. endSpriteCellID: number;
  92164. /**
  92165. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92166. */
  92167. spriteCellWidth: number;
  92168. /**
  92169. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92170. */
  92171. spriteCellHeight: number;
  92172. /**
  92173. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92174. */
  92175. spriteRandomStartCell: boolean;
  92176. /**
  92177. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  92178. */
  92179. isAnimationSheetEnabled: boolean;
  92180. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92181. translationPivot: Vector2;
  92182. /**
  92183. * Gets or sets a texture used to add random noise to particle positions
  92184. */
  92185. noiseTexture: Nullable<BaseTexture>;
  92186. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92187. noiseStrength: Vector3;
  92188. /**
  92189. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92190. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92191. */
  92192. billboardMode: number;
  92193. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92194. limitVelocityDamping: number;
  92195. /**
  92196. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92197. */
  92198. beginAnimationOnStart: boolean;
  92199. /**
  92200. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92201. */
  92202. beginAnimationFrom: number;
  92203. /**
  92204. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92205. */
  92206. beginAnimationTo: number;
  92207. /**
  92208. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92209. */
  92210. beginAnimationLoop: boolean;
  92211. /**
  92212. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92213. */
  92214. disposeOnStop: boolean;
  92215. /**
  92216. * Specifies if the particles are updated in emitter local space or world space
  92217. */
  92218. isLocal: boolean;
  92219. /** Snippet ID if the particle system was created from the snippet server */
  92220. snippetId: string;
  92221. /**
  92222. * Gets the maximum number of particles active at the same time.
  92223. * @returns The max number of active particles.
  92224. */
  92225. getCapacity(): number;
  92226. /**
  92227. * Gets the number of particles active at the same time.
  92228. * @returns The number of active particles.
  92229. */
  92230. getActiveCount(): number;
  92231. /**
  92232. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92233. * @returns True if it has been started, otherwise false.
  92234. */
  92235. isStarted(): boolean;
  92236. /**
  92237. * Animates the particle system for this frame.
  92238. */
  92239. animate(): void;
  92240. /**
  92241. * Renders the particle system in its current state.
  92242. * @returns the current number of particles
  92243. */
  92244. render(): number;
  92245. /**
  92246. * Dispose the particle system and frees its associated resources.
  92247. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92248. */
  92249. dispose(disposeTexture?: boolean): void;
  92250. /**
  92251. * An event triggered when the system is disposed
  92252. */
  92253. onDisposeObservable: Observable<IParticleSystem>;
  92254. /**
  92255. * Clones the particle system.
  92256. * @param name The name of the cloned object
  92257. * @param newEmitter The new emitter to use
  92258. * @returns the cloned particle system
  92259. */
  92260. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  92261. /**
  92262. * Serializes the particle system to a JSON object
  92263. * @param serializeTexture defines if the texture must be serialized as well
  92264. * @returns the JSON object
  92265. */
  92266. serialize(serializeTexture: boolean): any;
  92267. /**
  92268. * Rebuild the particle system
  92269. */
  92270. rebuild(): void;
  92271. /** Force the system to rebuild all gradients that need to be resync */
  92272. forceRefreshGradients(): void;
  92273. /**
  92274. * Starts the particle system and begins to emit
  92275. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  92276. */
  92277. start(delay?: number): void;
  92278. /**
  92279. * Stops the particle system.
  92280. */
  92281. stop(): void;
  92282. /**
  92283. * Remove all active particles
  92284. */
  92285. reset(): void;
  92286. /**
  92287. * Gets a boolean indicating that the system is stopping
  92288. * @returns true if the system is currently stopping
  92289. */
  92290. isStopping(): boolean;
  92291. /**
  92292. * Is this system ready to be used/rendered
  92293. * @return true if the system is ready
  92294. */
  92295. isReady(): boolean;
  92296. /**
  92297. * Returns the string "ParticleSystem"
  92298. * @returns a string containing the class name
  92299. */
  92300. getClassName(): string;
  92301. /**
  92302. * Gets the custom effect used to render the particles
  92303. * @param blendMode Blend mode for which the effect should be retrieved
  92304. * @returns The effect
  92305. */
  92306. getCustomEffect(blendMode: number): Nullable<Effect>;
  92307. /**
  92308. * Sets the custom effect used to render the particles
  92309. * @param effect The effect to set
  92310. * @param blendMode Blend mode for which the effect should be set
  92311. */
  92312. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  92313. /**
  92314. * Fill the defines array according to the current settings of the particle system
  92315. * @param defines Array to be updated
  92316. * @param blendMode blend mode to take into account when updating the array
  92317. */
  92318. fillDefines(defines: Array<string>, blendMode: number): void;
  92319. /**
  92320. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92321. * @param uniforms Uniforms array to fill
  92322. * @param attributes Attributes array to fill
  92323. * @param samplers Samplers array to fill
  92324. */
  92325. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92326. /**
  92327. * Observable that will be called just before the particles are drawn
  92328. */
  92329. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  92330. /**
  92331. * Gets the name of the particle vertex shader
  92332. */
  92333. vertexShaderName: string;
  92334. /**
  92335. * Adds a new color gradient
  92336. * @param gradient defines the gradient to use (between 0 and 1)
  92337. * @param color1 defines the color to affect to the specified gradient
  92338. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92339. * @returns the current particle system
  92340. */
  92341. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92342. /**
  92343. * Remove a specific color gradient
  92344. * @param gradient defines the gradient to remove
  92345. * @returns the current particle system
  92346. */
  92347. removeColorGradient(gradient: number): IParticleSystem;
  92348. /**
  92349. * Adds a new size gradient
  92350. * @param gradient defines the gradient to use (between 0 and 1)
  92351. * @param factor defines the size factor to affect to the specified gradient
  92352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92353. * @returns the current particle system
  92354. */
  92355. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92356. /**
  92357. * Remove a specific size gradient
  92358. * @param gradient defines the gradient to remove
  92359. * @returns the current particle system
  92360. */
  92361. removeSizeGradient(gradient: number): IParticleSystem;
  92362. /**
  92363. * Gets the current list of color gradients.
  92364. * You must use addColorGradient and removeColorGradient to udpate this list
  92365. * @returns the list of color gradients
  92366. */
  92367. getColorGradients(): Nullable<Array<ColorGradient>>;
  92368. /**
  92369. * Gets the current list of size gradients.
  92370. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92371. * @returns the list of size gradients
  92372. */
  92373. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92374. /**
  92375. * Gets the current list of angular speed gradients.
  92376. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92377. * @returns the list of angular speed gradients
  92378. */
  92379. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92380. /**
  92381. * Adds a new angular speed gradient
  92382. * @param gradient defines the gradient to use (between 0 and 1)
  92383. * @param factor defines the angular speed to affect to the specified gradient
  92384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92385. * @returns the current particle system
  92386. */
  92387. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92388. /**
  92389. * Remove a specific angular speed gradient
  92390. * @param gradient defines the gradient to remove
  92391. * @returns the current particle system
  92392. */
  92393. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92394. /**
  92395. * Gets the current list of velocity gradients.
  92396. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92397. * @returns the list of velocity gradients
  92398. */
  92399. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92400. /**
  92401. * Adds a new velocity gradient
  92402. * @param gradient defines the gradient to use (between 0 and 1)
  92403. * @param factor defines the velocity to affect to the specified gradient
  92404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92405. * @returns the current particle system
  92406. */
  92407. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92408. /**
  92409. * Remove a specific velocity gradient
  92410. * @param gradient defines the gradient to remove
  92411. * @returns the current particle system
  92412. */
  92413. removeVelocityGradient(gradient: number): IParticleSystem;
  92414. /**
  92415. * Gets the current list of limit velocity gradients.
  92416. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92417. * @returns the list of limit velocity gradients
  92418. */
  92419. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92420. /**
  92421. * Adds a new limit velocity gradient
  92422. * @param gradient defines the gradient to use (between 0 and 1)
  92423. * @param factor defines the limit velocity to affect to the specified gradient
  92424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92425. * @returns the current particle system
  92426. */
  92427. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92428. /**
  92429. * Remove a specific limit velocity gradient
  92430. * @param gradient defines the gradient to remove
  92431. * @returns the current particle system
  92432. */
  92433. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92434. /**
  92435. * Adds a new drag gradient
  92436. * @param gradient defines the gradient to use (between 0 and 1)
  92437. * @param factor defines the drag to affect to the specified gradient
  92438. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92439. * @returns the current particle system
  92440. */
  92441. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92442. /**
  92443. * Remove a specific drag gradient
  92444. * @param gradient defines the gradient to remove
  92445. * @returns the current particle system
  92446. */
  92447. removeDragGradient(gradient: number): IParticleSystem;
  92448. /**
  92449. * Gets the current list of drag gradients.
  92450. * You must use addDragGradient and removeDragGradient to udpate this list
  92451. * @returns the list of drag gradients
  92452. */
  92453. getDragGradients(): Nullable<Array<FactorGradient>>;
  92454. /**
  92455. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92456. * @param gradient defines the gradient to use (between 0 and 1)
  92457. * @param factor defines the emit rate to affect to the specified gradient
  92458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92459. * @returns the current particle system
  92460. */
  92461. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92462. /**
  92463. * Remove a specific emit rate gradient
  92464. * @param gradient defines the gradient to remove
  92465. * @returns the current particle system
  92466. */
  92467. removeEmitRateGradient(gradient: number): IParticleSystem;
  92468. /**
  92469. * Gets the current list of emit rate gradients.
  92470. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92471. * @returns the list of emit rate gradients
  92472. */
  92473. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92474. /**
  92475. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92476. * @param gradient defines the gradient to use (between 0 and 1)
  92477. * @param factor defines the start size to affect to the specified gradient
  92478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92479. * @returns the current particle system
  92480. */
  92481. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92482. /**
  92483. * Remove a specific start size gradient
  92484. * @param gradient defines the gradient to remove
  92485. * @returns the current particle system
  92486. */
  92487. removeStartSizeGradient(gradient: number): IParticleSystem;
  92488. /**
  92489. * Gets the current list of start size gradients.
  92490. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92491. * @returns the list of start size gradients
  92492. */
  92493. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92494. /**
  92495. * Adds a new life time gradient
  92496. * @param gradient defines the gradient to use (between 0 and 1)
  92497. * @param factor defines the life time factor to affect to the specified gradient
  92498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92499. * @returns the current particle system
  92500. */
  92501. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92502. /**
  92503. * Remove a specific life time gradient
  92504. * @param gradient defines the gradient to remove
  92505. * @returns the current particle system
  92506. */
  92507. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92508. /**
  92509. * Gets the current list of life time gradients.
  92510. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92511. * @returns the list of life time gradients
  92512. */
  92513. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92514. /**
  92515. * Gets the current list of color gradients.
  92516. * You must use addColorGradient and removeColorGradient to udpate this list
  92517. * @returns the list of color gradients
  92518. */
  92519. getColorGradients(): Nullable<Array<ColorGradient>>;
  92520. /**
  92521. * Adds a new ramp gradient used to remap particle colors
  92522. * @param gradient defines the gradient to use (between 0 and 1)
  92523. * @param color defines the color to affect to the specified gradient
  92524. * @returns the current particle system
  92525. */
  92526. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  92527. /**
  92528. * Gets the current list of ramp gradients.
  92529. * You must use addRampGradient and removeRampGradient to udpate this list
  92530. * @returns the list of ramp gradients
  92531. */
  92532. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92533. /** Gets or sets a boolean indicating that ramp gradients must be used
  92534. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92535. */
  92536. useRampGradients: boolean;
  92537. /**
  92538. * Adds a new color remap gradient
  92539. * @param gradient defines the gradient to use (between 0 and 1)
  92540. * @param min defines the color remap minimal range
  92541. * @param max defines the color remap maximal range
  92542. * @returns the current particle system
  92543. */
  92544. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92545. /**
  92546. * Gets the current list of color remap gradients.
  92547. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92548. * @returns the list of color remap gradients
  92549. */
  92550. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92551. /**
  92552. * Adds a new alpha remap gradient
  92553. * @param gradient defines the gradient to use (between 0 and 1)
  92554. * @param min defines the alpha remap minimal range
  92555. * @param max defines the alpha remap maximal range
  92556. * @returns the current particle system
  92557. */
  92558. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92559. /**
  92560. * Gets the current list of alpha remap gradients.
  92561. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92562. * @returns the list of alpha remap gradients
  92563. */
  92564. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92565. /**
  92566. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92567. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92568. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92569. * @returns the emitter
  92570. */
  92571. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92572. /**
  92573. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92574. * @param radius The radius of the hemisphere to emit from
  92575. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92576. * @returns the emitter
  92577. */
  92578. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92579. /**
  92580. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92581. * @param radius The radius of the sphere to emit from
  92582. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92583. * @returns the emitter
  92584. */
  92585. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92586. /**
  92587. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92588. * @param radius The radius of the sphere to emit from
  92589. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92590. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92591. * @returns the emitter
  92592. */
  92593. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92594. /**
  92595. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92596. * @param radius The radius of the emission cylinder
  92597. * @param height The height of the emission cylinder
  92598. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92599. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92600. * @returns the emitter
  92601. */
  92602. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92603. /**
  92604. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92605. * @param radius The radius of the cylinder to emit from
  92606. * @param height The height of the emission cylinder
  92607. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92610. * @returns the emitter
  92611. */
  92612. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92613. /**
  92614. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92615. * @param radius The radius of the cone to emit from
  92616. * @param angle The base angle of the cone
  92617. * @returns the emitter
  92618. */
  92619. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92620. /**
  92621. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92622. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92623. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92624. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92625. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92626. * @returns the emitter
  92627. */
  92628. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92629. /**
  92630. * Get hosting scene
  92631. * @returns the scene
  92632. */
  92633. getScene(): Scene;
  92634. }
  92635. }
  92636. declare module BABYLON {
  92637. /**
  92638. * 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.
  92639. * @see https://doc.babylonjs.com/how_to/transformnode
  92640. */
  92641. export class TransformNode extends Node {
  92642. /**
  92643. * Object will not rotate to face the camera
  92644. */
  92645. static BILLBOARDMODE_NONE: number;
  92646. /**
  92647. * Object will rotate to face the camera but only on the x axis
  92648. */
  92649. static BILLBOARDMODE_X: number;
  92650. /**
  92651. * Object will rotate to face the camera but only on the y axis
  92652. */
  92653. static BILLBOARDMODE_Y: number;
  92654. /**
  92655. * Object will rotate to face the camera but only on the z axis
  92656. */
  92657. static BILLBOARDMODE_Z: number;
  92658. /**
  92659. * Object will rotate to face the camera
  92660. */
  92661. static BILLBOARDMODE_ALL: number;
  92662. /**
  92663. * Object will rotate to face the camera's position instead of orientation
  92664. */
  92665. static BILLBOARDMODE_USE_POSITION: number;
  92666. private static _TmpRotation;
  92667. private static _TmpScaling;
  92668. private static _TmpTranslation;
  92669. private _forward;
  92670. private _forwardInverted;
  92671. private _up;
  92672. private _right;
  92673. private _rightInverted;
  92674. private _position;
  92675. private _rotation;
  92676. private _rotationQuaternion;
  92677. protected _scaling: Vector3;
  92678. protected _isDirty: boolean;
  92679. private _transformToBoneReferal;
  92680. private _isAbsoluteSynced;
  92681. private _billboardMode;
  92682. /**
  92683. * Gets or sets the billboard mode. Default is 0.
  92684. *
  92685. * | Value | Type | Description |
  92686. * | --- | --- | --- |
  92687. * | 0 | BILLBOARDMODE_NONE | |
  92688. * | 1 | BILLBOARDMODE_X | |
  92689. * | 2 | BILLBOARDMODE_Y | |
  92690. * | 4 | BILLBOARDMODE_Z | |
  92691. * | 7 | BILLBOARDMODE_ALL | |
  92692. *
  92693. */
  92694. get billboardMode(): number;
  92695. set billboardMode(value: number);
  92696. private _preserveParentRotationForBillboard;
  92697. /**
  92698. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  92699. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  92700. */
  92701. get preserveParentRotationForBillboard(): boolean;
  92702. set preserveParentRotationForBillboard(value: boolean);
  92703. /**
  92704. * 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
  92705. */
  92706. scalingDeterminant: number;
  92707. private _infiniteDistance;
  92708. /**
  92709. * Gets or sets the distance of the object to max, often used by skybox
  92710. */
  92711. get infiniteDistance(): boolean;
  92712. set infiniteDistance(value: boolean);
  92713. /**
  92714. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92715. * By default the system will update normals to compensate
  92716. */
  92717. ignoreNonUniformScaling: boolean;
  92718. /**
  92719. * 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
  92720. */
  92721. reIntegrateRotationIntoRotationQuaternion: boolean;
  92722. /** @hidden */
  92723. _poseMatrix: Nullable<Matrix>;
  92724. /** @hidden */
  92725. _localMatrix: Matrix;
  92726. private _usePivotMatrix;
  92727. private _absolutePosition;
  92728. private _absoluteScaling;
  92729. private _absoluteRotationQuaternion;
  92730. private _pivotMatrix;
  92731. private _pivotMatrixInverse;
  92732. protected _postMultiplyPivotMatrix: boolean;
  92733. protected _isWorldMatrixFrozen: boolean;
  92734. /** @hidden */
  92735. _indexInSceneTransformNodesArray: number;
  92736. /**
  92737. * An event triggered after the world matrix is updated
  92738. */
  92739. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  92740. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  92741. /**
  92742. * Gets a string identifying the name of the class
  92743. * @returns "TransformNode" string
  92744. */
  92745. getClassName(): string;
  92746. /**
  92747. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92748. */
  92749. get position(): Vector3;
  92750. set position(newPosition: Vector3);
  92751. /**
  92752. * 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)).
  92753. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92754. */
  92755. get rotation(): Vector3;
  92756. set rotation(newRotation: Vector3);
  92757. /**
  92758. * 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)).
  92759. */
  92760. get scaling(): Vector3;
  92761. set scaling(newScaling: Vector3);
  92762. /**
  92763. * 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).
  92764. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92765. */
  92766. get rotationQuaternion(): Nullable<Quaternion>;
  92767. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  92768. /**
  92769. * The forward direction of that transform in world space.
  92770. */
  92771. get forward(): Vector3;
  92772. /**
  92773. * The up direction of that transform in world space.
  92774. */
  92775. get up(): Vector3;
  92776. /**
  92777. * The right direction of that transform in world space.
  92778. */
  92779. get right(): Vector3;
  92780. /**
  92781. * Copies the parameter passed Matrix into the mesh Pose matrix.
  92782. * @param matrix the matrix to copy the pose from
  92783. * @returns this TransformNode.
  92784. */
  92785. updatePoseMatrix(matrix: Matrix): TransformNode;
  92786. /**
  92787. * Returns the mesh Pose matrix.
  92788. * @returns the pose matrix
  92789. */
  92790. getPoseMatrix(): Matrix;
  92791. /** @hidden */
  92792. _isSynchronized(): boolean;
  92793. /** @hidden */
  92794. _initCache(): void;
  92795. /**
  92796. * Flag the transform node as dirty (Forcing it to update everything)
  92797. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  92798. * @returns this transform node
  92799. */
  92800. markAsDirty(property: string): TransformNode;
  92801. /**
  92802. * Returns the current mesh absolute position.
  92803. * Returns a Vector3.
  92804. */
  92805. get absolutePosition(): Vector3;
  92806. /**
  92807. * Returns the current mesh absolute scaling.
  92808. * Returns a Vector3.
  92809. */
  92810. get absoluteScaling(): Vector3;
  92811. /**
  92812. * Returns the current mesh absolute rotation.
  92813. * Returns a Quaternion.
  92814. */
  92815. get absoluteRotationQuaternion(): Quaternion;
  92816. /**
  92817. * Sets a new matrix to apply before all other transformation
  92818. * @param matrix defines the transform matrix
  92819. * @returns the current TransformNode
  92820. */
  92821. setPreTransformMatrix(matrix: Matrix): TransformNode;
  92822. /**
  92823. * Sets a new pivot matrix to the current node
  92824. * @param matrix defines the new pivot matrix to use
  92825. * @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
  92826. * @returns the current TransformNode
  92827. */
  92828. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  92829. /**
  92830. * Returns the mesh pivot matrix.
  92831. * Default : Identity.
  92832. * @returns the matrix
  92833. */
  92834. getPivotMatrix(): Matrix;
  92835. /**
  92836. * Instantiate (when possible) or clone that node with its hierarchy
  92837. * @param newParent defines the new parent to use for the instance (or clone)
  92838. * @param options defines options to configure how copy is done
  92839. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  92840. * @returns an instance (or a clone) of the current node with its hiearchy
  92841. */
  92842. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92843. doNotInstantiate: boolean;
  92844. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92845. /**
  92846. * Prevents the World matrix to be computed any longer
  92847. * @param newWorldMatrix defines an optional matrix to use as world matrix
  92848. * @returns the TransformNode.
  92849. */
  92850. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  92851. /**
  92852. * Allows back the World matrix computation.
  92853. * @returns the TransformNode.
  92854. */
  92855. unfreezeWorldMatrix(): this;
  92856. /**
  92857. * True if the World matrix has been frozen.
  92858. */
  92859. get isWorldMatrixFrozen(): boolean;
  92860. /**
  92861. * Retuns the mesh absolute position in the World.
  92862. * @returns a Vector3.
  92863. */
  92864. getAbsolutePosition(): Vector3;
  92865. /**
  92866. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  92867. * @param absolutePosition the absolute position to set
  92868. * @returns the TransformNode.
  92869. */
  92870. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92871. /**
  92872. * Sets the mesh position in its local space.
  92873. * @param vector3 the position to set in localspace
  92874. * @returns the TransformNode.
  92875. */
  92876. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  92877. /**
  92878. * Returns the mesh position in the local space from the current World matrix values.
  92879. * @returns a new Vector3.
  92880. */
  92881. getPositionExpressedInLocalSpace(): Vector3;
  92882. /**
  92883. * Translates the mesh along the passed Vector3 in its local space.
  92884. * @param vector3 the distance to translate in localspace
  92885. * @returns the TransformNode.
  92886. */
  92887. locallyTranslate(vector3: Vector3): TransformNode;
  92888. private static _lookAtVectorCache;
  92889. /**
  92890. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  92891. * @param targetPoint the position (must be in same space as current mesh) to look at
  92892. * @param yawCor optional yaw (y-axis) correction in radians
  92893. * @param pitchCor optional pitch (x-axis) correction in radians
  92894. * @param rollCor optional roll (z-axis) correction in radians
  92895. * @param space the choosen space of the target
  92896. * @returns the TransformNode.
  92897. */
  92898. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  92899. /**
  92900. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92901. * This Vector3 is expressed in the World space.
  92902. * @param localAxis axis to rotate
  92903. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92904. */
  92905. getDirection(localAxis: Vector3): Vector3;
  92906. /**
  92907. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  92908. * localAxis is expressed in the mesh local space.
  92909. * result is computed in the Wordl space from the mesh World matrix.
  92910. * @param localAxis axis to rotate
  92911. * @param result the resulting transformnode
  92912. * @returns this TransformNode.
  92913. */
  92914. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  92915. /**
  92916. * Sets this transform node rotation to the given local axis.
  92917. * @param localAxis the axis in local space
  92918. * @param yawCor optional yaw (y-axis) correction in radians
  92919. * @param pitchCor optional pitch (x-axis) correction in radians
  92920. * @param rollCor optional roll (z-axis) correction in radians
  92921. * @returns this TransformNode
  92922. */
  92923. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  92924. /**
  92925. * Sets a new pivot point to the current node
  92926. * @param point defines the new pivot point to use
  92927. * @param space defines if the point is in world or local space (local by default)
  92928. * @returns the current TransformNode
  92929. */
  92930. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  92931. /**
  92932. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  92933. * @returns the pivot point
  92934. */
  92935. getPivotPoint(): Vector3;
  92936. /**
  92937. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  92938. * @param result the vector3 to store the result
  92939. * @returns this TransformNode.
  92940. */
  92941. getPivotPointToRef(result: Vector3): TransformNode;
  92942. /**
  92943. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92944. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92945. */
  92946. getAbsolutePivotPoint(): Vector3;
  92947. /**
  92948. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92949. * @param result vector3 to store the result
  92950. * @returns this TransformNode.
  92951. */
  92952. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  92953. /**
  92954. * Defines the passed node as the parent of the current node.
  92955. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92956. * @see https://doc.babylonjs.com/how_to/parenting
  92957. * @param node the node ot set as the parent
  92958. * @returns this TransformNode.
  92959. */
  92960. setParent(node: Nullable<Node>): TransformNode;
  92961. private _nonUniformScaling;
  92962. /**
  92963. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92964. */
  92965. get nonUniformScaling(): boolean;
  92966. /** @hidden */
  92967. _updateNonUniformScalingState(value: boolean): boolean;
  92968. /**
  92969. * Attach the current TransformNode to another TransformNode associated with a bone
  92970. * @param bone Bone affecting the TransformNode
  92971. * @param affectedTransformNode TransformNode associated with the bone
  92972. * @returns this object
  92973. */
  92974. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92975. /**
  92976. * Detach the transform node if its associated with a bone
  92977. * @returns this object
  92978. */
  92979. detachFromBone(): TransformNode;
  92980. private static _rotationAxisCache;
  92981. /**
  92982. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92983. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92984. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92985. * The passed axis is also normalized.
  92986. * @param axis the axis to rotate around
  92987. * @param amount the amount to rotate in radians
  92988. * @param space Space to rotate in (Default: local)
  92989. * @returns the TransformNode.
  92990. */
  92991. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92992. /**
  92993. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92994. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92995. * The passed axis is also normalized. .
  92996. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92997. * @param point the point to rotate around
  92998. * @param axis the axis to rotate around
  92999. * @param amount the amount to rotate in radians
  93000. * @returns the TransformNode
  93001. */
  93002. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  93003. /**
  93004. * Translates the mesh along the axis vector for the passed distance in the given space.
  93005. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93006. * @param axis the axis to translate in
  93007. * @param distance the distance to translate
  93008. * @param space Space to rotate in (Default: local)
  93009. * @returns the TransformNode.
  93010. */
  93011. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93012. /**
  93013. * Adds a rotation step to the mesh current rotation.
  93014. * x, y, z are Euler angles expressed in radians.
  93015. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93016. * This means this rotation is made in the mesh local space only.
  93017. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93018. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93019. * ```javascript
  93020. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93021. * ```
  93022. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93023. * 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.
  93024. * @param x Rotation to add
  93025. * @param y Rotation to add
  93026. * @param z Rotation to add
  93027. * @returns the TransformNode.
  93028. */
  93029. addRotation(x: number, y: number, z: number): TransformNode;
  93030. /**
  93031. * @hidden
  93032. */
  93033. protected _getEffectiveParent(): Nullable<Node>;
  93034. /**
  93035. * Computes the world matrix of the node
  93036. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93037. * @returns the world matrix
  93038. */
  93039. computeWorldMatrix(force?: boolean): Matrix;
  93040. /**
  93041. * Resets this nodeTransform's local matrix to Matrix.Identity().
  93042. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  93043. */
  93044. resetLocalMatrix(independentOfChildren?: boolean): void;
  93045. protected _afterComputeWorldMatrix(): void;
  93046. /**
  93047. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93048. * @param func callback function to add
  93049. *
  93050. * @returns the TransformNode.
  93051. */
  93052. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93053. /**
  93054. * Removes a registered callback function.
  93055. * @param func callback function to remove
  93056. * @returns the TransformNode.
  93057. */
  93058. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93059. /**
  93060. * Gets the position of the current mesh in camera space
  93061. * @param camera defines the camera to use
  93062. * @returns a position
  93063. */
  93064. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  93065. /**
  93066. * Returns the distance from the mesh to the active camera
  93067. * @param camera defines the camera to use
  93068. * @returns the distance
  93069. */
  93070. getDistanceToCamera(camera?: Nullable<Camera>): number;
  93071. /**
  93072. * Clone the current transform node
  93073. * @param name Name of the new clone
  93074. * @param newParent New parent for the clone
  93075. * @param doNotCloneChildren Do not clone children hierarchy
  93076. * @returns the new transform node
  93077. */
  93078. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  93079. /**
  93080. * Serializes the objects information.
  93081. * @param currentSerializationObject defines the object to serialize in
  93082. * @returns the serialized object
  93083. */
  93084. serialize(currentSerializationObject?: any): any;
  93085. /**
  93086. * Returns a new TransformNode object parsed from the source provided.
  93087. * @param parsedTransformNode is the source.
  93088. * @param scene the scne the object belongs to
  93089. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93090. * @returns a new TransformNode object parsed from the source provided.
  93091. */
  93092. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  93093. /**
  93094. * Get all child-transformNodes of this node
  93095. * @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
  93096. * @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
  93097. * @returns an array of TransformNode
  93098. */
  93099. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  93100. /**
  93101. * Releases resources associated with this transform node.
  93102. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93103. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93104. */
  93105. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93106. /**
  93107. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93108. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93109. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93110. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93111. * @returns the current mesh
  93112. */
  93113. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  93114. private _syncAbsoluteScalingAndRotation;
  93115. }
  93116. }
  93117. declare module BABYLON {
  93118. /**
  93119. * Class used to override all child animations of a given target
  93120. */
  93121. export class AnimationPropertiesOverride {
  93122. /**
  93123. * Gets or sets a value indicating if animation blending must be used
  93124. */
  93125. enableBlending: boolean;
  93126. /**
  93127. * Gets or sets the blending speed to use when enableBlending is true
  93128. */
  93129. blendingSpeed: number;
  93130. /**
  93131. * Gets or sets the default loop mode to use
  93132. */
  93133. loopMode: number;
  93134. }
  93135. }
  93136. declare module BABYLON {
  93137. /**
  93138. * Class used to store bone information
  93139. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93140. */
  93141. export class Bone extends Node {
  93142. /**
  93143. * defines the bone name
  93144. */
  93145. name: string;
  93146. private static _tmpVecs;
  93147. private static _tmpQuat;
  93148. private static _tmpMats;
  93149. /**
  93150. * Gets the list of child bones
  93151. */
  93152. children: Bone[];
  93153. /** Gets the animations associated with this bone */
  93154. animations: Animation[];
  93155. /**
  93156. * Gets or sets bone length
  93157. */
  93158. length: number;
  93159. /**
  93160. * @hidden Internal only
  93161. * Set this value to map this bone to a different index in the transform matrices
  93162. * Set this value to -1 to exclude the bone from the transform matrices
  93163. */
  93164. _index: Nullable<number>;
  93165. private _skeleton;
  93166. private _localMatrix;
  93167. private _restPose;
  93168. private _baseMatrix;
  93169. private _absoluteTransform;
  93170. private _invertedAbsoluteTransform;
  93171. private _parent;
  93172. private _scalingDeterminant;
  93173. private _worldTransform;
  93174. private _localScaling;
  93175. private _localRotation;
  93176. private _localPosition;
  93177. private _needToDecompose;
  93178. private _needToCompose;
  93179. /** @hidden */
  93180. _linkedTransformNode: Nullable<TransformNode>;
  93181. /** @hidden */
  93182. _waitingTransformNodeId: Nullable<string>;
  93183. /** @hidden */
  93184. get _matrix(): Matrix;
  93185. /** @hidden */
  93186. set _matrix(value: Matrix);
  93187. /**
  93188. * Create a new bone
  93189. * @param name defines the bone name
  93190. * @param skeleton defines the parent skeleton
  93191. * @param parentBone defines the parent (can be null if the bone is the root)
  93192. * @param localMatrix defines the local matrix
  93193. * @param restPose defines the rest pose matrix
  93194. * @param baseMatrix defines the base matrix
  93195. * @param index defines index of the bone in the hiearchy
  93196. */
  93197. constructor(
  93198. /**
  93199. * defines the bone name
  93200. */
  93201. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  93202. /**
  93203. * Gets the current object class name.
  93204. * @return the class name
  93205. */
  93206. getClassName(): string;
  93207. /**
  93208. * Gets the parent skeleton
  93209. * @returns a skeleton
  93210. */
  93211. getSkeleton(): Skeleton;
  93212. /**
  93213. * Gets parent bone
  93214. * @returns a bone or null if the bone is the root of the bone hierarchy
  93215. */
  93216. getParent(): Nullable<Bone>;
  93217. /**
  93218. * Returns an array containing the root bones
  93219. * @returns an array containing the root bones
  93220. */
  93221. getChildren(): Array<Bone>;
  93222. /**
  93223. * Gets the node index in matrix array generated for rendering
  93224. * @returns the node index
  93225. */
  93226. getIndex(): number;
  93227. /**
  93228. * Sets the parent bone
  93229. * @param parent defines the parent (can be null if the bone is the root)
  93230. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93231. */
  93232. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  93233. /**
  93234. * Gets the local matrix
  93235. * @returns a matrix
  93236. */
  93237. getLocalMatrix(): Matrix;
  93238. /**
  93239. * Gets the base matrix (initial matrix which remains unchanged)
  93240. * @returns a matrix
  93241. */
  93242. getBaseMatrix(): Matrix;
  93243. /**
  93244. * Gets the rest pose matrix
  93245. * @returns a matrix
  93246. */
  93247. getRestPose(): Matrix;
  93248. /**
  93249. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  93250. */
  93251. getWorldMatrix(): Matrix;
  93252. /**
  93253. * Sets the local matrix to rest pose matrix
  93254. */
  93255. returnToRest(): void;
  93256. /**
  93257. * Gets the inverse of the absolute transform matrix.
  93258. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  93259. * @returns a matrix
  93260. */
  93261. getInvertedAbsoluteTransform(): Matrix;
  93262. /**
  93263. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  93264. * @returns a matrix
  93265. */
  93266. getAbsoluteTransform(): Matrix;
  93267. /**
  93268. * Links with the given transform node.
  93269. * The local matrix of this bone is copied from the transform node every frame.
  93270. * @param transformNode defines the transform node to link to
  93271. */
  93272. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  93273. /**
  93274. * Gets the node used to drive the bone's transformation
  93275. * @returns a transform node or null
  93276. */
  93277. getTransformNode(): Nullable<TransformNode>;
  93278. /** Gets or sets current position (in local space) */
  93279. get position(): Vector3;
  93280. set position(newPosition: Vector3);
  93281. /** Gets or sets current rotation (in local space) */
  93282. get rotation(): Vector3;
  93283. set rotation(newRotation: Vector3);
  93284. /** Gets or sets current rotation quaternion (in local space) */
  93285. get rotationQuaternion(): Quaternion;
  93286. set rotationQuaternion(newRotation: Quaternion);
  93287. /** Gets or sets current scaling (in local space) */
  93288. get scaling(): Vector3;
  93289. set scaling(newScaling: Vector3);
  93290. /**
  93291. * Gets the animation properties override
  93292. */
  93293. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93294. private _decompose;
  93295. private _compose;
  93296. /**
  93297. * Update the base and local matrices
  93298. * @param matrix defines the new base or local matrix
  93299. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93300. * @param updateLocalMatrix defines if the local matrix should be updated
  93301. */
  93302. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  93303. /** @hidden */
  93304. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  93305. /**
  93306. * Flag the bone as dirty (Forcing it to update everything)
  93307. */
  93308. markAsDirty(): void;
  93309. /** @hidden */
  93310. _markAsDirtyAndCompose(): void;
  93311. private _markAsDirtyAndDecompose;
  93312. /**
  93313. * Translate the bone in local or world space
  93314. * @param vec The amount to translate the bone
  93315. * @param space The space that the translation is in
  93316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93317. */
  93318. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93319. /**
  93320. * Set the postion of the bone in local or world space
  93321. * @param position The position to set the bone
  93322. * @param space The space that the position is in
  93323. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93324. */
  93325. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93326. /**
  93327. * Set the absolute position of the bone (world space)
  93328. * @param position The position to set the bone
  93329. * @param mesh The mesh that this bone is attached to
  93330. */
  93331. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  93332. /**
  93333. * Scale the bone on the x, y and z axes (in local space)
  93334. * @param x The amount to scale the bone on the x axis
  93335. * @param y The amount to scale the bone on the y axis
  93336. * @param z The amount to scale the bone on the z axis
  93337. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  93338. */
  93339. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  93340. /**
  93341. * Set the bone scaling in local space
  93342. * @param scale defines the scaling vector
  93343. */
  93344. setScale(scale: Vector3): void;
  93345. /**
  93346. * Gets the current scaling in local space
  93347. * @returns the current scaling vector
  93348. */
  93349. getScale(): Vector3;
  93350. /**
  93351. * Gets the current scaling in local space and stores it in a target vector
  93352. * @param result defines the target vector
  93353. */
  93354. getScaleToRef(result: Vector3): void;
  93355. /**
  93356. * Set the yaw, pitch, and roll of the bone in local or world space
  93357. * @param yaw The rotation of the bone on the y axis
  93358. * @param pitch The rotation of the bone on the x axis
  93359. * @param roll The rotation of the bone on the z axis
  93360. * @param space The space that the axes of rotation are in
  93361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93362. */
  93363. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  93364. /**
  93365. * Add a rotation to the bone on an axis in local or world space
  93366. * @param axis The axis to rotate the bone on
  93367. * @param amount The amount to rotate the bone
  93368. * @param space The space that the axis is in
  93369. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93370. */
  93371. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  93372. /**
  93373. * Set the rotation of the bone to a particular axis angle in local or world space
  93374. * @param axis The axis to rotate the bone on
  93375. * @param angle The angle that the bone should be rotated to
  93376. * @param space The space that the axis is in
  93377. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93378. */
  93379. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  93380. /**
  93381. * Set the euler rotation of the bone in local of world space
  93382. * @param rotation The euler rotation that the bone should be set to
  93383. * @param space The space that the rotation is in
  93384. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93385. */
  93386. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93387. /**
  93388. * Set the quaternion rotation of the bone in local of world space
  93389. * @param quat The quaternion rotation that the bone should be set to
  93390. * @param space The space that the rotation is in
  93391. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93392. */
  93393. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  93394. /**
  93395. * Set the rotation matrix of the bone in local of world space
  93396. * @param rotMat The rotation matrix that the bone should be set to
  93397. * @param space The space that the rotation is in
  93398. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93399. */
  93400. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  93401. private _rotateWithMatrix;
  93402. private _getNegativeRotationToRef;
  93403. /**
  93404. * Get the position of the bone in local or world space
  93405. * @param space The space that the returned position is in
  93406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93407. * @returns The position of the bone
  93408. */
  93409. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93410. /**
  93411. * Copy the position of the bone to a vector3 in local or world space
  93412. * @param space The space that the returned position is in
  93413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93414. * @param result The vector3 to copy the position to
  93415. */
  93416. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  93417. /**
  93418. * Get the absolute position of the bone (world space)
  93419. * @param mesh The mesh that this bone is attached to
  93420. * @returns The absolute position of the bone
  93421. */
  93422. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  93423. /**
  93424. * Copy the absolute position of the bone (world space) to the result param
  93425. * @param mesh The mesh that this bone is attached to
  93426. * @param result The vector3 to copy the absolute position to
  93427. */
  93428. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  93429. /**
  93430. * Compute the absolute transforms of this bone and its children
  93431. */
  93432. computeAbsoluteTransforms(): void;
  93433. /**
  93434. * Get the world direction from an axis that is in the local space of the bone
  93435. * @param localAxis The local direction that is used to compute the world direction
  93436. * @param mesh The mesh that this bone is attached to
  93437. * @returns The world direction
  93438. */
  93439. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93440. /**
  93441. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  93442. * @param localAxis The local direction that is used to compute the world direction
  93443. * @param mesh The mesh that this bone is attached to
  93444. * @param result The vector3 that the world direction will be copied to
  93445. */
  93446. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93447. /**
  93448. * Get the euler rotation of the bone in local or world space
  93449. * @param space The space that the rotation should be in
  93450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93451. * @returns The euler rotation
  93452. */
  93453. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93454. /**
  93455. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  93456. * @param space The space that the rotation should be in
  93457. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93458. * @param result The vector3 that the rotation should be copied to
  93459. */
  93460. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93461. /**
  93462. * Get the quaternion rotation of the bone in either local or world space
  93463. * @param space The space that the rotation should be in
  93464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93465. * @returns The quaternion rotation
  93466. */
  93467. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  93468. /**
  93469. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  93470. * @param space The space that the rotation should be in
  93471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93472. * @param result The quaternion that the rotation should be copied to
  93473. */
  93474. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  93475. /**
  93476. * Get the rotation matrix of the bone in local or world space
  93477. * @param space The space that the rotation should be in
  93478. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93479. * @returns The rotation matrix
  93480. */
  93481. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  93482. /**
  93483. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  93484. * @param space The space that the rotation should be in
  93485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93486. * @param result The quaternion that the rotation should be copied to
  93487. */
  93488. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  93489. /**
  93490. * Get the world position of a point that is in the local space of the bone
  93491. * @param position The local position
  93492. * @param mesh The mesh that this bone is attached to
  93493. * @returns The world position
  93494. */
  93495. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93496. /**
  93497. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  93498. * @param position The local position
  93499. * @param mesh The mesh that this bone is attached to
  93500. * @param result The vector3 that the world position should be copied to
  93501. */
  93502. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93503. /**
  93504. * Get the local position of a point that is in world space
  93505. * @param position The world position
  93506. * @param mesh The mesh that this bone is attached to
  93507. * @returns The local position
  93508. */
  93509. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93510. /**
  93511. * Get the local position of a point that is in world space and copy it to the result param
  93512. * @param position The world position
  93513. * @param mesh The mesh that this bone is attached to
  93514. * @param result The vector3 that the local position should be copied to
  93515. */
  93516. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93517. }
  93518. }
  93519. declare module BABYLON {
  93520. /**
  93521. * Defines a runtime animation
  93522. */
  93523. export class RuntimeAnimation {
  93524. private _events;
  93525. /**
  93526. * The current frame of the runtime animation
  93527. */
  93528. private _currentFrame;
  93529. /**
  93530. * The animation used by the runtime animation
  93531. */
  93532. private _animation;
  93533. /**
  93534. * The target of the runtime animation
  93535. */
  93536. private _target;
  93537. /**
  93538. * The initiating animatable
  93539. */
  93540. private _host;
  93541. /**
  93542. * The original value of the runtime animation
  93543. */
  93544. private _originalValue;
  93545. /**
  93546. * The original blend value of the runtime animation
  93547. */
  93548. private _originalBlendValue;
  93549. /**
  93550. * The offsets cache of the runtime animation
  93551. */
  93552. private _offsetsCache;
  93553. /**
  93554. * The high limits cache of the runtime animation
  93555. */
  93556. private _highLimitsCache;
  93557. /**
  93558. * Specifies if the runtime animation has been stopped
  93559. */
  93560. private _stopped;
  93561. /**
  93562. * The blending factor of the runtime animation
  93563. */
  93564. private _blendingFactor;
  93565. /**
  93566. * The BabylonJS scene
  93567. */
  93568. private _scene;
  93569. /**
  93570. * The current value of the runtime animation
  93571. */
  93572. private _currentValue;
  93573. /** @hidden */
  93574. _animationState: _IAnimationState;
  93575. /**
  93576. * The active target of the runtime animation
  93577. */
  93578. private _activeTargets;
  93579. private _currentActiveTarget;
  93580. private _directTarget;
  93581. /**
  93582. * The target path of the runtime animation
  93583. */
  93584. private _targetPath;
  93585. /**
  93586. * The weight of the runtime animation
  93587. */
  93588. private _weight;
  93589. /**
  93590. * The ratio offset of the runtime animation
  93591. */
  93592. private _ratioOffset;
  93593. /**
  93594. * The previous delay of the runtime animation
  93595. */
  93596. private _previousDelay;
  93597. /**
  93598. * The previous ratio of the runtime animation
  93599. */
  93600. private _previousRatio;
  93601. private _enableBlending;
  93602. private _keys;
  93603. private _minFrame;
  93604. private _maxFrame;
  93605. private _minValue;
  93606. private _maxValue;
  93607. private _targetIsArray;
  93608. /**
  93609. * Gets the current frame of the runtime animation
  93610. */
  93611. get currentFrame(): number;
  93612. /**
  93613. * Gets the weight of the runtime animation
  93614. */
  93615. get weight(): number;
  93616. /**
  93617. * Gets the current value of the runtime animation
  93618. */
  93619. get currentValue(): any;
  93620. /**
  93621. * Gets the target path of the runtime animation
  93622. */
  93623. get targetPath(): string;
  93624. /**
  93625. * Gets the actual target of the runtime animation
  93626. */
  93627. get target(): any;
  93628. /**
  93629. * Gets the additive state of the runtime animation
  93630. */
  93631. get isAdditive(): boolean;
  93632. /** @hidden */
  93633. _onLoop: () => void;
  93634. /**
  93635. * Create a new RuntimeAnimation object
  93636. * @param target defines the target of the animation
  93637. * @param animation defines the source animation object
  93638. * @param scene defines the hosting scene
  93639. * @param host defines the initiating Animatable
  93640. */
  93641. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  93642. private _preparePath;
  93643. /**
  93644. * Gets the animation from the runtime animation
  93645. */
  93646. get animation(): Animation;
  93647. /**
  93648. * Resets the runtime animation to the beginning
  93649. * @param restoreOriginal defines whether to restore the target property to the original value
  93650. */
  93651. reset(restoreOriginal?: boolean): void;
  93652. /**
  93653. * Specifies if the runtime animation is stopped
  93654. * @returns Boolean specifying if the runtime animation is stopped
  93655. */
  93656. isStopped(): boolean;
  93657. /**
  93658. * Disposes of the runtime animation
  93659. */
  93660. dispose(): void;
  93661. /**
  93662. * Apply the interpolated value to the target
  93663. * @param currentValue defines the value computed by the animation
  93664. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  93665. */
  93666. setValue(currentValue: any, weight: number): void;
  93667. private _getOriginalValues;
  93668. private _setValue;
  93669. /**
  93670. * Gets the loop pmode of the runtime animation
  93671. * @returns Loop Mode
  93672. */
  93673. private _getCorrectLoopMode;
  93674. /**
  93675. * Move the current animation to a given frame
  93676. * @param frame defines the frame to move to
  93677. */
  93678. goToFrame(frame: number): void;
  93679. /**
  93680. * @hidden Internal use only
  93681. */
  93682. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  93683. /**
  93684. * Execute the current animation
  93685. * @param delay defines the delay to add to the current frame
  93686. * @param from defines the lower bound of the animation range
  93687. * @param to defines the upper bound of the animation range
  93688. * @param loop defines if the current animation must loop
  93689. * @param speedRatio defines the current speed ratio
  93690. * @param weight defines the weight of the animation (default is -1 so no weight)
  93691. * @param onLoop optional callback called when animation loops
  93692. * @returns a boolean indicating if the animation is running
  93693. */
  93694. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  93695. }
  93696. }
  93697. declare module BABYLON {
  93698. /**
  93699. * Class used to store an actual running animation
  93700. */
  93701. export class Animatable {
  93702. /** defines the target object */
  93703. target: any;
  93704. /** defines the starting frame number (default is 0) */
  93705. fromFrame: number;
  93706. /** defines the ending frame number (default is 100) */
  93707. toFrame: number;
  93708. /** defines if the animation must loop (default is false) */
  93709. loopAnimation: boolean;
  93710. /** defines a callback to call when animation ends if it is not looping */
  93711. onAnimationEnd?: (() => void) | null | undefined;
  93712. /** defines a callback to call when animation loops */
  93713. onAnimationLoop?: (() => void) | null | undefined;
  93714. /** defines whether the animation should be evaluated additively */
  93715. isAdditive: boolean;
  93716. private _localDelayOffset;
  93717. private _pausedDelay;
  93718. private _runtimeAnimations;
  93719. private _paused;
  93720. private _scene;
  93721. private _speedRatio;
  93722. private _weight;
  93723. private _syncRoot;
  93724. /**
  93725. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  93726. * This will only apply for non looping animation (default is true)
  93727. */
  93728. disposeOnEnd: boolean;
  93729. /**
  93730. * Gets a boolean indicating if the animation has started
  93731. */
  93732. animationStarted: boolean;
  93733. /**
  93734. * Observer raised when the animation ends
  93735. */
  93736. onAnimationEndObservable: Observable<Animatable>;
  93737. /**
  93738. * Observer raised when the animation loops
  93739. */
  93740. onAnimationLoopObservable: Observable<Animatable>;
  93741. /**
  93742. * Gets the root Animatable used to synchronize and normalize animations
  93743. */
  93744. get syncRoot(): Nullable<Animatable>;
  93745. /**
  93746. * Gets the current frame of the first RuntimeAnimation
  93747. * Used to synchronize Animatables
  93748. */
  93749. get masterFrame(): number;
  93750. /**
  93751. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  93752. */
  93753. get weight(): number;
  93754. set weight(value: number);
  93755. /**
  93756. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  93757. */
  93758. get speedRatio(): number;
  93759. set speedRatio(value: number);
  93760. /**
  93761. * Creates a new Animatable
  93762. * @param scene defines the hosting scene
  93763. * @param target defines the target object
  93764. * @param fromFrame defines the starting frame number (default is 0)
  93765. * @param toFrame defines the ending frame number (default is 100)
  93766. * @param loopAnimation defines if the animation must loop (default is false)
  93767. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  93768. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  93769. * @param animations defines a group of animation to add to the new Animatable
  93770. * @param onAnimationLoop defines a callback to call when animation loops
  93771. * @param isAdditive defines whether the animation should be evaluated additively
  93772. */
  93773. constructor(scene: Scene,
  93774. /** defines the target object */
  93775. target: any,
  93776. /** defines the starting frame number (default is 0) */
  93777. fromFrame?: number,
  93778. /** defines the ending frame number (default is 100) */
  93779. toFrame?: number,
  93780. /** defines if the animation must loop (default is false) */
  93781. loopAnimation?: boolean, speedRatio?: number,
  93782. /** defines a callback to call when animation ends if it is not looping */
  93783. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  93784. /** defines a callback to call when animation loops */
  93785. onAnimationLoop?: (() => void) | null | undefined,
  93786. /** defines whether the animation should be evaluated additively */
  93787. isAdditive?: boolean);
  93788. /**
  93789. * Synchronize and normalize current Animatable with a source Animatable
  93790. * This is useful when using animation weights and when animations are not of the same length
  93791. * @param root defines the root Animatable to synchronize with
  93792. * @returns the current Animatable
  93793. */
  93794. syncWith(root: Animatable): Animatable;
  93795. /**
  93796. * Gets the list of runtime animations
  93797. * @returns an array of RuntimeAnimation
  93798. */
  93799. getAnimations(): RuntimeAnimation[];
  93800. /**
  93801. * Adds more animations to the current animatable
  93802. * @param target defines the target of the animations
  93803. * @param animations defines the new animations to add
  93804. */
  93805. appendAnimations(target: any, animations: Animation[]): void;
  93806. /**
  93807. * Gets the source animation for a specific property
  93808. * @param property defines the propertyu to look for
  93809. * @returns null or the source animation for the given property
  93810. */
  93811. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  93812. /**
  93813. * Gets the runtime animation for a specific property
  93814. * @param property defines the propertyu to look for
  93815. * @returns null or the runtime animation for the given property
  93816. */
  93817. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  93818. /**
  93819. * Resets the animatable to its original state
  93820. */
  93821. reset(): void;
  93822. /**
  93823. * Allows the animatable to blend with current running animations
  93824. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  93825. * @param blendingSpeed defines the blending speed to use
  93826. */
  93827. enableBlending(blendingSpeed: number): void;
  93828. /**
  93829. * Disable animation blending
  93830. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  93831. */
  93832. disableBlending(): void;
  93833. /**
  93834. * Jump directly to a given frame
  93835. * @param frame defines the frame to jump to
  93836. */
  93837. goToFrame(frame: number): void;
  93838. /**
  93839. * Pause the animation
  93840. */
  93841. pause(): void;
  93842. /**
  93843. * Restart the animation
  93844. */
  93845. restart(): void;
  93846. private _raiseOnAnimationEnd;
  93847. /**
  93848. * Stop and delete the current animation
  93849. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  93850. * @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)
  93851. */
  93852. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  93853. /**
  93854. * Wait asynchronously for the animation to end
  93855. * @returns a promise which will be fullfilled when the animation ends
  93856. */
  93857. waitAsync(): Promise<Animatable>;
  93858. /** @hidden */
  93859. _animate(delay: number): boolean;
  93860. }
  93861. interface Scene {
  93862. /** @hidden */
  93863. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  93864. /** @hidden */
  93865. _processLateAnimationBindingsForMatrices(holder: {
  93866. totalWeight: number;
  93867. totalAdditiveWeight: number;
  93868. animations: RuntimeAnimation[];
  93869. additiveAnimations: RuntimeAnimation[];
  93870. originalValue: Matrix;
  93871. }): any;
  93872. /** @hidden */
  93873. _processLateAnimationBindingsForQuaternions(holder: {
  93874. totalWeight: number;
  93875. totalAdditiveWeight: number;
  93876. animations: RuntimeAnimation[];
  93877. additiveAnimations: RuntimeAnimation[];
  93878. originalValue: Quaternion;
  93879. }, refQuaternion: Quaternion): Quaternion;
  93880. /** @hidden */
  93881. _processLateAnimationBindings(): void;
  93882. /**
  93883. * Will start the animation sequence of a given target
  93884. * @param target defines the target
  93885. * @param from defines from which frame should animation start
  93886. * @param to defines until which frame should animation run.
  93887. * @param weight defines the weight to apply to the animation (1.0 by default)
  93888. * @param loop defines if the animation loops
  93889. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93890. * @param onAnimationEnd defines the function to be executed when the animation ends
  93891. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93892. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93893. * @param onAnimationLoop defines the callback to call when an animation loops
  93894. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93895. * @returns the animatable object created for this animation
  93896. */
  93897. 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;
  93898. /**
  93899. * Will start the animation sequence of a given target
  93900. * @param target defines the target
  93901. * @param from defines from which frame should animation start
  93902. * @param to defines until which frame should animation run.
  93903. * @param loop defines if the animation loops
  93904. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93905. * @param onAnimationEnd defines the function to be executed when the animation ends
  93906. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93907. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93908. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  93909. * @param onAnimationLoop defines the callback to call when an animation loops
  93910. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93911. * @returns the animatable object created for this animation
  93912. */
  93913. 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;
  93914. /**
  93915. * Will start the animation sequence of a given target and its hierarchy
  93916. * @param target defines the target
  93917. * @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.
  93918. * @param from defines from which frame should animation start
  93919. * @param to defines until which frame should animation run.
  93920. * @param loop defines if the animation loops
  93921. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93922. * @param onAnimationEnd defines the function to be executed when the animation ends
  93923. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93924. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93925. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93926. * @param onAnimationLoop defines the callback to call when an animation loops
  93927. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93928. * @returns the list of created animatables
  93929. */
  93930. 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[];
  93931. /**
  93932. * Begin a new animation on a given node
  93933. * @param target defines the target where the animation will take place
  93934. * @param animations defines the list of animations to start
  93935. * @param from defines the initial value
  93936. * @param to defines the final value
  93937. * @param loop defines if you want animation to loop (off by default)
  93938. * @param speedRatio defines the speed ratio to apply to all animations
  93939. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93940. * @param onAnimationLoop defines the callback to call when an animation loops
  93941. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93942. * @returns the list of created animatables
  93943. */
  93944. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93945. /**
  93946. * Begin a new animation on a given node and its hierarchy
  93947. * @param target defines the root node where the animation will take place
  93948. * @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.
  93949. * @param animations defines the list of animations to start
  93950. * @param from defines the initial value
  93951. * @param to defines the final value
  93952. * @param loop defines if you want animation to loop (off by default)
  93953. * @param speedRatio defines the speed ratio to apply to all animations
  93954. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93955. * @param onAnimationLoop defines the callback to call when an animation loops
  93956. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93957. * @returns the list of animatables created for all nodes
  93958. */
  93959. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  93960. /**
  93961. * Gets the animatable associated with a specific target
  93962. * @param target defines the target of the animatable
  93963. * @returns the required animatable if found
  93964. */
  93965. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93966. /**
  93967. * Gets all animatables associated with a given target
  93968. * @param target defines the target to look animatables for
  93969. * @returns an array of Animatables
  93970. */
  93971. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93972. /**
  93973. * Stops and removes all animations that have been applied to the scene
  93974. */
  93975. stopAllAnimations(): void;
  93976. /**
  93977. * Gets the current delta time used by animation engine
  93978. */
  93979. deltaTime: number;
  93980. }
  93981. interface Bone {
  93982. /**
  93983. * Copy an animation range from another bone
  93984. * @param source defines the source bone
  93985. * @param rangeName defines the range name to copy
  93986. * @param frameOffset defines the frame offset
  93987. * @param rescaleAsRequired defines if rescaling must be applied if required
  93988. * @param skelDimensionsRatio defines the scaling ratio
  93989. * @returns true if operation was successful
  93990. */
  93991. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93992. }
  93993. }
  93994. declare module BABYLON {
  93995. /**
  93996. * Class used to handle skinning animations
  93997. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93998. */
  93999. export class Skeleton implements IAnimatable {
  94000. /** defines the skeleton name */
  94001. name: string;
  94002. /** defines the skeleton Id */
  94003. id: string;
  94004. /**
  94005. * Defines the list of child bones
  94006. */
  94007. bones: Bone[];
  94008. /**
  94009. * Defines an estimate of the dimension of the skeleton at rest
  94010. */
  94011. dimensionsAtRest: Vector3;
  94012. /**
  94013. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94014. */
  94015. needInitialSkinMatrix: boolean;
  94016. /**
  94017. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94018. */
  94019. overrideMesh: Nullable<AbstractMesh>;
  94020. /**
  94021. * Gets the list of animations attached to this skeleton
  94022. */
  94023. animations: Array<Animation>;
  94024. private _scene;
  94025. private _isDirty;
  94026. private _transformMatrices;
  94027. private _transformMatrixTexture;
  94028. private _meshesWithPoseMatrix;
  94029. private _animatables;
  94030. private _identity;
  94031. private _synchronizedWithMesh;
  94032. private _ranges;
  94033. private _lastAbsoluteTransformsUpdateId;
  94034. private _canUseTextureForBones;
  94035. private _uniqueId;
  94036. /** @hidden */
  94037. _numBonesWithLinkedTransformNode: number;
  94038. /** @hidden */
  94039. _hasWaitingData: Nullable<boolean>;
  94040. /**
  94041. * Specifies if the skeleton should be serialized
  94042. */
  94043. doNotSerialize: boolean;
  94044. private _useTextureToStoreBoneMatrices;
  94045. /**
  94046. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  94047. * Please note that this option is not available if the hardware does not support it
  94048. */
  94049. get useTextureToStoreBoneMatrices(): boolean;
  94050. set useTextureToStoreBoneMatrices(value: boolean);
  94051. private _animationPropertiesOverride;
  94052. /**
  94053. * Gets or sets the animation properties override
  94054. */
  94055. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94056. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94057. /**
  94058. * List of inspectable custom properties (used by the Inspector)
  94059. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94060. */
  94061. inspectableCustomProperties: IInspectable[];
  94062. /**
  94063. * An observable triggered before computing the skeleton's matrices
  94064. */
  94065. onBeforeComputeObservable: Observable<Skeleton>;
  94066. /**
  94067. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  94068. */
  94069. get isUsingTextureForMatrices(): boolean;
  94070. /**
  94071. * Gets the unique ID of this skeleton
  94072. */
  94073. get uniqueId(): number;
  94074. /**
  94075. * Creates a new skeleton
  94076. * @param name defines the skeleton name
  94077. * @param id defines the skeleton Id
  94078. * @param scene defines the hosting scene
  94079. */
  94080. constructor(
  94081. /** defines the skeleton name */
  94082. name: string,
  94083. /** defines the skeleton Id */
  94084. id: string, scene: Scene);
  94085. /**
  94086. * Gets the current object class name.
  94087. * @return the class name
  94088. */
  94089. getClassName(): string;
  94090. /**
  94091. * Returns an array containing the root bones
  94092. * @returns an array containing the root bones
  94093. */
  94094. getChildren(): Array<Bone>;
  94095. /**
  94096. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  94097. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94098. * @returns a Float32Array containing matrices data
  94099. */
  94100. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  94101. /**
  94102. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  94103. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94104. * @returns a raw texture containing the data
  94105. */
  94106. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  94107. /**
  94108. * Gets the current hosting scene
  94109. * @returns a scene object
  94110. */
  94111. getScene(): Scene;
  94112. /**
  94113. * Gets a string representing the current skeleton data
  94114. * @param fullDetails defines a boolean indicating if we want a verbose version
  94115. * @returns a string representing the current skeleton data
  94116. */
  94117. toString(fullDetails?: boolean): string;
  94118. /**
  94119. * Get bone's index searching by name
  94120. * @param name defines bone's name to search for
  94121. * @return the indice of the bone. Returns -1 if not found
  94122. */
  94123. getBoneIndexByName(name: string): number;
  94124. /**
  94125. * Creater a new animation range
  94126. * @param name defines the name of the range
  94127. * @param from defines the start key
  94128. * @param to defines the end key
  94129. */
  94130. createAnimationRange(name: string, from: number, to: number): void;
  94131. /**
  94132. * Delete a specific animation range
  94133. * @param name defines the name of the range
  94134. * @param deleteFrames defines if frames must be removed as well
  94135. */
  94136. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94137. /**
  94138. * Gets a specific animation range
  94139. * @param name defines the name of the range to look for
  94140. * @returns the requested animation range or null if not found
  94141. */
  94142. getAnimationRange(name: string): Nullable<AnimationRange>;
  94143. /**
  94144. * Gets the list of all animation ranges defined on this skeleton
  94145. * @returns an array
  94146. */
  94147. getAnimationRanges(): Nullable<AnimationRange>[];
  94148. /**
  94149. * Copy animation range from a source skeleton.
  94150. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  94151. * @param source defines the source skeleton
  94152. * @param name defines the name of the range to copy
  94153. * @param rescaleAsRequired defines if rescaling must be applied if required
  94154. * @returns true if operation was successful
  94155. */
  94156. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  94157. /**
  94158. * Forces the skeleton to go to rest pose
  94159. */
  94160. returnToRest(): void;
  94161. private _getHighestAnimationFrame;
  94162. /**
  94163. * Begin a specific animation range
  94164. * @param name defines the name of the range to start
  94165. * @param loop defines if looping must be turned on (false by default)
  94166. * @param speedRatio defines the speed ratio to apply (1 by default)
  94167. * @param onAnimationEnd defines a callback which will be called when animation will end
  94168. * @returns a new animatable
  94169. */
  94170. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94171. /**
  94172. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  94173. * @param skeleton defines the Skeleton containing the animation range to convert
  94174. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  94175. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  94176. * @returns the original skeleton
  94177. */
  94178. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  94179. /** @hidden */
  94180. _markAsDirty(): void;
  94181. /** @hidden */
  94182. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94183. /** @hidden */
  94184. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94185. private _computeTransformMatrices;
  94186. /**
  94187. * Build all resources required to render a skeleton
  94188. */
  94189. prepare(): void;
  94190. /**
  94191. * Gets the list of animatables currently running for this skeleton
  94192. * @returns an array of animatables
  94193. */
  94194. getAnimatables(): IAnimatable[];
  94195. /**
  94196. * Clone the current skeleton
  94197. * @param name defines the name of the new skeleton
  94198. * @param id defines the id of the new skeleton
  94199. * @returns the new skeleton
  94200. */
  94201. clone(name: string, id?: string): Skeleton;
  94202. /**
  94203. * Enable animation blending for this skeleton
  94204. * @param blendingSpeed defines the blending speed to apply
  94205. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94206. */
  94207. enableBlending(blendingSpeed?: number): void;
  94208. /**
  94209. * Releases all resources associated with the current skeleton
  94210. */
  94211. dispose(): void;
  94212. /**
  94213. * Serialize the skeleton in a JSON object
  94214. * @returns a JSON object
  94215. */
  94216. serialize(): any;
  94217. /**
  94218. * Creates a new skeleton from serialized data
  94219. * @param parsedSkeleton defines the serialized data
  94220. * @param scene defines the hosting scene
  94221. * @returns a new skeleton
  94222. */
  94223. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  94224. /**
  94225. * Compute all node absolute transforms
  94226. * @param forceUpdate defines if computation must be done even if cache is up to date
  94227. */
  94228. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  94229. /**
  94230. * Gets the root pose matrix
  94231. * @returns a matrix
  94232. */
  94233. getPoseMatrix(): Nullable<Matrix>;
  94234. /**
  94235. * Sorts bones per internal index
  94236. */
  94237. sortBones(): void;
  94238. private _sortBones;
  94239. }
  94240. }
  94241. declare module BABYLON {
  94242. /**
  94243. * Creates an instance based on a source mesh.
  94244. */
  94245. export class InstancedMesh extends AbstractMesh {
  94246. private _sourceMesh;
  94247. private _currentLOD;
  94248. /** @hidden */
  94249. _indexInSourceMeshInstanceArray: number;
  94250. constructor(name: string, source: Mesh);
  94251. /**
  94252. * Returns the string "InstancedMesh".
  94253. */
  94254. getClassName(): string;
  94255. /** Gets the list of lights affecting that mesh */
  94256. get lightSources(): Light[];
  94257. _resyncLightSources(): void;
  94258. _resyncLightSource(light: Light): void;
  94259. _removeLightSource(light: Light, dispose: boolean): void;
  94260. /**
  94261. * If the source mesh receives shadows
  94262. */
  94263. get receiveShadows(): boolean;
  94264. /**
  94265. * The material of the source mesh
  94266. */
  94267. get material(): Nullable<Material>;
  94268. /**
  94269. * Visibility of the source mesh
  94270. */
  94271. get visibility(): number;
  94272. /**
  94273. * Skeleton of the source mesh
  94274. */
  94275. get skeleton(): Nullable<Skeleton>;
  94276. /**
  94277. * Rendering ground id of the source mesh
  94278. */
  94279. get renderingGroupId(): number;
  94280. set renderingGroupId(value: number);
  94281. /**
  94282. * Returns the total number of vertices (integer).
  94283. */
  94284. getTotalVertices(): number;
  94285. /**
  94286. * Returns a positive integer : the total number of indices in this mesh geometry.
  94287. * @returns the numner of indices or zero if the mesh has no geometry.
  94288. */
  94289. getTotalIndices(): number;
  94290. /**
  94291. * The source mesh of the instance
  94292. */
  94293. get sourceMesh(): Mesh;
  94294. /**
  94295. * Creates a new InstancedMesh object from the mesh model.
  94296. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94297. * @param name defines the name of the new instance
  94298. * @returns a new InstancedMesh
  94299. */
  94300. createInstance(name: string): InstancedMesh;
  94301. /**
  94302. * Is this node ready to be used/rendered
  94303. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94304. * @return {boolean} is it ready
  94305. */
  94306. isReady(completeCheck?: boolean): boolean;
  94307. /**
  94308. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94309. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  94310. * @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.
  94311. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  94312. */
  94313. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  94314. /**
  94315. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94316. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94317. * The `data` are either a numeric array either a Float32Array.
  94318. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  94319. * 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).
  94320. * Note that a new underlying VertexBuffer object is created each call.
  94321. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94322. *
  94323. * Possible `kind` values :
  94324. * - VertexBuffer.PositionKind
  94325. * - VertexBuffer.UVKind
  94326. * - VertexBuffer.UV2Kind
  94327. * - VertexBuffer.UV3Kind
  94328. * - VertexBuffer.UV4Kind
  94329. * - VertexBuffer.UV5Kind
  94330. * - VertexBuffer.UV6Kind
  94331. * - VertexBuffer.ColorKind
  94332. * - VertexBuffer.MatricesIndicesKind
  94333. * - VertexBuffer.MatricesIndicesExtraKind
  94334. * - VertexBuffer.MatricesWeightsKind
  94335. * - VertexBuffer.MatricesWeightsExtraKind
  94336. *
  94337. * Returns the Mesh.
  94338. */
  94339. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94340. /**
  94341. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94342. * If the mesh has no geometry, it is simply returned as it is.
  94343. * The `data` are either a numeric array either a Float32Array.
  94344. * No new underlying VertexBuffer object is created.
  94345. * 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.
  94346. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  94347. *
  94348. * Possible `kind` values :
  94349. * - VertexBuffer.PositionKind
  94350. * - VertexBuffer.UVKind
  94351. * - VertexBuffer.UV2Kind
  94352. * - VertexBuffer.UV3Kind
  94353. * - VertexBuffer.UV4Kind
  94354. * - VertexBuffer.UV5Kind
  94355. * - VertexBuffer.UV6Kind
  94356. * - VertexBuffer.ColorKind
  94357. * - VertexBuffer.MatricesIndicesKind
  94358. * - VertexBuffer.MatricesIndicesExtraKind
  94359. * - VertexBuffer.MatricesWeightsKind
  94360. * - VertexBuffer.MatricesWeightsExtraKind
  94361. *
  94362. * Returns the Mesh.
  94363. */
  94364. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  94365. /**
  94366. * Sets the mesh indices.
  94367. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  94368. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94369. * This method creates a new index buffer each call.
  94370. * Returns the Mesh.
  94371. */
  94372. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  94373. /**
  94374. * Boolean : True if the mesh owns the requested kind of data.
  94375. */
  94376. isVerticesDataPresent(kind: string): boolean;
  94377. /**
  94378. * Returns an array of indices (IndicesArray).
  94379. */
  94380. getIndices(): Nullable<IndicesArray>;
  94381. get _positions(): Nullable<Vector3[]>;
  94382. /**
  94383. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94384. * This means the mesh underlying bounding box and sphere are recomputed.
  94385. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94386. * @returns the current mesh
  94387. */
  94388. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  94389. /** @hidden */
  94390. _preActivate(): InstancedMesh;
  94391. /** @hidden */
  94392. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94393. /** @hidden */
  94394. _postActivate(): void;
  94395. getWorldMatrix(): Matrix;
  94396. get isAnInstance(): boolean;
  94397. /**
  94398. * Returns the current associated LOD AbstractMesh.
  94399. */
  94400. getLOD(camera: Camera): AbstractMesh;
  94401. /** @hidden */
  94402. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94403. /** @hidden */
  94404. _syncSubMeshes(): InstancedMesh;
  94405. /** @hidden */
  94406. _generatePointsArray(): boolean;
  94407. /**
  94408. * Creates a new InstancedMesh from the current mesh.
  94409. * - name (string) : the cloned mesh name
  94410. * - newParent (optional Node) : the optional Node to parent the clone to.
  94411. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  94412. *
  94413. * Returns the clone.
  94414. */
  94415. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  94416. /**
  94417. * Disposes the InstancedMesh.
  94418. * Returns nothing.
  94419. */
  94420. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94421. }
  94422. interface Mesh {
  94423. /**
  94424. * Register a custom buffer that will be instanced
  94425. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94426. * @param kind defines the buffer kind
  94427. * @param stride defines the stride in floats
  94428. */
  94429. registerInstancedBuffer(kind: string, stride: number): void;
  94430. /**
  94431. * true to use the edge renderer for all instances of this mesh
  94432. */
  94433. edgesShareWithInstances: boolean;
  94434. /** @hidden */
  94435. _userInstancedBuffersStorage: {
  94436. data: {
  94437. [key: string]: Float32Array;
  94438. };
  94439. sizes: {
  94440. [key: string]: number;
  94441. };
  94442. vertexBuffers: {
  94443. [key: string]: Nullable<VertexBuffer>;
  94444. };
  94445. strides: {
  94446. [key: string]: number;
  94447. };
  94448. };
  94449. }
  94450. interface AbstractMesh {
  94451. /**
  94452. * Object used to store instanced buffers defined by user
  94453. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94454. */
  94455. instancedBuffers: {
  94456. [key: string]: any;
  94457. };
  94458. }
  94459. }
  94460. declare module BABYLON {
  94461. /**
  94462. * Defines the options associated with the creation of a shader material.
  94463. */
  94464. export interface IShaderMaterialOptions {
  94465. /**
  94466. * Does the material work in alpha blend mode
  94467. */
  94468. needAlphaBlending: boolean;
  94469. /**
  94470. * Does the material work in alpha test mode
  94471. */
  94472. needAlphaTesting: boolean;
  94473. /**
  94474. * The list of attribute names used in the shader
  94475. */
  94476. attributes: string[];
  94477. /**
  94478. * The list of unifrom names used in the shader
  94479. */
  94480. uniforms: string[];
  94481. /**
  94482. * The list of UBO names used in the shader
  94483. */
  94484. uniformBuffers: string[];
  94485. /**
  94486. * The list of sampler names used in the shader
  94487. */
  94488. samplers: string[];
  94489. /**
  94490. * The list of defines used in the shader
  94491. */
  94492. defines: string[];
  94493. }
  94494. /**
  94495. * 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.
  94496. *
  94497. * This returned material effects how the mesh will look based on the code in the shaders.
  94498. *
  94499. * @see https://doc.babylonjs.com/how_to/shader_material
  94500. */
  94501. export class ShaderMaterial extends Material {
  94502. private _shaderPath;
  94503. private _options;
  94504. private _textures;
  94505. private _textureArrays;
  94506. private _floats;
  94507. private _ints;
  94508. private _floatsArrays;
  94509. private _colors3;
  94510. private _colors3Arrays;
  94511. private _colors4;
  94512. private _colors4Arrays;
  94513. private _vectors2;
  94514. private _vectors3;
  94515. private _vectors4;
  94516. private _matrices;
  94517. private _matrixArrays;
  94518. private _matrices3x3;
  94519. private _matrices2x2;
  94520. private _vectors2Arrays;
  94521. private _vectors3Arrays;
  94522. private _vectors4Arrays;
  94523. private _cachedWorldViewMatrix;
  94524. private _cachedWorldViewProjectionMatrix;
  94525. private _renderId;
  94526. private _multiview;
  94527. private _cachedDefines;
  94528. /** Define the Url to load snippets */
  94529. static SnippetUrl: string;
  94530. /** Snippet ID if the material was created from the snippet server */
  94531. snippetId: string;
  94532. /**
  94533. * Instantiate a new shader material.
  94534. * 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.
  94535. * This returned material effects how the mesh will look based on the code in the shaders.
  94536. * @see https://doc.babylonjs.com/how_to/shader_material
  94537. * @param name Define the name of the material in the scene
  94538. * @param scene Define the scene the material belongs to
  94539. * @param shaderPath Defines the route to the shader code in one of three ways:
  94540. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  94541. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  94542. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  94543. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  94544. * @param options Define the options used to create the shader
  94545. */
  94546. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  94547. /**
  94548. * Gets the shader path used to define the shader code
  94549. * It can be modified to trigger a new compilation
  94550. */
  94551. get shaderPath(): any;
  94552. /**
  94553. * Sets the shader path used to define the shader code
  94554. * It can be modified to trigger a new compilation
  94555. */
  94556. set shaderPath(shaderPath: any);
  94557. /**
  94558. * Gets the options used to compile the shader.
  94559. * They can be modified to trigger a new compilation
  94560. */
  94561. get options(): IShaderMaterialOptions;
  94562. /**
  94563. * Gets the current class name of the material e.g. "ShaderMaterial"
  94564. * Mainly use in serialization.
  94565. * @returns the class name
  94566. */
  94567. getClassName(): string;
  94568. /**
  94569. * Specifies if the material will require alpha blending
  94570. * @returns a boolean specifying if alpha blending is needed
  94571. */
  94572. needAlphaBlending(): boolean;
  94573. /**
  94574. * Specifies if this material should be rendered in alpha test mode
  94575. * @returns a boolean specifying if an alpha test is needed.
  94576. */
  94577. needAlphaTesting(): boolean;
  94578. private _checkUniform;
  94579. /**
  94580. * Set a texture in the shader.
  94581. * @param name Define the name of the uniform samplers as defined in the shader
  94582. * @param texture Define the texture to bind to this sampler
  94583. * @return the material itself allowing "fluent" like uniform updates
  94584. */
  94585. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  94586. /**
  94587. * Set a texture array in the shader.
  94588. * @param name Define the name of the uniform sampler array as defined in the shader
  94589. * @param textures Define the list of textures to bind to this sampler
  94590. * @return the material itself allowing "fluent" like uniform updates
  94591. */
  94592. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  94593. /**
  94594. * Set a float in the shader.
  94595. * @param name Define the name of the uniform as defined in the shader
  94596. * @param value Define the value to give to the uniform
  94597. * @return the material itself allowing "fluent" like uniform updates
  94598. */
  94599. setFloat(name: string, value: number): ShaderMaterial;
  94600. /**
  94601. * Set a int in the shader.
  94602. * @param name Define the name of the uniform as defined in the shader
  94603. * @param value Define the value to give to the uniform
  94604. * @return the material itself allowing "fluent" like uniform updates
  94605. */
  94606. setInt(name: string, value: number): ShaderMaterial;
  94607. /**
  94608. * Set an array of floats in the shader.
  94609. * @param name Define the name of the uniform as defined in the shader
  94610. * @param value Define the value to give to the uniform
  94611. * @return the material itself allowing "fluent" like uniform updates
  94612. */
  94613. setFloats(name: string, value: number[]): ShaderMaterial;
  94614. /**
  94615. * Set a vec3 in the shader from a Color3.
  94616. * @param name Define the name of the uniform as defined in the shader
  94617. * @param value Define the value to give to the uniform
  94618. * @return the material itself allowing "fluent" like uniform updates
  94619. */
  94620. setColor3(name: string, value: Color3): ShaderMaterial;
  94621. /**
  94622. * Set a vec3 array in the shader from a Color3 array.
  94623. * @param name Define the name of the uniform as defined in the shader
  94624. * @param value Define the value to give to the uniform
  94625. * @return the material itself allowing "fluent" like uniform updates
  94626. */
  94627. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  94628. /**
  94629. * Set a vec4 in the shader from a Color4.
  94630. * @param name Define the name of the uniform as defined in the shader
  94631. * @param value Define the value to give to the uniform
  94632. * @return the material itself allowing "fluent" like uniform updates
  94633. */
  94634. setColor4(name: string, value: Color4): ShaderMaterial;
  94635. /**
  94636. * Set a vec4 array in the shader from a Color4 array.
  94637. * @param name Define the name of the uniform as defined in the shader
  94638. * @param value Define the value to give to the uniform
  94639. * @return the material itself allowing "fluent" like uniform updates
  94640. */
  94641. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  94642. /**
  94643. * Set a vec2 in the shader from a Vector2.
  94644. * @param name Define the name of the uniform as defined in the shader
  94645. * @param value Define the value to give to the uniform
  94646. * @return the material itself allowing "fluent" like uniform updates
  94647. */
  94648. setVector2(name: string, value: Vector2): ShaderMaterial;
  94649. /**
  94650. * Set a vec3 in the shader from a Vector3.
  94651. * @param name Define the name of the uniform as defined in the shader
  94652. * @param value Define the value to give to the uniform
  94653. * @return the material itself allowing "fluent" like uniform updates
  94654. */
  94655. setVector3(name: string, value: Vector3): ShaderMaterial;
  94656. /**
  94657. * Set a vec4 in the shader from a Vector4.
  94658. * @param name Define the name of the uniform as defined in the shader
  94659. * @param value Define the value to give to the uniform
  94660. * @return the material itself allowing "fluent" like uniform updates
  94661. */
  94662. setVector4(name: string, value: Vector4): ShaderMaterial;
  94663. /**
  94664. * Set a mat4 in the shader from a Matrix.
  94665. * @param name Define the name of the uniform as defined in the shader
  94666. * @param value Define the value to give to the uniform
  94667. * @return the material itself allowing "fluent" like uniform updates
  94668. */
  94669. setMatrix(name: string, value: Matrix): ShaderMaterial;
  94670. /**
  94671. * Set a float32Array in the shader from a matrix array.
  94672. * @param name Define the name of the uniform as defined in the shader
  94673. * @param value Define the value to give to the uniform
  94674. * @return the material itself allowing "fluent" like uniform updates
  94675. */
  94676. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  94677. /**
  94678. * Set a mat3 in the shader from a Float32Array.
  94679. * @param name Define the name of the uniform as defined in the shader
  94680. * @param value Define the value to give to the uniform
  94681. * @return the material itself allowing "fluent" like uniform updates
  94682. */
  94683. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  94684. /**
  94685. * Set a mat2 in the shader from a Float32Array.
  94686. * @param name Define the name of the uniform as defined in the shader
  94687. * @param value Define the value to give to the uniform
  94688. * @return the material itself allowing "fluent" like uniform updates
  94689. */
  94690. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  94691. /**
  94692. * Set a vec2 array in the shader from a number array.
  94693. * @param name Define the name of the uniform as defined in the shader
  94694. * @param value Define the value to give to the uniform
  94695. * @return the material itself allowing "fluent" like uniform updates
  94696. */
  94697. setArray2(name: string, value: number[]): ShaderMaterial;
  94698. /**
  94699. * Set a vec3 array in the shader from a number array.
  94700. * @param name Define the name of the uniform as defined in the shader
  94701. * @param value Define the value to give to the uniform
  94702. * @return the material itself allowing "fluent" like uniform updates
  94703. */
  94704. setArray3(name: string, value: number[]): ShaderMaterial;
  94705. /**
  94706. * Set a vec4 array in the shader from a number array.
  94707. * @param name Define the name of the uniform as defined in the shader
  94708. * @param value Define the value to give to the uniform
  94709. * @return the material itself allowing "fluent" like uniform updates
  94710. */
  94711. setArray4(name: string, value: number[]): ShaderMaterial;
  94712. private _checkCache;
  94713. /**
  94714. * Specifies that the submesh is ready to be used
  94715. * @param mesh defines the mesh to check
  94716. * @param subMesh defines which submesh to check
  94717. * @param useInstances specifies that instances should be used
  94718. * @returns a boolean indicating that the submesh is ready or not
  94719. */
  94720. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94721. /**
  94722. * Checks if the material is ready to render the requested mesh
  94723. * @param mesh Define the mesh to render
  94724. * @param useInstances Define whether or not the material is used with instances
  94725. * @returns true if ready, otherwise false
  94726. */
  94727. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94728. /**
  94729. * Binds the world matrix to the material
  94730. * @param world defines the world transformation matrix
  94731. * @param effectOverride - If provided, use this effect instead of internal effect
  94732. */
  94733. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  94734. /**
  94735. * Binds the submesh to this material by preparing the effect and shader to draw
  94736. * @param world defines the world transformation matrix
  94737. * @param mesh defines the mesh containing the submesh
  94738. * @param subMesh defines the submesh to bind the material to
  94739. */
  94740. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94741. /**
  94742. * Binds the material to the mesh
  94743. * @param world defines the world transformation matrix
  94744. * @param mesh defines the mesh to bind the material to
  94745. * @param effectOverride - If provided, use this effect instead of internal effect
  94746. */
  94747. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  94748. protected _afterBind(mesh?: Mesh): void;
  94749. /**
  94750. * Gets the active textures from the material
  94751. * @returns an array of textures
  94752. */
  94753. getActiveTextures(): BaseTexture[];
  94754. /**
  94755. * Specifies if the material uses a texture
  94756. * @param texture defines the texture to check against the material
  94757. * @returns a boolean specifying if the material uses the texture
  94758. */
  94759. hasTexture(texture: BaseTexture): boolean;
  94760. /**
  94761. * Makes a duplicate of the material, and gives it a new name
  94762. * @param name defines the new name for the duplicated material
  94763. * @returns the cloned material
  94764. */
  94765. clone(name: string): ShaderMaterial;
  94766. /**
  94767. * Disposes the material
  94768. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94769. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94770. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94771. */
  94772. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94773. /**
  94774. * Serializes this material in a JSON representation
  94775. * @returns the serialized material object
  94776. */
  94777. serialize(): any;
  94778. /**
  94779. * Creates a shader material from parsed shader material data
  94780. * @param source defines the JSON represnetation of the material
  94781. * @param scene defines the hosting scene
  94782. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94783. * @returns a new material
  94784. */
  94785. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  94786. /**
  94787. * Creates a new ShaderMaterial from a snippet saved in a remote file
  94788. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  94789. * @param url defines the url to load from
  94790. * @param scene defines the hosting scene
  94791. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94792. * @returns a promise that will resolve to the new ShaderMaterial
  94793. */
  94794. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94795. /**
  94796. * Creates a ShaderMaterial from a snippet saved by the Inspector
  94797. * @param snippetId defines the snippet to load
  94798. * @param scene defines the hosting scene
  94799. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94800. * @returns a promise that will resolve to the new ShaderMaterial
  94801. */
  94802. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94803. }
  94804. }
  94805. declare module BABYLON {
  94806. /** @hidden */
  94807. export var colorPixelShader: {
  94808. name: string;
  94809. shader: string;
  94810. };
  94811. }
  94812. declare module BABYLON {
  94813. /** @hidden */
  94814. export var colorVertexShader: {
  94815. name: string;
  94816. shader: string;
  94817. };
  94818. }
  94819. declare module BABYLON {
  94820. /**
  94821. * Line mesh
  94822. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  94823. */
  94824. export class LinesMesh extends Mesh {
  94825. /**
  94826. * If vertex color should be applied to the mesh
  94827. */
  94828. readonly useVertexColor?: boolean | undefined;
  94829. /**
  94830. * If vertex alpha should be applied to the mesh
  94831. */
  94832. readonly useVertexAlpha?: boolean | undefined;
  94833. /**
  94834. * Color of the line (Default: White)
  94835. */
  94836. color: Color3;
  94837. /**
  94838. * Alpha of the line (Default: 1)
  94839. */
  94840. alpha: number;
  94841. /**
  94842. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94843. * This margin is expressed in world space coordinates, so its value may vary.
  94844. * Default value is 0.1
  94845. */
  94846. intersectionThreshold: number;
  94847. private _colorShader;
  94848. private color4;
  94849. /**
  94850. * Creates a new LinesMesh
  94851. * @param name defines the name
  94852. * @param scene defines the hosting scene
  94853. * @param parent defines the parent mesh if any
  94854. * @param source defines the optional source LinesMesh used to clone data from
  94855. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94856. * When false, achieved by calling a clone(), also passing False.
  94857. * This will make creation of children, recursive.
  94858. * @param useVertexColor defines if this LinesMesh supports vertex color
  94859. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  94860. */
  94861. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  94862. /**
  94863. * If vertex color should be applied to the mesh
  94864. */
  94865. useVertexColor?: boolean | undefined,
  94866. /**
  94867. * If vertex alpha should be applied to the mesh
  94868. */
  94869. useVertexAlpha?: boolean | undefined);
  94870. private _addClipPlaneDefine;
  94871. private _removeClipPlaneDefine;
  94872. isReady(): boolean;
  94873. /**
  94874. * Returns the string "LineMesh"
  94875. */
  94876. getClassName(): string;
  94877. /**
  94878. * @hidden
  94879. */
  94880. get material(): Material;
  94881. /**
  94882. * @hidden
  94883. */
  94884. set material(value: Material);
  94885. /**
  94886. * @hidden
  94887. */
  94888. get checkCollisions(): boolean;
  94889. /** @hidden */
  94890. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  94891. /** @hidden */
  94892. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  94893. /**
  94894. * Disposes of the line mesh
  94895. * @param doNotRecurse If children should be disposed
  94896. */
  94897. dispose(doNotRecurse?: boolean): void;
  94898. /**
  94899. * Returns a new LineMesh object cloned from the current one.
  94900. */
  94901. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  94902. /**
  94903. * Creates a new InstancedLinesMesh object from the mesh model.
  94904. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94905. * @param name defines the name of the new instance
  94906. * @returns a new InstancedLinesMesh
  94907. */
  94908. createInstance(name: string): InstancedLinesMesh;
  94909. }
  94910. /**
  94911. * Creates an instance based on a source LinesMesh
  94912. */
  94913. export class InstancedLinesMesh extends InstancedMesh {
  94914. /**
  94915. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94916. * This margin is expressed in world space coordinates, so its value may vary.
  94917. * Initilized with the intersectionThreshold value of the source LinesMesh
  94918. */
  94919. intersectionThreshold: number;
  94920. constructor(name: string, source: LinesMesh);
  94921. /**
  94922. * Returns the string "InstancedLinesMesh".
  94923. */
  94924. getClassName(): string;
  94925. }
  94926. }
  94927. declare module BABYLON {
  94928. /** @hidden */
  94929. export var linePixelShader: {
  94930. name: string;
  94931. shader: string;
  94932. };
  94933. }
  94934. declare module BABYLON {
  94935. /** @hidden */
  94936. export var lineVertexShader: {
  94937. name: string;
  94938. shader: string;
  94939. };
  94940. }
  94941. declare module BABYLON {
  94942. interface Scene {
  94943. /** @hidden */
  94944. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  94945. }
  94946. interface AbstractMesh {
  94947. /**
  94948. * Gets the edgesRenderer associated with the mesh
  94949. */
  94950. edgesRenderer: Nullable<EdgesRenderer>;
  94951. }
  94952. interface LinesMesh {
  94953. /**
  94954. * Enables the edge rendering mode on the mesh.
  94955. * This mode makes the mesh edges visible
  94956. * @param epsilon defines the maximal distance between two angles to detect a face
  94957. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94958. * @returns the currentAbstractMesh
  94959. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94960. */
  94961. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94962. }
  94963. interface InstancedLinesMesh {
  94964. /**
  94965. * Enables the edge rendering mode on the mesh.
  94966. * This mode makes the mesh edges visible
  94967. * @param epsilon defines the maximal distance between two angles to detect a face
  94968. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94969. * @returns the current InstancedLinesMesh
  94970. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94971. */
  94972. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  94973. }
  94974. /**
  94975. * Defines the minimum contract an Edges renderer should follow.
  94976. */
  94977. export interface IEdgesRenderer extends IDisposable {
  94978. /**
  94979. * Gets or sets a boolean indicating if the edgesRenderer is active
  94980. */
  94981. isEnabled: boolean;
  94982. /**
  94983. * Renders the edges of the attached mesh,
  94984. */
  94985. render(): void;
  94986. /**
  94987. * Checks wether or not the edges renderer is ready to render.
  94988. * @return true if ready, otherwise false.
  94989. */
  94990. isReady(): boolean;
  94991. /**
  94992. * List of instances to render in case the source mesh has instances
  94993. */
  94994. customInstances: SmartArray<Matrix>;
  94995. }
  94996. /**
  94997. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94998. */
  94999. export class EdgesRenderer implements IEdgesRenderer {
  95000. /**
  95001. * Define the size of the edges with an orthographic camera
  95002. */
  95003. edgesWidthScalerForOrthographic: number;
  95004. /**
  95005. * Define the size of the edges with a perspective camera
  95006. */
  95007. edgesWidthScalerForPerspective: number;
  95008. protected _source: AbstractMesh;
  95009. protected _linesPositions: number[];
  95010. protected _linesNormals: number[];
  95011. protected _linesIndices: number[];
  95012. protected _epsilon: number;
  95013. protected _indicesCount: number;
  95014. protected _lineShader: ShaderMaterial;
  95015. protected _ib: DataBuffer;
  95016. protected _buffers: {
  95017. [key: string]: Nullable<VertexBuffer>;
  95018. };
  95019. protected _buffersForInstances: {
  95020. [key: string]: Nullable<VertexBuffer>;
  95021. };
  95022. protected _checkVerticesInsteadOfIndices: boolean;
  95023. private _meshRebuildObserver;
  95024. private _meshDisposeObserver;
  95025. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  95026. isEnabled: boolean;
  95027. /**
  95028. * List of instances to render in case the source mesh has instances
  95029. */
  95030. customInstances: SmartArray<Matrix>;
  95031. private static GetShader;
  95032. /**
  95033. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  95034. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  95035. * @param source Mesh used to create edges
  95036. * @param epsilon sum of angles in adjacency to check for edge
  95037. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  95038. * @param generateEdgesLines - should generate Lines or only prepare resources.
  95039. */
  95040. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  95041. protected _prepareRessources(): void;
  95042. /** @hidden */
  95043. _rebuild(): void;
  95044. /**
  95045. * Releases the required resources for the edges renderer
  95046. */
  95047. dispose(): void;
  95048. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  95049. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  95050. /**
  95051. * Checks if the pair of p0 and p1 is en edge
  95052. * @param faceIndex
  95053. * @param edge
  95054. * @param faceNormals
  95055. * @param p0
  95056. * @param p1
  95057. * @private
  95058. */
  95059. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  95060. /**
  95061. * push line into the position, normal and index buffer
  95062. * @protected
  95063. */
  95064. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  95065. /**
  95066. * Generates lines edges from adjacencjes
  95067. * @private
  95068. */
  95069. _generateEdgesLines(): void;
  95070. /**
  95071. * Checks wether or not the edges renderer is ready to render.
  95072. * @return true if ready, otherwise false.
  95073. */
  95074. isReady(): boolean;
  95075. /**
  95076. * Renders the edges of the attached mesh,
  95077. */
  95078. render(): void;
  95079. }
  95080. /**
  95081. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  95082. */
  95083. export class LineEdgesRenderer extends EdgesRenderer {
  95084. /**
  95085. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  95086. * @param source LineMesh used to generate edges
  95087. * @param epsilon not important (specified angle for edge detection)
  95088. * @param checkVerticesInsteadOfIndices not important for LineMesh
  95089. */
  95090. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  95091. /**
  95092. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  95093. */
  95094. _generateEdgesLines(): void;
  95095. }
  95096. }
  95097. declare module BABYLON {
  95098. /**
  95099. * This represents the object necessary to create a rendering group.
  95100. * This is exclusively used and created by the rendering manager.
  95101. * To modify the behavior, you use the available helpers in your scene or meshes.
  95102. * @hidden
  95103. */
  95104. export class RenderingGroup {
  95105. index: number;
  95106. private static _zeroVector;
  95107. private _scene;
  95108. private _opaqueSubMeshes;
  95109. private _transparentSubMeshes;
  95110. private _alphaTestSubMeshes;
  95111. private _depthOnlySubMeshes;
  95112. private _particleSystems;
  95113. private _spriteManagers;
  95114. private _opaqueSortCompareFn;
  95115. private _alphaTestSortCompareFn;
  95116. private _transparentSortCompareFn;
  95117. private _renderOpaque;
  95118. private _renderAlphaTest;
  95119. private _renderTransparent;
  95120. /** @hidden */
  95121. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  95122. onBeforeTransparentRendering: () => void;
  95123. /**
  95124. * Set the opaque sort comparison function.
  95125. * If null the sub meshes will be render in the order they were created
  95126. */
  95127. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95128. /**
  95129. * Set the alpha test sort comparison function.
  95130. * If null the sub meshes will be render in the order they were created
  95131. */
  95132. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95133. /**
  95134. * Set the transparent sort comparison function.
  95135. * If null the sub meshes will be render in the order they were created
  95136. */
  95137. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95138. /**
  95139. * Creates a new rendering group.
  95140. * @param index The rendering group index
  95141. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  95142. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  95143. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  95144. */
  95145. 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>);
  95146. /**
  95147. * Render all the sub meshes contained in the group.
  95148. * @param customRenderFunction Used to override the default render behaviour of the group.
  95149. * @returns true if rendered some submeshes.
  95150. */
  95151. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  95152. /**
  95153. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  95154. * @param subMeshes The submeshes to render
  95155. */
  95156. private renderOpaqueSorted;
  95157. /**
  95158. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  95159. * @param subMeshes The submeshes to render
  95160. */
  95161. private renderAlphaTestSorted;
  95162. /**
  95163. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  95164. * @param subMeshes The submeshes to render
  95165. */
  95166. private renderTransparentSorted;
  95167. /**
  95168. * Renders the submeshes in a specified order.
  95169. * @param subMeshes The submeshes to sort before render
  95170. * @param sortCompareFn The comparison function use to sort
  95171. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  95172. * @param transparent Specifies to activate blending if true
  95173. */
  95174. private static renderSorted;
  95175. /**
  95176. * Renders the submeshes in the order they were dispatched (no sort applied).
  95177. * @param subMeshes The submeshes to render
  95178. */
  95179. private static renderUnsorted;
  95180. /**
  95181. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95182. * are rendered back to front if in the same alpha index.
  95183. *
  95184. * @param a The first submesh
  95185. * @param b The second submesh
  95186. * @returns The result of the comparison
  95187. */
  95188. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  95189. /**
  95190. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95191. * are rendered back to front.
  95192. *
  95193. * @param a The first submesh
  95194. * @param b The second submesh
  95195. * @returns The result of the comparison
  95196. */
  95197. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  95198. /**
  95199. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95200. * are rendered front to back (prevent overdraw).
  95201. *
  95202. * @param a The first submesh
  95203. * @param b The second submesh
  95204. * @returns The result of the comparison
  95205. */
  95206. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  95207. /**
  95208. * Resets the different lists of submeshes to prepare a new frame.
  95209. */
  95210. prepare(): void;
  95211. dispose(): void;
  95212. /**
  95213. * Inserts the submesh in its correct queue depending on its material.
  95214. * @param subMesh The submesh to dispatch
  95215. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95216. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95217. */
  95218. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95219. dispatchSprites(spriteManager: ISpriteManager): void;
  95220. dispatchParticles(particleSystem: IParticleSystem): void;
  95221. private _renderParticles;
  95222. private _renderSprites;
  95223. }
  95224. }
  95225. declare module BABYLON {
  95226. /**
  95227. * Interface describing the different options available in the rendering manager
  95228. * regarding Auto Clear between groups.
  95229. */
  95230. export interface IRenderingManagerAutoClearSetup {
  95231. /**
  95232. * Defines whether or not autoclear is enable.
  95233. */
  95234. autoClear: boolean;
  95235. /**
  95236. * Defines whether or not to autoclear the depth buffer.
  95237. */
  95238. depth: boolean;
  95239. /**
  95240. * Defines whether or not to autoclear the stencil buffer.
  95241. */
  95242. stencil: boolean;
  95243. }
  95244. /**
  95245. * This class is used by the onRenderingGroupObservable
  95246. */
  95247. export class RenderingGroupInfo {
  95248. /**
  95249. * The Scene that being rendered
  95250. */
  95251. scene: Scene;
  95252. /**
  95253. * The camera currently used for the rendering pass
  95254. */
  95255. camera: Nullable<Camera>;
  95256. /**
  95257. * The ID of the renderingGroup being processed
  95258. */
  95259. renderingGroupId: number;
  95260. }
  95261. /**
  95262. * This is the manager responsible of all the rendering for meshes sprites and particles.
  95263. * It is enable to manage the different groups as well as the different necessary sort functions.
  95264. * This should not be used directly aside of the few static configurations
  95265. */
  95266. export class RenderingManager {
  95267. /**
  95268. * The max id used for rendering groups (not included)
  95269. */
  95270. static MAX_RENDERINGGROUPS: number;
  95271. /**
  95272. * The min id used for rendering groups (included)
  95273. */
  95274. static MIN_RENDERINGGROUPS: number;
  95275. /**
  95276. * Used to globally prevent autoclearing scenes.
  95277. */
  95278. static AUTOCLEAR: boolean;
  95279. /**
  95280. * @hidden
  95281. */
  95282. _useSceneAutoClearSetup: boolean;
  95283. private _scene;
  95284. private _renderingGroups;
  95285. private _depthStencilBufferAlreadyCleaned;
  95286. private _autoClearDepthStencil;
  95287. private _customOpaqueSortCompareFn;
  95288. private _customAlphaTestSortCompareFn;
  95289. private _customTransparentSortCompareFn;
  95290. private _renderingGroupInfo;
  95291. /**
  95292. * Instantiates a new rendering group for a particular scene
  95293. * @param scene Defines the scene the groups belongs to
  95294. */
  95295. constructor(scene: Scene);
  95296. private _clearDepthStencilBuffer;
  95297. /**
  95298. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  95299. * @hidden
  95300. */
  95301. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  95302. /**
  95303. * Resets the different information of the group to prepare a new frame
  95304. * @hidden
  95305. */
  95306. reset(): void;
  95307. /**
  95308. * Dispose and release the group and its associated resources.
  95309. * @hidden
  95310. */
  95311. dispose(): void;
  95312. /**
  95313. * Clear the info related to rendering groups preventing retention points during dispose.
  95314. */
  95315. freeRenderingGroups(): void;
  95316. private _prepareRenderingGroup;
  95317. /**
  95318. * Add a sprite manager to the rendering manager in order to render it this frame.
  95319. * @param spriteManager Define the sprite manager to render
  95320. */
  95321. dispatchSprites(spriteManager: ISpriteManager): void;
  95322. /**
  95323. * Add a particle system to the rendering manager in order to render it this frame.
  95324. * @param particleSystem Define the particle system to render
  95325. */
  95326. dispatchParticles(particleSystem: IParticleSystem): void;
  95327. /**
  95328. * Add a submesh to the manager in order to render it this frame
  95329. * @param subMesh The submesh to dispatch
  95330. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95331. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95332. */
  95333. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95334. /**
  95335. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95336. * This allowed control for front to back rendering or reversly depending of the special needs.
  95337. *
  95338. * @param renderingGroupId The rendering group id corresponding to its index
  95339. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95340. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95341. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95342. */
  95343. 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;
  95344. /**
  95345. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95346. *
  95347. * @param renderingGroupId The rendering group id corresponding to its index
  95348. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95349. * @param depth Automatically clears depth between groups if true and autoClear is true.
  95350. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  95351. */
  95352. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  95353. /**
  95354. * Gets the current auto clear configuration for one rendering group of the rendering
  95355. * manager.
  95356. * @param index the rendering group index to get the information for
  95357. * @returns The auto clear setup for the requested rendering group
  95358. */
  95359. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  95360. }
  95361. }
  95362. declare module BABYLON {
  95363. /**
  95364. * Defines the options associated with the creation of a custom shader for a shadow generator.
  95365. */
  95366. export interface ICustomShaderOptions {
  95367. /**
  95368. * Gets or sets the custom shader name to use
  95369. */
  95370. shaderName: string;
  95371. /**
  95372. * The list of attribute names used in the shader
  95373. */
  95374. attributes?: string[];
  95375. /**
  95376. * The list of unifrom names used in the shader
  95377. */
  95378. uniforms?: string[];
  95379. /**
  95380. * The list of sampler names used in the shader
  95381. */
  95382. samplers?: string[];
  95383. /**
  95384. * The list of defines used in the shader
  95385. */
  95386. defines?: string[];
  95387. }
  95388. /**
  95389. * Interface to implement to create a shadow generator compatible with BJS.
  95390. */
  95391. export interface IShadowGenerator {
  95392. /**
  95393. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95394. * @returns The render target texture if present otherwise, null
  95395. */
  95396. getShadowMap(): Nullable<RenderTargetTexture>;
  95397. /**
  95398. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95399. * @param subMesh The submesh we want to render in the shadow map
  95400. * @param useInstances Defines wether will draw in the map using instances
  95401. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95402. * @returns true if ready otherwise, false
  95403. */
  95404. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95405. /**
  95406. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95407. * @param defines Defines of the material we want to update
  95408. * @param lightIndex Index of the light in the enabled light list of the material
  95409. */
  95410. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  95411. /**
  95412. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95413. * defined in the generator but impacting the effect).
  95414. * It implies the unifroms available on the materials are the standard BJS ones.
  95415. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95416. * @param effect The effect we are binfing the information for
  95417. */
  95418. bindShadowLight(lightIndex: string, effect: Effect): void;
  95419. /**
  95420. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95421. * (eq to shadow prjection matrix * light transform matrix)
  95422. * @returns The transform matrix used to create the shadow map
  95423. */
  95424. getTransformMatrix(): Matrix;
  95425. /**
  95426. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95427. * Cube and 2D textures for instance.
  95428. */
  95429. recreateShadowMap(): void;
  95430. /**
  95431. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95432. * @param onCompiled Callback triggered at the and of the effects compilation
  95433. * @param options Sets of optional options forcing the compilation with different modes
  95434. */
  95435. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95436. useInstances: boolean;
  95437. }>): void;
  95438. /**
  95439. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95440. * @param options Sets of optional options forcing the compilation with different modes
  95441. * @returns A promise that resolves when the compilation completes
  95442. */
  95443. forceCompilationAsync(options?: Partial<{
  95444. useInstances: boolean;
  95445. }>): Promise<void>;
  95446. /**
  95447. * Serializes the shadow generator setup to a json object.
  95448. * @returns The serialized JSON object
  95449. */
  95450. serialize(): any;
  95451. /**
  95452. * Disposes the Shadow map and related Textures and effects.
  95453. */
  95454. dispose(): void;
  95455. }
  95456. /**
  95457. * Default implementation IShadowGenerator.
  95458. * This is the main object responsible of generating shadows in the framework.
  95459. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  95460. */
  95461. export class ShadowGenerator implements IShadowGenerator {
  95462. /**
  95463. * Name of the shadow generator class
  95464. */
  95465. static CLASSNAME: string;
  95466. /**
  95467. * Shadow generator mode None: no filtering applied.
  95468. */
  95469. static readonly FILTER_NONE: number;
  95470. /**
  95471. * Shadow generator mode ESM: Exponential Shadow Mapping.
  95472. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95473. */
  95474. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  95475. /**
  95476. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  95477. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  95478. */
  95479. static readonly FILTER_POISSONSAMPLING: number;
  95480. /**
  95481. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  95482. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95483. */
  95484. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  95485. /**
  95486. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  95487. * edge artifacts on steep falloff.
  95488. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95489. */
  95490. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  95491. /**
  95492. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  95493. * edge artifacts on steep falloff.
  95494. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95495. */
  95496. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  95497. /**
  95498. * Shadow generator mode PCF: Percentage Closer Filtering
  95499. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95500. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  95501. */
  95502. static readonly FILTER_PCF: number;
  95503. /**
  95504. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  95505. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95506. * Contact Hardening
  95507. */
  95508. static readonly FILTER_PCSS: number;
  95509. /**
  95510. * Reserved for PCF and PCSS
  95511. * Highest Quality.
  95512. *
  95513. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  95514. *
  95515. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  95516. */
  95517. static readonly QUALITY_HIGH: number;
  95518. /**
  95519. * Reserved for PCF and PCSS
  95520. * Good tradeoff for quality/perf cross devices
  95521. *
  95522. * Execute PCF on a 3*3 kernel.
  95523. *
  95524. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  95525. */
  95526. static readonly QUALITY_MEDIUM: number;
  95527. /**
  95528. * Reserved for PCF and PCSS
  95529. * The lowest quality but the fastest.
  95530. *
  95531. * Execute PCF on a 1*1 kernel.
  95532. *
  95533. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  95534. */
  95535. static readonly QUALITY_LOW: number;
  95536. /** Gets or sets the custom shader name to use */
  95537. customShaderOptions: ICustomShaderOptions;
  95538. /**
  95539. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  95540. */
  95541. onBeforeShadowMapRenderObservable: Observable<Effect>;
  95542. /**
  95543. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  95544. */
  95545. onAfterShadowMapRenderObservable: Observable<Effect>;
  95546. /**
  95547. * Observable triggered before a mesh is rendered in the shadow map.
  95548. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  95549. */
  95550. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  95551. /**
  95552. * Observable triggered after a mesh is rendered in the shadow map.
  95553. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  95554. */
  95555. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  95556. protected _bias: number;
  95557. /**
  95558. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  95559. */
  95560. get bias(): number;
  95561. /**
  95562. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  95563. */
  95564. set bias(bias: number);
  95565. protected _normalBias: number;
  95566. /**
  95567. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95568. */
  95569. get normalBias(): number;
  95570. /**
  95571. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95572. */
  95573. set normalBias(normalBias: number);
  95574. protected _blurBoxOffset: number;
  95575. /**
  95576. * Gets the blur box offset: offset applied during the blur pass.
  95577. * Only useful if useKernelBlur = false
  95578. */
  95579. get blurBoxOffset(): number;
  95580. /**
  95581. * Sets the blur box offset: offset applied during the blur pass.
  95582. * Only useful if useKernelBlur = false
  95583. */
  95584. set blurBoxOffset(value: number);
  95585. protected _blurScale: number;
  95586. /**
  95587. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  95588. * 2 means half of the size.
  95589. */
  95590. get blurScale(): number;
  95591. /**
  95592. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  95593. * 2 means half of the size.
  95594. */
  95595. set blurScale(value: number);
  95596. protected _blurKernel: number;
  95597. /**
  95598. * Gets the blur kernel: kernel size of the blur pass.
  95599. * Only useful if useKernelBlur = true
  95600. */
  95601. get blurKernel(): number;
  95602. /**
  95603. * Sets the blur kernel: kernel size of the blur pass.
  95604. * Only useful if useKernelBlur = true
  95605. */
  95606. set blurKernel(value: number);
  95607. protected _useKernelBlur: boolean;
  95608. /**
  95609. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  95610. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95611. */
  95612. get useKernelBlur(): boolean;
  95613. /**
  95614. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  95615. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95616. */
  95617. set useKernelBlur(value: boolean);
  95618. protected _depthScale: number;
  95619. /**
  95620. * Gets the depth scale used in ESM mode.
  95621. */
  95622. get depthScale(): number;
  95623. /**
  95624. * Sets the depth scale used in ESM mode.
  95625. * This can override the scale stored on the light.
  95626. */
  95627. set depthScale(value: number);
  95628. protected _validateFilter(filter: number): number;
  95629. protected _filter: number;
  95630. /**
  95631. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  95632. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95633. */
  95634. get filter(): number;
  95635. /**
  95636. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  95637. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95638. */
  95639. set filter(value: number);
  95640. /**
  95641. * Gets if the current filter is set to Poisson Sampling.
  95642. */
  95643. get usePoissonSampling(): boolean;
  95644. /**
  95645. * Sets the current filter to Poisson Sampling.
  95646. */
  95647. set usePoissonSampling(value: boolean);
  95648. /**
  95649. * Gets if the current filter is set to ESM.
  95650. */
  95651. get useExponentialShadowMap(): boolean;
  95652. /**
  95653. * Sets the current filter is to ESM.
  95654. */
  95655. set useExponentialShadowMap(value: boolean);
  95656. /**
  95657. * Gets if the current filter is set to filtered ESM.
  95658. */
  95659. get useBlurExponentialShadowMap(): boolean;
  95660. /**
  95661. * Gets if the current filter is set to filtered ESM.
  95662. */
  95663. set useBlurExponentialShadowMap(value: boolean);
  95664. /**
  95665. * Gets if the current filter is set to "close ESM" (using the inverse of the
  95666. * exponential to prevent steep falloff artifacts).
  95667. */
  95668. get useCloseExponentialShadowMap(): boolean;
  95669. /**
  95670. * Sets the current filter to "close ESM" (using the inverse of the
  95671. * exponential to prevent steep falloff artifacts).
  95672. */
  95673. set useCloseExponentialShadowMap(value: boolean);
  95674. /**
  95675. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  95676. * exponential to prevent steep falloff artifacts).
  95677. */
  95678. get useBlurCloseExponentialShadowMap(): boolean;
  95679. /**
  95680. * Sets the current filter to filtered "close ESM" (using the inverse of the
  95681. * exponential to prevent steep falloff artifacts).
  95682. */
  95683. set useBlurCloseExponentialShadowMap(value: boolean);
  95684. /**
  95685. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  95686. */
  95687. get usePercentageCloserFiltering(): boolean;
  95688. /**
  95689. * Sets the current filter to "PCF" (percentage closer filtering).
  95690. */
  95691. set usePercentageCloserFiltering(value: boolean);
  95692. protected _filteringQuality: number;
  95693. /**
  95694. * Gets the PCF or PCSS Quality.
  95695. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95696. */
  95697. get filteringQuality(): number;
  95698. /**
  95699. * Sets the PCF or PCSS Quality.
  95700. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95701. */
  95702. set filteringQuality(filteringQuality: number);
  95703. /**
  95704. * Gets if the current filter is set to "PCSS" (contact hardening).
  95705. */
  95706. get useContactHardeningShadow(): boolean;
  95707. /**
  95708. * Sets the current filter to "PCSS" (contact hardening).
  95709. */
  95710. set useContactHardeningShadow(value: boolean);
  95711. protected _contactHardeningLightSizeUVRatio: number;
  95712. /**
  95713. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95714. * Using a ratio helps keeping shape stability independently of the map size.
  95715. *
  95716. * It does not account for the light projection as it was having too much
  95717. * instability during the light setup or during light position changes.
  95718. *
  95719. * Only valid if useContactHardeningShadow is true.
  95720. */
  95721. get contactHardeningLightSizeUVRatio(): number;
  95722. /**
  95723. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95724. * Using a ratio helps keeping shape stability independently of the map size.
  95725. *
  95726. * It does not account for the light projection as it was having too much
  95727. * instability during the light setup or during light position changes.
  95728. *
  95729. * Only valid if useContactHardeningShadow is true.
  95730. */
  95731. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  95732. protected _darkness: number;
  95733. /** Gets or sets the actual darkness of a shadow */
  95734. get darkness(): number;
  95735. set darkness(value: number);
  95736. /**
  95737. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  95738. * 0 means strongest and 1 would means no shadow.
  95739. * @returns the darkness.
  95740. */
  95741. getDarkness(): number;
  95742. /**
  95743. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  95744. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  95745. * @returns the shadow generator allowing fluent coding.
  95746. */
  95747. setDarkness(darkness: number): ShadowGenerator;
  95748. protected _transparencyShadow: boolean;
  95749. /** Gets or sets the ability to have transparent shadow */
  95750. get transparencyShadow(): boolean;
  95751. set transparencyShadow(value: boolean);
  95752. /**
  95753. * Sets the ability to have transparent shadow (boolean).
  95754. * @param transparent True if transparent else False
  95755. * @returns the shadow generator allowing fluent coding
  95756. */
  95757. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  95758. /**
  95759. * Enables or disables shadows with varying strength based on the transparency
  95760. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  95761. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  95762. * mesh.visibility * alphaTexture.a
  95763. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  95764. */
  95765. enableSoftTransparentShadow: boolean;
  95766. protected _shadowMap: Nullable<RenderTargetTexture>;
  95767. protected _shadowMap2: Nullable<RenderTargetTexture>;
  95768. /**
  95769. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95770. * @returns The render target texture if present otherwise, null
  95771. */
  95772. getShadowMap(): Nullable<RenderTargetTexture>;
  95773. /**
  95774. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  95775. * @returns The render target texture if the shadow map is present otherwise, null
  95776. */
  95777. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  95778. /**
  95779. * Gets the class name of that object
  95780. * @returns "ShadowGenerator"
  95781. */
  95782. getClassName(): string;
  95783. /**
  95784. * Helper function to add a mesh and its descendants to the list of shadow casters.
  95785. * @param mesh Mesh to add
  95786. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  95787. * @returns the Shadow Generator itself
  95788. */
  95789. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95790. /**
  95791. * Helper function to remove a mesh and its descendants from the list of shadow casters
  95792. * @param mesh Mesh to remove
  95793. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  95794. * @returns the Shadow Generator itself
  95795. */
  95796. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95797. /**
  95798. * Controls the extent to which the shadows fade out at the edge of the frustum
  95799. */
  95800. frustumEdgeFalloff: number;
  95801. protected _light: IShadowLight;
  95802. /**
  95803. * Returns the associated light object.
  95804. * @returns the light generating the shadow
  95805. */
  95806. getLight(): IShadowLight;
  95807. /**
  95808. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  95809. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  95810. * It might on the other hand introduce peter panning.
  95811. */
  95812. forceBackFacesOnly: boolean;
  95813. protected _scene: Scene;
  95814. protected _lightDirection: Vector3;
  95815. protected _effect: Effect;
  95816. protected _viewMatrix: Matrix;
  95817. protected _projectionMatrix: Matrix;
  95818. protected _transformMatrix: Matrix;
  95819. protected _cachedPosition: Vector3;
  95820. protected _cachedDirection: Vector3;
  95821. protected _cachedDefines: string;
  95822. protected _currentRenderID: number;
  95823. protected _boxBlurPostprocess: Nullable<PostProcess>;
  95824. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  95825. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  95826. protected _blurPostProcesses: PostProcess[];
  95827. protected _mapSize: number;
  95828. protected _currentFaceIndex: number;
  95829. protected _currentFaceIndexCache: number;
  95830. protected _textureType: number;
  95831. protected _defaultTextureMatrix: Matrix;
  95832. protected _storedUniqueId: Nullable<number>;
  95833. /** @hidden */
  95834. static _SceneComponentInitialization: (scene: Scene) => void;
  95835. /**
  95836. * Creates a ShadowGenerator object.
  95837. * A ShadowGenerator is the required tool to use the shadows.
  95838. * Each light casting shadows needs to use its own ShadowGenerator.
  95839. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  95840. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  95841. * @param light The light object generating the shadows.
  95842. * @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.
  95843. */
  95844. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  95845. protected _initializeGenerator(): void;
  95846. protected _createTargetRenderTexture(): void;
  95847. protected _initializeShadowMap(): void;
  95848. protected _initializeBlurRTTAndPostProcesses(): void;
  95849. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  95850. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  95851. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  95852. protected _applyFilterValues(): void;
  95853. /**
  95854. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95855. * @param onCompiled Callback triggered at the and of the effects compilation
  95856. * @param options Sets of optional options forcing the compilation with different modes
  95857. */
  95858. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95859. useInstances: boolean;
  95860. }>): void;
  95861. /**
  95862. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95863. * @param options Sets of optional options forcing the compilation with different modes
  95864. * @returns A promise that resolves when the compilation completes
  95865. */
  95866. forceCompilationAsync(options?: Partial<{
  95867. useInstances: boolean;
  95868. }>): Promise<void>;
  95869. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  95870. private _prepareShadowDefines;
  95871. /**
  95872. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95873. * @param subMesh The submesh we want to render in the shadow map
  95874. * @param useInstances Defines wether will draw in the map using instances
  95875. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95876. * @returns true if ready otherwise, false
  95877. */
  95878. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95879. /**
  95880. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95881. * @param defines Defines of the material we want to update
  95882. * @param lightIndex Index of the light in the enabled light list of the material
  95883. */
  95884. prepareDefines(defines: any, lightIndex: number): void;
  95885. /**
  95886. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95887. * defined in the generator but impacting the effect).
  95888. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95889. * @param effect The effect we are binfing the information for
  95890. */
  95891. bindShadowLight(lightIndex: string, effect: Effect): void;
  95892. /**
  95893. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95894. * (eq to shadow prjection matrix * light transform matrix)
  95895. * @returns The transform matrix used to create the shadow map
  95896. */
  95897. getTransformMatrix(): Matrix;
  95898. /**
  95899. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95900. * Cube and 2D textures for instance.
  95901. */
  95902. recreateShadowMap(): void;
  95903. protected _disposeBlurPostProcesses(): void;
  95904. protected _disposeRTTandPostProcesses(): void;
  95905. /**
  95906. * Disposes the ShadowGenerator.
  95907. * Returns nothing.
  95908. */
  95909. dispose(): void;
  95910. /**
  95911. * Serializes the shadow generator setup to a json object.
  95912. * @returns The serialized JSON object
  95913. */
  95914. serialize(): any;
  95915. /**
  95916. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  95917. * @param parsedShadowGenerator The JSON object to parse
  95918. * @param scene The scene to create the shadow map for
  95919. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  95920. * @returns The parsed shadow generator
  95921. */
  95922. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  95923. }
  95924. }
  95925. declare module BABYLON {
  95926. /**
  95927. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  95928. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  95929. * 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.
  95930. */
  95931. export abstract class Light extends Node {
  95932. /**
  95933. * Falloff Default: light is falling off following the material specification:
  95934. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  95935. */
  95936. static readonly FALLOFF_DEFAULT: number;
  95937. /**
  95938. * Falloff Physical: light is falling off following the inverse squared distance law.
  95939. */
  95940. static readonly FALLOFF_PHYSICAL: number;
  95941. /**
  95942. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  95943. * to enhance interoperability with other engines.
  95944. */
  95945. static readonly FALLOFF_GLTF: number;
  95946. /**
  95947. * Falloff Standard: light is falling off like in the standard material
  95948. * to enhance interoperability with other materials.
  95949. */
  95950. static readonly FALLOFF_STANDARD: number;
  95951. /**
  95952. * If every light affecting the material is in this lightmapMode,
  95953. * material.lightmapTexture adds or multiplies
  95954. * (depends on material.useLightmapAsShadowmap)
  95955. * after every other light calculations.
  95956. */
  95957. static readonly LIGHTMAP_DEFAULT: number;
  95958. /**
  95959. * material.lightmapTexture as only diffuse lighting from this light
  95960. * adds only specular lighting from this light
  95961. * adds dynamic shadows
  95962. */
  95963. static readonly LIGHTMAP_SPECULAR: number;
  95964. /**
  95965. * material.lightmapTexture as only lighting
  95966. * no light calculation from this light
  95967. * only adds dynamic shadows from this light
  95968. */
  95969. static readonly LIGHTMAP_SHADOWSONLY: number;
  95970. /**
  95971. * Each light type uses the default quantity according to its type:
  95972. * point/spot lights use luminous intensity
  95973. * directional lights use illuminance
  95974. */
  95975. static readonly INTENSITYMODE_AUTOMATIC: number;
  95976. /**
  95977. * lumen (lm)
  95978. */
  95979. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  95980. /**
  95981. * candela (lm/sr)
  95982. */
  95983. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  95984. /**
  95985. * lux (lm/m^2)
  95986. */
  95987. static readonly INTENSITYMODE_ILLUMINANCE: number;
  95988. /**
  95989. * nit (cd/m^2)
  95990. */
  95991. static readonly INTENSITYMODE_LUMINANCE: number;
  95992. /**
  95993. * Light type const id of the point light.
  95994. */
  95995. static readonly LIGHTTYPEID_POINTLIGHT: number;
  95996. /**
  95997. * Light type const id of the directional light.
  95998. */
  95999. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  96000. /**
  96001. * Light type const id of the spot light.
  96002. */
  96003. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  96004. /**
  96005. * Light type const id of the hemispheric light.
  96006. */
  96007. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  96008. /**
  96009. * Diffuse gives the basic color to an object.
  96010. */
  96011. diffuse: Color3;
  96012. /**
  96013. * Specular produces a highlight color on an object.
  96014. * Note: This is note affecting PBR materials.
  96015. */
  96016. specular: Color3;
  96017. /**
  96018. * Defines the falloff type for this light. This lets overrriding how punctual light are
  96019. * falling off base on range or angle.
  96020. * This can be set to any values in Light.FALLOFF_x.
  96021. *
  96022. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  96023. * other types of materials.
  96024. */
  96025. falloffType: number;
  96026. /**
  96027. * Strength of the light.
  96028. * Note: By default it is define in the framework own unit.
  96029. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  96030. */
  96031. intensity: number;
  96032. private _range;
  96033. protected _inverseSquaredRange: number;
  96034. /**
  96035. * Defines how far from the source the light is impacting in scene units.
  96036. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96037. */
  96038. get range(): number;
  96039. /**
  96040. * Defines how far from the source the light is impacting in scene units.
  96041. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96042. */
  96043. set range(value: number);
  96044. /**
  96045. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  96046. * of light.
  96047. */
  96048. private _photometricScale;
  96049. private _intensityMode;
  96050. /**
  96051. * Gets the photometric scale used to interpret the intensity.
  96052. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96053. */
  96054. get intensityMode(): number;
  96055. /**
  96056. * Sets the photometric scale used to interpret the intensity.
  96057. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96058. */
  96059. set intensityMode(value: number);
  96060. private _radius;
  96061. /**
  96062. * Gets the light radius used by PBR Materials to simulate soft area lights.
  96063. */
  96064. get radius(): number;
  96065. /**
  96066. * sets the light radius used by PBR Materials to simulate soft area lights.
  96067. */
  96068. set radius(value: number);
  96069. private _renderPriority;
  96070. /**
  96071. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  96072. * exceeding the number allowed of the materials.
  96073. */
  96074. renderPriority: number;
  96075. private _shadowEnabled;
  96076. /**
  96077. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96078. * the current shadow generator.
  96079. */
  96080. get shadowEnabled(): boolean;
  96081. /**
  96082. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96083. * the current shadow generator.
  96084. */
  96085. set shadowEnabled(value: boolean);
  96086. private _includedOnlyMeshes;
  96087. /**
  96088. * Gets the only meshes impacted by this light.
  96089. */
  96090. get includedOnlyMeshes(): AbstractMesh[];
  96091. /**
  96092. * Sets the only meshes impacted by this light.
  96093. */
  96094. set includedOnlyMeshes(value: AbstractMesh[]);
  96095. private _excludedMeshes;
  96096. /**
  96097. * Gets the meshes not impacted by this light.
  96098. */
  96099. get excludedMeshes(): AbstractMesh[];
  96100. /**
  96101. * Sets the meshes not impacted by this light.
  96102. */
  96103. set excludedMeshes(value: AbstractMesh[]);
  96104. private _excludeWithLayerMask;
  96105. /**
  96106. * Gets the layer id use to find what meshes are not impacted by the light.
  96107. * Inactive if 0
  96108. */
  96109. get excludeWithLayerMask(): number;
  96110. /**
  96111. * Sets the layer id use to find what meshes are not impacted by the light.
  96112. * Inactive if 0
  96113. */
  96114. set excludeWithLayerMask(value: number);
  96115. private _includeOnlyWithLayerMask;
  96116. /**
  96117. * Gets the layer id use to find what meshes are impacted by the light.
  96118. * Inactive if 0
  96119. */
  96120. get includeOnlyWithLayerMask(): number;
  96121. /**
  96122. * Sets the layer id use to find what meshes are impacted by the light.
  96123. * Inactive if 0
  96124. */
  96125. set includeOnlyWithLayerMask(value: number);
  96126. private _lightmapMode;
  96127. /**
  96128. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96129. */
  96130. get lightmapMode(): number;
  96131. /**
  96132. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96133. */
  96134. set lightmapMode(value: number);
  96135. /**
  96136. * Shadow generator associted to the light.
  96137. * @hidden Internal use only.
  96138. */
  96139. _shadowGenerator: Nullable<IShadowGenerator>;
  96140. /**
  96141. * @hidden Internal use only.
  96142. */
  96143. _excludedMeshesIds: string[];
  96144. /**
  96145. * @hidden Internal use only.
  96146. */
  96147. _includedOnlyMeshesIds: string[];
  96148. /**
  96149. * The current light unifom buffer.
  96150. * @hidden Internal use only.
  96151. */
  96152. _uniformBuffer: UniformBuffer;
  96153. /** @hidden */
  96154. _renderId: number;
  96155. /**
  96156. * Creates a Light object in the scene.
  96157. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96158. * @param name The firendly name of the light
  96159. * @param scene The scene the light belongs too
  96160. */
  96161. constructor(name: string, scene: Scene);
  96162. protected abstract _buildUniformLayout(): void;
  96163. /**
  96164. * Sets the passed Effect "effect" with the Light information.
  96165. * @param effect The effect to update
  96166. * @param lightIndex The index of the light in the effect to update
  96167. * @returns The light
  96168. */
  96169. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  96170. /**
  96171. * Sets the passed Effect "effect" with the Light textures.
  96172. * @param effect The effect to update
  96173. * @param lightIndex The index of the light in the effect to update
  96174. * @returns The light
  96175. */
  96176. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  96177. /**
  96178. * Binds the lights information from the scene to the effect for the given mesh.
  96179. * @param lightIndex Light index
  96180. * @param scene The scene where the light belongs to
  96181. * @param effect The effect we are binding the data to
  96182. * @param useSpecular Defines if specular is supported
  96183. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  96184. */
  96185. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  96186. /**
  96187. * Sets the passed Effect "effect" with the Light information.
  96188. * @param effect The effect to update
  96189. * @param lightDataUniformName The uniform used to store light data (position or direction)
  96190. * @returns The light
  96191. */
  96192. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  96193. /**
  96194. * Returns the string "Light".
  96195. * @returns the class name
  96196. */
  96197. getClassName(): string;
  96198. /** @hidden */
  96199. readonly _isLight: boolean;
  96200. /**
  96201. * Converts the light information to a readable string for debug purpose.
  96202. * @param fullDetails Supports for multiple levels of logging within scene loading
  96203. * @returns the human readable light info
  96204. */
  96205. toString(fullDetails?: boolean): string;
  96206. /** @hidden */
  96207. protected _syncParentEnabledState(): void;
  96208. /**
  96209. * Set the enabled state of this node.
  96210. * @param value - the new enabled state
  96211. */
  96212. setEnabled(value: boolean): void;
  96213. /**
  96214. * Returns the Light associated shadow generator if any.
  96215. * @return the associated shadow generator.
  96216. */
  96217. getShadowGenerator(): Nullable<IShadowGenerator>;
  96218. /**
  96219. * Returns a Vector3, the absolute light position in the World.
  96220. * @returns the world space position of the light
  96221. */
  96222. getAbsolutePosition(): Vector3;
  96223. /**
  96224. * Specifies if the light will affect the passed mesh.
  96225. * @param mesh The mesh to test against the light
  96226. * @return true the mesh is affected otherwise, false.
  96227. */
  96228. canAffectMesh(mesh: AbstractMesh): boolean;
  96229. /**
  96230. * Sort function to order lights for rendering.
  96231. * @param a First Light object to compare to second.
  96232. * @param b Second Light object to compare first.
  96233. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  96234. */
  96235. static CompareLightsPriority(a: Light, b: Light): number;
  96236. /**
  96237. * Releases resources associated with this node.
  96238. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96239. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96240. */
  96241. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96242. /**
  96243. * Returns the light type ID (integer).
  96244. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96245. */
  96246. getTypeID(): number;
  96247. /**
  96248. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  96249. * @returns the scaled intensity in intensity mode unit
  96250. */
  96251. getScaledIntensity(): number;
  96252. /**
  96253. * Returns a new Light object, named "name", from the current one.
  96254. * @param name The name of the cloned light
  96255. * @param newParent The parent of this light, if it has one
  96256. * @returns the new created light
  96257. */
  96258. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  96259. /**
  96260. * Serializes the current light into a Serialization object.
  96261. * @returns the serialized object.
  96262. */
  96263. serialize(): any;
  96264. /**
  96265. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  96266. * This new light is named "name" and added to the passed scene.
  96267. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  96268. * @param name The friendly name of the light
  96269. * @param scene The scene the new light will belong to
  96270. * @returns the constructor function
  96271. */
  96272. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  96273. /**
  96274. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  96275. * @param parsedLight The JSON representation of the light
  96276. * @param scene The scene to create the parsed light in
  96277. * @returns the created light after parsing
  96278. */
  96279. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  96280. private _hookArrayForExcluded;
  96281. private _hookArrayForIncludedOnly;
  96282. private _resyncMeshes;
  96283. /**
  96284. * Forces the meshes to update their light related information in their rendering used effects
  96285. * @hidden Internal Use Only
  96286. */
  96287. _markMeshesAsLightDirty(): void;
  96288. /**
  96289. * Recomputes the cached photometric scale if needed.
  96290. */
  96291. private _computePhotometricScale;
  96292. /**
  96293. * Returns the Photometric Scale according to the light type and intensity mode.
  96294. */
  96295. private _getPhotometricScale;
  96296. /**
  96297. * Reorder the light in the scene according to their defined priority.
  96298. * @hidden Internal Use Only
  96299. */
  96300. _reorderLightsInScene(): void;
  96301. /**
  96302. * Prepares the list of defines specific to the light type.
  96303. * @param defines the list of defines
  96304. * @param lightIndex defines the index of the light for the effect
  96305. */
  96306. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96307. }
  96308. }
  96309. declare module BABYLON {
  96310. /**
  96311. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  96312. * This is the base of the follow, arc rotate cameras and Free camera
  96313. * @see https://doc.babylonjs.com/features/cameras
  96314. */
  96315. export class TargetCamera extends Camera {
  96316. private static _RigCamTransformMatrix;
  96317. private static _TargetTransformMatrix;
  96318. private static _TargetFocalPoint;
  96319. private _tmpUpVector;
  96320. private _tmpTargetVector;
  96321. /**
  96322. * Define the current direction the camera is moving to
  96323. */
  96324. cameraDirection: Vector3;
  96325. /**
  96326. * Define the current rotation the camera is rotating to
  96327. */
  96328. cameraRotation: Vector2;
  96329. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  96330. ignoreParentScaling: boolean;
  96331. /**
  96332. * When set, the up vector of the camera will be updated by the rotation of the camera
  96333. */
  96334. updateUpVectorFromRotation: boolean;
  96335. private _tmpQuaternion;
  96336. /**
  96337. * Define the current rotation of the camera
  96338. */
  96339. rotation: Vector3;
  96340. /**
  96341. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  96342. */
  96343. rotationQuaternion: Quaternion;
  96344. /**
  96345. * Define the current speed of the camera
  96346. */
  96347. speed: number;
  96348. /**
  96349. * Add constraint to the camera to prevent it to move freely in all directions and
  96350. * around all axis.
  96351. */
  96352. noRotationConstraint: boolean;
  96353. /**
  96354. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  96355. * panning
  96356. */
  96357. invertRotation: boolean;
  96358. /**
  96359. * Speed multiplier for inverse camera panning
  96360. */
  96361. inverseRotationSpeed: number;
  96362. /**
  96363. * Define the current target of the camera as an object or a position.
  96364. */
  96365. lockedTarget: any;
  96366. /** @hidden */
  96367. _currentTarget: Vector3;
  96368. /** @hidden */
  96369. _initialFocalDistance: number;
  96370. /** @hidden */
  96371. _viewMatrix: Matrix;
  96372. /** @hidden */
  96373. _camMatrix: Matrix;
  96374. /** @hidden */
  96375. _cameraTransformMatrix: Matrix;
  96376. /** @hidden */
  96377. _cameraRotationMatrix: Matrix;
  96378. /** @hidden */
  96379. _referencePoint: Vector3;
  96380. /** @hidden */
  96381. _transformedReferencePoint: Vector3;
  96382. /** @hidden */
  96383. _reset: () => void;
  96384. private _defaultUp;
  96385. /**
  96386. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  96387. * This is the base of the follow, arc rotate cameras and Free camera
  96388. * @see https://doc.babylonjs.com/features/cameras
  96389. * @param name Defines the name of the camera in the scene
  96390. * @param position Defines the start position of the camera in the scene
  96391. * @param scene Defines the scene the camera belongs to
  96392. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96393. */
  96394. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96395. /**
  96396. * Gets the position in front of the camera at a given distance.
  96397. * @param distance The distance from the camera we want the position to be
  96398. * @returns the position
  96399. */
  96400. getFrontPosition(distance: number): Vector3;
  96401. /** @hidden */
  96402. _getLockedTargetPosition(): Nullable<Vector3>;
  96403. private _storedPosition;
  96404. private _storedRotation;
  96405. private _storedRotationQuaternion;
  96406. /**
  96407. * Store current camera state of the camera (fov, position, rotation, etc..)
  96408. * @returns the camera
  96409. */
  96410. storeState(): Camera;
  96411. /**
  96412. * Restored camera state. You must call storeState() first
  96413. * @returns whether it was successful or not
  96414. * @hidden
  96415. */
  96416. _restoreStateValues(): boolean;
  96417. /** @hidden */
  96418. _initCache(): void;
  96419. /** @hidden */
  96420. _updateCache(ignoreParentClass?: boolean): void;
  96421. /** @hidden */
  96422. _isSynchronizedViewMatrix(): boolean;
  96423. /** @hidden */
  96424. _computeLocalCameraSpeed(): number;
  96425. /**
  96426. * Defines the target the camera should look at.
  96427. * @param target Defines the new target as a Vector or a mesh
  96428. */
  96429. setTarget(target: Vector3): void;
  96430. /**
  96431. * Return the current target position of the camera. This value is expressed in local space.
  96432. * @returns the target position
  96433. */
  96434. getTarget(): Vector3;
  96435. /** @hidden */
  96436. _decideIfNeedsToMove(): boolean;
  96437. /** @hidden */
  96438. _updatePosition(): void;
  96439. /** @hidden */
  96440. _checkInputs(): void;
  96441. protected _updateCameraRotationMatrix(): void;
  96442. /**
  96443. * 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)
  96444. * @returns the current camera
  96445. */
  96446. private _rotateUpVectorWithCameraRotationMatrix;
  96447. private _cachedRotationZ;
  96448. private _cachedQuaternionRotationZ;
  96449. /** @hidden */
  96450. _getViewMatrix(): Matrix;
  96451. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  96452. /**
  96453. * @hidden
  96454. */
  96455. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96456. /**
  96457. * @hidden
  96458. */
  96459. _updateRigCameras(): void;
  96460. private _getRigCamPositionAndTarget;
  96461. /**
  96462. * Gets the current object class name.
  96463. * @return the class name
  96464. */
  96465. getClassName(): string;
  96466. }
  96467. }
  96468. declare module BABYLON {
  96469. /**
  96470. * Gather the list of keyboard event types as constants.
  96471. */
  96472. export class KeyboardEventTypes {
  96473. /**
  96474. * The keydown event is fired when a key becomes active (pressed).
  96475. */
  96476. static readonly KEYDOWN: number;
  96477. /**
  96478. * The keyup event is fired when a key has been released.
  96479. */
  96480. static readonly KEYUP: number;
  96481. }
  96482. /**
  96483. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96484. */
  96485. export class KeyboardInfo {
  96486. /**
  96487. * Defines the type of event (KeyboardEventTypes)
  96488. */
  96489. type: number;
  96490. /**
  96491. * Defines the related dom event
  96492. */
  96493. event: KeyboardEvent;
  96494. /**
  96495. * Instantiates a new keyboard info.
  96496. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96497. * @param type Defines the type of event (KeyboardEventTypes)
  96498. * @param event Defines the related dom event
  96499. */
  96500. constructor(
  96501. /**
  96502. * Defines the type of event (KeyboardEventTypes)
  96503. */
  96504. type: number,
  96505. /**
  96506. * Defines the related dom event
  96507. */
  96508. event: KeyboardEvent);
  96509. }
  96510. /**
  96511. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96512. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  96513. */
  96514. export class KeyboardInfoPre extends KeyboardInfo {
  96515. /**
  96516. * Defines the type of event (KeyboardEventTypes)
  96517. */
  96518. type: number;
  96519. /**
  96520. * Defines the related dom event
  96521. */
  96522. event: KeyboardEvent;
  96523. /**
  96524. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  96525. */
  96526. skipOnPointerObservable: boolean;
  96527. /**
  96528. * Instantiates a new keyboard pre info.
  96529. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96530. * @param type Defines the type of event (KeyboardEventTypes)
  96531. * @param event Defines the related dom event
  96532. */
  96533. constructor(
  96534. /**
  96535. * Defines the type of event (KeyboardEventTypes)
  96536. */
  96537. type: number,
  96538. /**
  96539. * Defines the related dom event
  96540. */
  96541. event: KeyboardEvent);
  96542. }
  96543. }
  96544. declare module BABYLON {
  96545. /**
  96546. * Manage the keyboard inputs to control the movement of a free camera.
  96547. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96548. */
  96549. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  96550. /**
  96551. * Defines the camera the input is attached to.
  96552. */
  96553. camera: FreeCamera;
  96554. /**
  96555. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96556. */
  96557. keysUp: number[];
  96558. /**
  96559. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96560. */
  96561. keysUpward: number[];
  96562. /**
  96563. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96564. */
  96565. keysDown: number[];
  96566. /**
  96567. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96568. */
  96569. keysDownward: number[];
  96570. /**
  96571. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96572. */
  96573. keysLeft: number[];
  96574. /**
  96575. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96576. */
  96577. keysRight: number[];
  96578. private _keys;
  96579. private _onCanvasBlurObserver;
  96580. private _onKeyboardObserver;
  96581. private _engine;
  96582. private _scene;
  96583. /**
  96584. * Attach the input controls to a specific dom element to get the input from.
  96585. * @param element Defines the element the controls should be listened from
  96586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96587. */
  96588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96589. /**
  96590. * Detach the current controls from the specified dom element.
  96591. * @param element Defines the element to stop listening the inputs from
  96592. */
  96593. detachControl(element: Nullable<HTMLElement>): void;
  96594. /**
  96595. * Update the current camera state depending on the inputs that have been used this frame.
  96596. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96597. */
  96598. checkInputs(): void;
  96599. /**
  96600. * Gets the class name of the current intput.
  96601. * @returns the class name
  96602. */
  96603. getClassName(): string;
  96604. /** @hidden */
  96605. _onLostFocus(): void;
  96606. /**
  96607. * Get the friendly name associated with the input class.
  96608. * @returns the input friendly name
  96609. */
  96610. getSimpleName(): string;
  96611. }
  96612. }
  96613. declare module BABYLON {
  96614. /**
  96615. * Gather the list of pointer event types as constants.
  96616. */
  96617. export class PointerEventTypes {
  96618. /**
  96619. * 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.
  96620. */
  96621. static readonly POINTERDOWN: number;
  96622. /**
  96623. * The pointerup event is fired when a pointer is no longer active.
  96624. */
  96625. static readonly POINTERUP: number;
  96626. /**
  96627. * The pointermove event is fired when a pointer changes coordinates.
  96628. */
  96629. static readonly POINTERMOVE: number;
  96630. /**
  96631. * The pointerwheel event is fired when a mouse wheel has been rotated.
  96632. */
  96633. static readonly POINTERWHEEL: number;
  96634. /**
  96635. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  96636. */
  96637. static readonly POINTERPICK: number;
  96638. /**
  96639. * The pointertap event is fired when a the object has been touched and released without drag.
  96640. */
  96641. static readonly POINTERTAP: number;
  96642. /**
  96643. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  96644. */
  96645. static readonly POINTERDOUBLETAP: number;
  96646. }
  96647. /**
  96648. * Base class of pointer info types.
  96649. */
  96650. export class PointerInfoBase {
  96651. /**
  96652. * Defines the type of event (PointerEventTypes)
  96653. */
  96654. type: number;
  96655. /**
  96656. * Defines the related dom event
  96657. */
  96658. event: PointerEvent | MouseWheelEvent;
  96659. /**
  96660. * Instantiates the base class of pointers info.
  96661. * @param type Defines the type of event (PointerEventTypes)
  96662. * @param event Defines the related dom event
  96663. */
  96664. constructor(
  96665. /**
  96666. * Defines the type of event (PointerEventTypes)
  96667. */
  96668. type: number,
  96669. /**
  96670. * Defines the related dom event
  96671. */
  96672. event: PointerEvent | MouseWheelEvent);
  96673. }
  96674. /**
  96675. * This class is used to store pointer related info for the onPrePointerObservable event.
  96676. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  96677. */
  96678. export class PointerInfoPre extends PointerInfoBase {
  96679. /**
  96680. * Ray from a pointer if availible (eg. 6dof controller)
  96681. */
  96682. ray: Nullable<Ray>;
  96683. /**
  96684. * Defines the local position of the pointer on the canvas.
  96685. */
  96686. localPosition: Vector2;
  96687. /**
  96688. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  96689. */
  96690. skipOnPointerObservable: boolean;
  96691. /**
  96692. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  96693. * @param type Defines the type of event (PointerEventTypes)
  96694. * @param event Defines the related dom event
  96695. * @param localX Defines the local x coordinates of the pointer when the event occured
  96696. * @param localY Defines the local y coordinates of the pointer when the event occured
  96697. */
  96698. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  96699. }
  96700. /**
  96701. * This type contains all the data related to a pointer event in Babylon.js.
  96702. * 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.
  96703. */
  96704. export class PointerInfo extends PointerInfoBase {
  96705. /**
  96706. * Defines the picking info associated to the info (if any)\
  96707. */
  96708. pickInfo: Nullable<PickingInfo>;
  96709. /**
  96710. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  96711. * @param type Defines the type of event (PointerEventTypes)
  96712. * @param event Defines the related dom event
  96713. * @param pickInfo Defines the picking info associated to the info (if any)\
  96714. */
  96715. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  96716. /**
  96717. * Defines the picking info associated to the info (if any)\
  96718. */
  96719. pickInfo: Nullable<PickingInfo>);
  96720. }
  96721. /**
  96722. * Data relating to a touch event on the screen.
  96723. */
  96724. export interface PointerTouch {
  96725. /**
  96726. * X coordinate of touch.
  96727. */
  96728. x: number;
  96729. /**
  96730. * Y coordinate of touch.
  96731. */
  96732. y: number;
  96733. /**
  96734. * Id of touch. Unique for each finger.
  96735. */
  96736. pointerId: number;
  96737. /**
  96738. * Event type passed from DOM.
  96739. */
  96740. type: any;
  96741. }
  96742. }
  96743. declare module BABYLON {
  96744. /**
  96745. * Manage the mouse inputs to control the movement of a free camera.
  96746. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96747. */
  96748. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  96749. /**
  96750. * Define if touch is enabled in the mouse input
  96751. */
  96752. touchEnabled: boolean;
  96753. /**
  96754. * Defines the camera the input is attached to.
  96755. */
  96756. camera: FreeCamera;
  96757. /**
  96758. * Defines the buttons associated with the input to handle camera move.
  96759. */
  96760. buttons: number[];
  96761. /**
  96762. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  96763. */
  96764. angularSensibility: number;
  96765. private _pointerInput;
  96766. private _onMouseMove;
  96767. private _observer;
  96768. private previousPosition;
  96769. /**
  96770. * Observable for when a pointer move event occurs containing the move offset
  96771. */
  96772. onPointerMovedObservable: Observable<{
  96773. offsetX: number;
  96774. offsetY: number;
  96775. }>;
  96776. /**
  96777. * @hidden
  96778. * If the camera should be rotated automatically based on pointer movement
  96779. */
  96780. _allowCameraRotation: boolean;
  96781. /**
  96782. * Manage the mouse inputs to control the movement of a free camera.
  96783. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96784. * @param touchEnabled Defines if touch is enabled or not
  96785. */
  96786. constructor(
  96787. /**
  96788. * Define if touch is enabled in the mouse input
  96789. */
  96790. touchEnabled?: boolean);
  96791. /**
  96792. * Attach the input controls to a specific dom element to get the input from.
  96793. * @param element Defines the element the controls should be listened from
  96794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96795. */
  96796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96797. /**
  96798. * Called on JS contextmenu event.
  96799. * Override this method to provide functionality.
  96800. */
  96801. protected onContextMenu(evt: PointerEvent): void;
  96802. /**
  96803. * Detach the current controls from the specified dom element.
  96804. * @param element Defines the element to stop listening the inputs from
  96805. */
  96806. detachControl(element: Nullable<HTMLElement>): void;
  96807. /**
  96808. * Gets the class name of the current intput.
  96809. * @returns the class name
  96810. */
  96811. getClassName(): string;
  96812. /**
  96813. * Get the friendly name associated with the input class.
  96814. * @returns the input friendly name
  96815. */
  96816. getSimpleName(): string;
  96817. }
  96818. }
  96819. declare module BABYLON {
  96820. /**
  96821. * Manage the touch inputs to control the movement of a free camera.
  96822. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96823. */
  96824. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  96825. /**
  96826. * Defines the camera the input is attached to.
  96827. */
  96828. camera: FreeCamera;
  96829. /**
  96830. * Defines the touch sensibility for rotation.
  96831. * The higher the faster.
  96832. */
  96833. touchAngularSensibility: number;
  96834. /**
  96835. * Defines the touch sensibility for move.
  96836. * The higher the faster.
  96837. */
  96838. touchMoveSensibility: number;
  96839. private _offsetX;
  96840. private _offsetY;
  96841. private _pointerPressed;
  96842. private _pointerInput;
  96843. private _observer;
  96844. private _onLostFocus;
  96845. /**
  96846. * Attach the input controls to a specific dom element to get the input from.
  96847. * @param element Defines the element the controls should be listened from
  96848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96849. */
  96850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96851. /**
  96852. * Detach the current controls from the specified dom element.
  96853. * @param element Defines the element to stop listening the inputs from
  96854. */
  96855. detachControl(element: Nullable<HTMLElement>): void;
  96856. /**
  96857. * Update the current camera state depending on the inputs that have been used this frame.
  96858. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96859. */
  96860. checkInputs(): void;
  96861. /**
  96862. * Gets the class name of the current intput.
  96863. * @returns the class name
  96864. */
  96865. getClassName(): string;
  96866. /**
  96867. * Get the friendly name associated with the input class.
  96868. * @returns the input friendly name
  96869. */
  96870. getSimpleName(): string;
  96871. }
  96872. }
  96873. declare module BABYLON {
  96874. /**
  96875. * Default Inputs manager for the FreeCamera.
  96876. * It groups all the default supported inputs for ease of use.
  96877. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96878. */
  96879. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  96880. /**
  96881. * @hidden
  96882. */
  96883. _mouseInput: Nullable<FreeCameraMouseInput>;
  96884. /**
  96885. * Instantiates a new FreeCameraInputsManager.
  96886. * @param camera Defines the camera the inputs belong to
  96887. */
  96888. constructor(camera: FreeCamera);
  96889. /**
  96890. * Add keyboard input support to the input manager.
  96891. * @returns the current input manager
  96892. */
  96893. addKeyboard(): FreeCameraInputsManager;
  96894. /**
  96895. * Add mouse input support to the input manager.
  96896. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  96897. * @returns the current input manager
  96898. */
  96899. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  96900. /**
  96901. * Removes the mouse input support from the manager
  96902. * @returns the current input manager
  96903. */
  96904. removeMouse(): FreeCameraInputsManager;
  96905. /**
  96906. * Add touch input support to the input manager.
  96907. * @returns the current input manager
  96908. */
  96909. addTouch(): FreeCameraInputsManager;
  96910. /**
  96911. * Remove all attached input methods from a camera
  96912. */
  96913. clear(): void;
  96914. }
  96915. }
  96916. declare module BABYLON {
  96917. /**
  96918. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96919. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  96920. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  96921. */
  96922. export class FreeCamera extends TargetCamera {
  96923. /**
  96924. * Define the collision ellipsoid of the camera.
  96925. * This is helpful to simulate a camera body like the player body around the camera
  96926. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96927. */
  96928. ellipsoid: Vector3;
  96929. /**
  96930. * Define an offset for the position of the ellipsoid around the camera.
  96931. * This can be helpful to determine the center of the body near the gravity center of the body
  96932. * instead of its head.
  96933. */
  96934. ellipsoidOffset: Vector3;
  96935. /**
  96936. * Enable or disable collisions of the camera with the rest of the scene objects.
  96937. */
  96938. checkCollisions: boolean;
  96939. /**
  96940. * Enable or disable gravity on the camera.
  96941. */
  96942. applyGravity: boolean;
  96943. /**
  96944. * Define the input manager associated to the camera.
  96945. */
  96946. inputs: FreeCameraInputsManager;
  96947. /**
  96948. * Gets the input sensibility for a mouse input. (default is 2000.0)
  96949. * Higher values reduce sensitivity.
  96950. */
  96951. get angularSensibility(): number;
  96952. /**
  96953. * Sets the input sensibility for a mouse input. (default is 2000.0)
  96954. * Higher values reduce sensitivity.
  96955. */
  96956. set angularSensibility(value: number);
  96957. /**
  96958. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96959. */
  96960. get keysUp(): number[];
  96961. set keysUp(value: number[]);
  96962. /**
  96963. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96964. */
  96965. get keysUpward(): number[];
  96966. set keysUpward(value: number[]);
  96967. /**
  96968. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96969. */
  96970. get keysDown(): number[];
  96971. set keysDown(value: number[]);
  96972. /**
  96973. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96974. */
  96975. get keysDownward(): number[];
  96976. set keysDownward(value: number[]);
  96977. /**
  96978. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96979. */
  96980. get keysLeft(): number[];
  96981. set keysLeft(value: number[]);
  96982. /**
  96983. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96984. */
  96985. get keysRight(): number[];
  96986. set keysRight(value: number[]);
  96987. /**
  96988. * Event raised when the camera collide with a mesh in the scene.
  96989. */
  96990. onCollide: (collidedMesh: AbstractMesh) => void;
  96991. private _collider;
  96992. private _needMoveForGravity;
  96993. private _oldPosition;
  96994. private _diffPosition;
  96995. private _newPosition;
  96996. /** @hidden */
  96997. _localDirection: Vector3;
  96998. /** @hidden */
  96999. _transformedDirection: Vector3;
  97000. /**
  97001. * Instantiates a Free Camera.
  97002. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97003. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  97004. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97005. * @param name Define the name of the camera in the scene
  97006. * @param position Define the start position of the camera in the scene
  97007. * @param scene Define the scene the camera belongs to
  97008. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97009. */
  97010. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97011. /**
  97012. * Attached controls to the current camera.
  97013. * @param element Defines the element the controls should be listened from
  97014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97015. */
  97016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97017. /**
  97018. * Detach the current controls from the camera.
  97019. * The camera will stop reacting to inputs.
  97020. * @param element Defines the element to stop listening the inputs from
  97021. */
  97022. detachControl(element: HTMLElement): void;
  97023. private _collisionMask;
  97024. /**
  97025. * Define a collision mask to limit the list of object the camera can collide with
  97026. */
  97027. get collisionMask(): number;
  97028. set collisionMask(mask: number);
  97029. /** @hidden */
  97030. _collideWithWorld(displacement: Vector3): void;
  97031. private _onCollisionPositionChange;
  97032. /** @hidden */
  97033. _checkInputs(): void;
  97034. /** @hidden */
  97035. _decideIfNeedsToMove(): boolean;
  97036. /** @hidden */
  97037. _updatePosition(): void;
  97038. /**
  97039. * Destroy the camera and release the current resources hold by it.
  97040. */
  97041. dispose(): void;
  97042. /**
  97043. * Gets the current object class name.
  97044. * @return the class name
  97045. */
  97046. getClassName(): string;
  97047. }
  97048. }
  97049. declare module BABYLON {
  97050. /**
  97051. * Represents a gamepad control stick position
  97052. */
  97053. export class StickValues {
  97054. /**
  97055. * The x component of the control stick
  97056. */
  97057. x: number;
  97058. /**
  97059. * The y component of the control stick
  97060. */
  97061. y: number;
  97062. /**
  97063. * Initializes the gamepad x and y control stick values
  97064. * @param x The x component of the gamepad control stick value
  97065. * @param y The y component of the gamepad control stick value
  97066. */
  97067. constructor(
  97068. /**
  97069. * The x component of the control stick
  97070. */
  97071. x: number,
  97072. /**
  97073. * The y component of the control stick
  97074. */
  97075. y: number);
  97076. }
  97077. /**
  97078. * An interface which manages callbacks for gamepad button changes
  97079. */
  97080. export interface GamepadButtonChanges {
  97081. /**
  97082. * Called when a gamepad has been changed
  97083. */
  97084. changed: boolean;
  97085. /**
  97086. * Called when a gamepad press event has been triggered
  97087. */
  97088. pressChanged: boolean;
  97089. /**
  97090. * Called when a touch event has been triggered
  97091. */
  97092. touchChanged: boolean;
  97093. /**
  97094. * Called when a value has changed
  97095. */
  97096. valueChanged: boolean;
  97097. }
  97098. /**
  97099. * Represents a gamepad
  97100. */
  97101. export class Gamepad {
  97102. /**
  97103. * The id of the gamepad
  97104. */
  97105. id: string;
  97106. /**
  97107. * The index of the gamepad
  97108. */
  97109. index: number;
  97110. /**
  97111. * The browser gamepad
  97112. */
  97113. browserGamepad: any;
  97114. /**
  97115. * Specifies what type of gamepad this represents
  97116. */
  97117. type: number;
  97118. private _leftStick;
  97119. private _rightStick;
  97120. /** @hidden */
  97121. _isConnected: boolean;
  97122. private _leftStickAxisX;
  97123. private _leftStickAxisY;
  97124. private _rightStickAxisX;
  97125. private _rightStickAxisY;
  97126. /**
  97127. * Triggered when the left control stick has been changed
  97128. */
  97129. private _onleftstickchanged;
  97130. /**
  97131. * Triggered when the right control stick has been changed
  97132. */
  97133. private _onrightstickchanged;
  97134. /**
  97135. * Represents a gamepad controller
  97136. */
  97137. static GAMEPAD: number;
  97138. /**
  97139. * Represents a generic controller
  97140. */
  97141. static GENERIC: number;
  97142. /**
  97143. * Represents an XBox controller
  97144. */
  97145. static XBOX: number;
  97146. /**
  97147. * Represents a pose-enabled controller
  97148. */
  97149. static POSE_ENABLED: number;
  97150. /**
  97151. * Represents an Dual Shock controller
  97152. */
  97153. static DUALSHOCK: number;
  97154. /**
  97155. * Specifies whether the left control stick should be Y-inverted
  97156. */
  97157. protected _invertLeftStickY: boolean;
  97158. /**
  97159. * Specifies if the gamepad has been connected
  97160. */
  97161. get isConnected(): boolean;
  97162. /**
  97163. * Initializes the gamepad
  97164. * @param id The id of the gamepad
  97165. * @param index The index of the gamepad
  97166. * @param browserGamepad The browser gamepad
  97167. * @param leftStickX The x component of the left joystick
  97168. * @param leftStickY The y component of the left joystick
  97169. * @param rightStickX The x component of the right joystick
  97170. * @param rightStickY The y component of the right joystick
  97171. */
  97172. constructor(
  97173. /**
  97174. * The id of the gamepad
  97175. */
  97176. id: string,
  97177. /**
  97178. * The index of the gamepad
  97179. */
  97180. index: number,
  97181. /**
  97182. * The browser gamepad
  97183. */
  97184. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  97185. /**
  97186. * Callback triggered when the left joystick has changed
  97187. * @param callback
  97188. */
  97189. onleftstickchanged(callback: (values: StickValues) => void): void;
  97190. /**
  97191. * Callback triggered when the right joystick has changed
  97192. * @param callback
  97193. */
  97194. onrightstickchanged(callback: (values: StickValues) => void): void;
  97195. /**
  97196. * Gets the left joystick
  97197. */
  97198. get leftStick(): StickValues;
  97199. /**
  97200. * Sets the left joystick values
  97201. */
  97202. set leftStick(newValues: StickValues);
  97203. /**
  97204. * Gets the right joystick
  97205. */
  97206. get rightStick(): StickValues;
  97207. /**
  97208. * Sets the right joystick value
  97209. */
  97210. set rightStick(newValues: StickValues);
  97211. /**
  97212. * Updates the gamepad joystick positions
  97213. */
  97214. update(): void;
  97215. /**
  97216. * Disposes the gamepad
  97217. */
  97218. dispose(): void;
  97219. }
  97220. /**
  97221. * Represents a generic gamepad
  97222. */
  97223. export class GenericPad extends Gamepad {
  97224. private _buttons;
  97225. private _onbuttondown;
  97226. private _onbuttonup;
  97227. /**
  97228. * Observable triggered when a button has been pressed
  97229. */
  97230. onButtonDownObservable: Observable<number>;
  97231. /**
  97232. * Observable triggered when a button has been released
  97233. */
  97234. onButtonUpObservable: Observable<number>;
  97235. /**
  97236. * Callback triggered when a button has been pressed
  97237. * @param callback Called when a button has been pressed
  97238. */
  97239. onbuttondown(callback: (buttonPressed: number) => void): void;
  97240. /**
  97241. * Callback triggered when a button has been released
  97242. * @param callback Called when a button has been released
  97243. */
  97244. onbuttonup(callback: (buttonReleased: number) => void): void;
  97245. /**
  97246. * Initializes the generic gamepad
  97247. * @param id The id of the generic gamepad
  97248. * @param index The index of the generic gamepad
  97249. * @param browserGamepad The browser gamepad
  97250. */
  97251. constructor(id: string, index: number, browserGamepad: any);
  97252. private _setButtonValue;
  97253. /**
  97254. * Updates the generic gamepad
  97255. */
  97256. update(): void;
  97257. /**
  97258. * Disposes the generic gamepad
  97259. */
  97260. dispose(): void;
  97261. }
  97262. }
  97263. declare module BABYLON {
  97264. /**
  97265. * Defines the types of pose enabled controllers that are supported
  97266. */
  97267. export enum PoseEnabledControllerType {
  97268. /**
  97269. * HTC Vive
  97270. */
  97271. VIVE = 0,
  97272. /**
  97273. * Oculus Rift
  97274. */
  97275. OCULUS = 1,
  97276. /**
  97277. * Windows mixed reality
  97278. */
  97279. WINDOWS = 2,
  97280. /**
  97281. * Samsung gear VR
  97282. */
  97283. GEAR_VR = 3,
  97284. /**
  97285. * Google Daydream
  97286. */
  97287. DAYDREAM = 4,
  97288. /**
  97289. * Generic
  97290. */
  97291. GENERIC = 5
  97292. }
  97293. /**
  97294. * Defines the MutableGamepadButton interface for the state of a gamepad button
  97295. */
  97296. export interface MutableGamepadButton {
  97297. /**
  97298. * Value of the button/trigger
  97299. */
  97300. value: number;
  97301. /**
  97302. * If the button/trigger is currently touched
  97303. */
  97304. touched: boolean;
  97305. /**
  97306. * If the button/trigger is currently pressed
  97307. */
  97308. pressed: boolean;
  97309. }
  97310. /**
  97311. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  97312. * @hidden
  97313. */
  97314. export interface ExtendedGamepadButton extends GamepadButton {
  97315. /**
  97316. * If the button/trigger is currently pressed
  97317. */
  97318. readonly pressed: boolean;
  97319. /**
  97320. * If the button/trigger is currently touched
  97321. */
  97322. readonly touched: boolean;
  97323. /**
  97324. * Value of the button/trigger
  97325. */
  97326. readonly value: number;
  97327. }
  97328. /** @hidden */
  97329. export interface _GamePadFactory {
  97330. /**
  97331. * Returns whether or not the current gamepad can be created for this type of controller.
  97332. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97333. * @returns true if it can be created, otherwise false
  97334. */
  97335. canCreate(gamepadInfo: any): boolean;
  97336. /**
  97337. * Creates a new instance of the Gamepad.
  97338. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97339. * @returns the new gamepad instance
  97340. */
  97341. create(gamepadInfo: any): Gamepad;
  97342. }
  97343. /**
  97344. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97345. */
  97346. export class PoseEnabledControllerHelper {
  97347. /** @hidden */
  97348. static _ControllerFactories: _GamePadFactory[];
  97349. /** @hidden */
  97350. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  97351. /**
  97352. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97353. * @param vrGamepad the gamepad to initialized
  97354. * @returns a vr controller of the type the gamepad identified as
  97355. */
  97356. static InitiateController(vrGamepad: any): Gamepad;
  97357. }
  97358. /**
  97359. * Defines the PoseEnabledController object that contains state of a vr capable controller
  97360. */
  97361. export class PoseEnabledController extends Gamepad implements PoseControlled {
  97362. /**
  97363. * If the controller is used in a webXR session
  97364. */
  97365. isXR: boolean;
  97366. private _deviceRoomPosition;
  97367. private _deviceRoomRotationQuaternion;
  97368. /**
  97369. * The device position in babylon space
  97370. */
  97371. devicePosition: Vector3;
  97372. /**
  97373. * The device rotation in babylon space
  97374. */
  97375. deviceRotationQuaternion: Quaternion;
  97376. /**
  97377. * The scale factor of the device in babylon space
  97378. */
  97379. deviceScaleFactor: number;
  97380. /**
  97381. * (Likely devicePosition should be used instead) The device position in its room space
  97382. */
  97383. position: Vector3;
  97384. /**
  97385. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  97386. */
  97387. rotationQuaternion: Quaternion;
  97388. /**
  97389. * The type of controller (Eg. Windows mixed reality)
  97390. */
  97391. controllerType: PoseEnabledControllerType;
  97392. protected _calculatedPosition: Vector3;
  97393. private _calculatedRotation;
  97394. /**
  97395. * The raw pose from the device
  97396. */
  97397. rawPose: DevicePose;
  97398. private _trackPosition;
  97399. private _maxRotationDistFromHeadset;
  97400. private _draggedRoomRotation;
  97401. /**
  97402. * @hidden
  97403. */
  97404. _disableTrackPosition(fixedPosition: Vector3): void;
  97405. /**
  97406. * Internal, the mesh attached to the controller
  97407. * @hidden
  97408. */
  97409. _mesh: Nullable<AbstractMesh>;
  97410. private _poseControlledCamera;
  97411. private _leftHandSystemQuaternion;
  97412. /**
  97413. * Internal, matrix used to convert room space to babylon space
  97414. * @hidden
  97415. */
  97416. _deviceToWorld: Matrix;
  97417. /**
  97418. * Node to be used when casting a ray from the controller
  97419. * @hidden
  97420. */
  97421. _pointingPoseNode: Nullable<TransformNode>;
  97422. /**
  97423. * Name of the child mesh that can be used to cast a ray from the controller
  97424. */
  97425. static readonly POINTING_POSE: string;
  97426. /**
  97427. * Creates a new PoseEnabledController from a gamepad
  97428. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  97429. */
  97430. constructor(browserGamepad: any);
  97431. private _workingMatrix;
  97432. /**
  97433. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  97434. */
  97435. update(): void;
  97436. /**
  97437. * Updates only the pose device and mesh without doing any button event checking
  97438. */
  97439. protected _updatePoseAndMesh(): void;
  97440. /**
  97441. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  97442. * @param poseData raw pose fromthe device
  97443. */
  97444. updateFromDevice(poseData: DevicePose): void;
  97445. /**
  97446. * @hidden
  97447. */
  97448. _meshAttachedObservable: Observable<AbstractMesh>;
  97449. /**
  97450. * Attaches a mesh to the controller
  97451. * @param mesh the mesh to be attached
  97452. */
  97453. attachToMesh(mesh: AbstractMesh): void;
  97454. /**
  97455. * Attaches the controllers mesh to a camera
  97456. * @param camera the camera the mesh should be attached to
  97457. */
  97458. attachToPoseControlledCamera(camera: TargetCamera): void;
  97459. /**
  97460. * Disposes of the controller
  97461. */
  97462. dispose(): void;
  97463. /**
  97464. * The mesh that is attached to the controller
  97465. */
  97466. get mesh(): Nullable<AbstractMesh>;
  97467. /**
  97468. * Gets the ray of the controller in the direction the controller is pointing
  97469. * @param length the length the resulting ray should be
  97470. * @returns a ray in the direction the controller is pointing
  97471. */
  97472. getForwardRay(length?: number): Ray;
  97473. }
  97474. }
  97475. declare module BABYLON {
  97476. /**
  97477. * Defines the WebVRController object that represents controllers tracked in 3D space
  97478. */
  97479. export abstract class WebVRController extends PoseEnabledController {
  97480. /**
  97481. * Internal, the default controller model for the controller
  97482. */
  97483. protected _defaultModel: Nullable<AbstractMesh>;
  97484. /**
  97485. * Fired when the trigger state has changed
  97486. */
  97487. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97488. /**
  97489. * Fired when the main button state has changed
  97490. */
  97491. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97492. /**
  97493. * Fired when the secondary button state has changed
  97494. */
  97495. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97496. /**
  97497. * Fired when the pad state has changed
  97498. */
  97499. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  97500. /**
  97501. * Fired when controllers stick values have changed
  97502. */
  97503. onPadValuesChangedObservable: Observable<StickValues>;
  97504. /**
  97505. * Array of button availible on the controller
  97506. */
  97507. protected _buttons: Array<MutableGamepadButton>;
  97508. private _onButtonStateChange;
  97509. /**
  97510. * Fired when a controller button's state has changed
  97511. * @param callback the callback containing the button that was modified
  97512. */
  97513. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  97514. /**
  97515. * X and Y axis corresponding to the controllers joystick
  97516. */
  97517. pad: StickValues;
  97518. /**
  97519. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  97520. */
  97521. hand: string;
  97522. /**
  97523. * The default controller model for the controller
  97524. */
  97525. get defaultModel(): Nullable<AbstractMesh>;
  97526. /**
  97527. * Creates a new WebVRController from a gamepad
  97528. * @param vrGamepad the gamepad that the WebVRController should be created from
  97529. */
  97530. constructor(vrGamepad: any);
  97531. /**
  97532. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  97533. */
  97534. update(): void;
  97535. /**
  97536. * Function to be called when a button is modified
  97537. */
  97538. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97539. /**
  97540. * Loads a mesh and attaches it to the controller
  97541. * @param scene the scene the mesh should be added to
  97542. * @param meshLoaded callback for when the mesh has been loaded
  97543. */
  97544. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97545. private _setButtonValue;
  97546. private _changes;
  97547. private _checkChanges;
  97548. /**
  97549. * Disposes of th webVRCOntroller
  97550. */
  97551. dispose(): void;
  97552. }
  97553. }
  97554. declare module BABYLON {
  97555. /**
  97556. * The HemisphericLight simulates the ambient environment light,
  97557. * so the passed direction is the light reflection direction, not the incoming direction.
  97558. */
  97559. export class HemisphericLight extends Light {
  97560. /**
  97561. * The groundColor is the light in the opposite direction to the one specified during creation.
  97562. * 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.
  97563. */
  97564. groundColor: Color3;
  97565. /**
  97566. * The light reflection direction, not the incoming direction.
  97567. */
  97568. direction: Vector3;
  97569. /**
  97570. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  97571. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  97572. * The HemisphericLight can't cast shadows.
  97573. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97574. * @param name The friendly name of the light
  97575. * @param direction The direction of the light reflection
  97576. * @param scene The scene the light belongs to
  97577. */
  97578. constructor(name: string, direction: Vector3, scene: Scene);
  97579. protected _buildUniformLayout(): void;
  97580. /**
  97581. * Returns the string "HemisphericLight".
  97582. * @return The class name
  97583. */
  97584. getClassName(): string;
  97585. /**
  97586. * Sets the HemisphericLight direction towards the passed target (Vector3).
  97587. * Returns the updated direction.
  97588. * @param target The target the direction should point to
  97589. * @return The computed direction
  97590. */
  97591. setDirectionToTarget(target: Vector3): Vector3;
  97592. /**
  97593. * Returns the shadow generator associated to the light.
  97594. * @returns Always null for hemispheric lights because it does not support shadows.
  97595. */
  97596. getShadowGenerator(): Nullable<IShadowGenerator>;
  97597. /**
  97598. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  97599. * @param effect The effect to update
  97600. * @param lightIndex The index of the light in the effect to update
  97601. * @returns The hemispheric light
  97602. */
  97603. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  97604. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  97605. /**
  97606. * Computes the world matrix of the node
  97607. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97608. * @param useWasUpdatedFlag defines a reserved property
  97609. * @returns the world matrix
  97610. */
  97611. computeWorldMatrix(): Matrix;
  97612. /**
  97613. * Returns the integer 3.
  97614. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97615. */
  97616. getTypeID(): number;
  97617. /**
  97618. * Prepares the list of defines specific to the light type.
  97619. * @param defines the list of defines
  97620. * @param lightIndex defines the index of the light for the effect
  97621. */
  97622. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97623. }
  97624. }
  97625. declare module BABYLON {
  97626. /** @hidden */
  97627. export var vrMultiviewToSingleviewPixelShader: {
  97628. name: string;
  97629. shader: string;
  97630. };
  97631. }
  97632. declare module BABYLON {
  97633. /**
  97634. * Renders to multiple views with a single draw call
  97635. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  97636. */
  97637. export class MultiviewRenderTarget extends RenderTargetTexture {
  97638. /**
  97639. * Creates a multiview render target
  97640. * @param scene scene used with the render target
  97641. * @param size the size of the render target (used for each view)
  97642. */
  97643. constructor(scene: Scene, size?: number | {
  97644. width: number;
  97645. height: number;
  97646. } | {
  97647. ratio: number;
  97648. });
  97649. /**
  97650. * @hidden
  97651. * @param faceIndex the face index, if its a cube texture
  97652. */
  97653. _bindFrameBuffer(faceIndex?: number): void;
  97654. /**
  97655. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97656. * @returns the view count
  97657. */
  97658. getViewCount(): number;
  97659. }
  97660. }
  97661. declare module BABYLON {
  97662. interface Engine {
  97663. /**
  97664. * Creates a new multiview render target
  97665. * @param width defines the width of the texture
  97666. * @param height defines the height of the texture
  97667. * @returns the created multiview texture
  97668. */
  97669. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  97670. /**
  97671. * Binds a multiview framebuffer to be drawn to
  97672. * @param multiviewTexture texture to bind
  97673. */
  97674. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  97675. }
  97676. interface Camera {
  97677. /**
  97678. * @hidden
  97679. * 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)
  97680. */
  97681. _useMultiviewToSingleView: boolean;
  97682. /**
  97683. * @hidden
  97684. * 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)
  97685. */
  97686. _multiviewTexture: Nullable<RenderTargetTexture>;
  97687. /**
  97688. * @hidden
  97689. * ensures the multiview texture of the camera exists and has the specified width/height
  97690. * @param width height to set on the multiview texture
  97691. * @param height width to set on the multiview texture
  97692. */
  97693. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  97694. }
  97695. interface Scene {
  97696. /** @hidden */
  97697. _transformMatrixR: Matrix;
  97698. /** @hidden */
  97699. _multiviewSceneUbo: Nullable<UniformBuffer>;
  97700. /** @hidden */
  97701. _createMultiviewUbo(): void;
  97702. /** @hidden */
  97703. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  97704. /** @hidden */
  97705. _renderMultiviewToSingleView(camera: Camera): void;
  97706. }
  97707. }
  97708. declare module BABYLON {
  97709. /**
  97710. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  97711. * This will not be used for webXR as it supports displaying texture arrays directly
  97712. */
  97713. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  97714. /**
  97715. * Initializes a VRMultiviewToSingleview
  97716. * @param name name of the post process
  97717. * @param camera camera to be applied to
  97718. * @param scaleFactor scaling factor to the size of the output texture
  97719. */
  97720. constructor(name: string, camera: Camera, scaleFactor: number);
  97721. }
  97722. }
  97723. declare module BABYLON {
  97724. /**
  97725. * Interface used to define additional presentation attributes
  97726. */
  97727. export interface IVRPresentationAttributes {
  97728. /**
  97729. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  97730. */
  97731. highRefreshRate: boolean;
  97732. /**
  97733. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  97734. */
  97735. foveationLevel: number;
  97736. }
  97737. interface Engine {
  97738. /** @hidden */
  97739. _vrDisplay: any;
  97740. /** @hidden */
  97741. _vrSupported: boolean;
  97742. /** @hidden */
  97743. _oldSize: Size;
  97744. /** @hidden */
  97745. _oldHardwareScaleFactor: number;
  97746. /** @hidden */
  97747. _vrExclusivePointerMode: boolean;
  97748. /** @hidden */
  97749. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  97750. /** @hidden */
  97751. _onVRDisplayPointerRestricted: () => void;
  97752. /** @hidden */
  97753. _onVRDisplayPointerUnrestricted: () => void;
  97754. /** @hidden */
  97755. _onVrDisplayConnect: Nullable<(display: any) => void>;
  97756. /** @hidden */
  97757. _onVrDisplayDisconnect: Nullable<() => void>;
  97758. /** @hidden */
  97759. _onVrDisplayPresentChange: Nullable<() => void>;
  97760. /**
  97761. * Observable signaled when VR display mode changes
  97762. */
  97763. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  97764. /**
  97765. * Observable signaled when VR request present is complete
  97766. */
  97767. onVRRequestPresentComplete: Observable<boolean>;
  97768. /**
  97769. * Observable signaled when VR request present starts
  97770. */
  97771. onVRRequestPresentStart: Observable<Engine>;
  97772. /**
  97773. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  97774. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  97775. */
  97776. isInVRExclusivePointerMode: boolean;
  97777. /**
  97778. * Gets a boolean indicating if a webVR device was detected
  97779. * @returns true if a webVR device was detected
  97780. */
  97781. isVRDevicePresent(): boolean;
  97782. /**
  97783. * Gets the current webVR device
  97784. * @returns the current webVR device (or null)
  97785. */
  97786. getVRDevice(): any;
  97787. /**
  97788. * Initializes a webVR display and starts listening to display change events
  97789. * The onVRDisplayChangedObservable will be notified upon these changes
  97790. * @returns A promise containing a VRDisplay and if vr is supported
  97791. */
  97792. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  97793. /** @hidden */
  97794. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  97795. /**
  97796. * Gets or sets the presentation attributes used to configure VR rendering
  97797. */
  97798. vrPresentationAttributes?: IVRPresentationAttributes;
  97799. /**
  97800. * Call this function to switch to webVR mode
  97801. * Will do nothing if webVR is not supported or if there is no webVR device
  97802. * @param options the webvr options provided to the camera. mainly used for multiview
  97803. * @see https://doc.babylonjs.com/how_to/webvr_camera
  97804. */
  97805. enableVR(options: WebVROptions): void;
  97806. /** @hidden */
  97807. _onVRFullScreenTriggered(): void;
  97808. }
  97809. }
  97810. declare module BABYLON {
  97811. /**
  97812. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  97813. * IMPORTANT!! The data is right-hand data.
  97814. * @export
  97815. * @interface DevicePose
  97816. */
  97817. export interface DevicePose {
  97818. /**
  97819. * The position of the device, values in array are [x,y,z].
  97820. */
  97821. readonly position: Nullable<Float32Array>;
  97822. /**
  97823. * The linearVelocity of the device, values in array are [x,y,z].
  97824. */
  97825. readonly linearVelocity: Nullable<Float32Array>;
  97826. /**
  97827. * The linearAcceleration of the device, values in array are [x,y,z].
  97828. */
  97829. readonly linearAcceleration: Nullable<Float32Array>;
  97830. /**
  97831. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  97832. */
  97833. readonly orientation: Nullable<Float32Array>;
  97834. /**
  97835. * The angularVelocity of the device, values in array are [x,y,z].
  97836. */
  97837. readonly angularVelocity: Nullable<Float32Array>;
  97838. /**
  97839. * The angularAcceleration of the device, values in array are [x,y,z].
  97840. */
  97841. readonly angularAcceleration: Nullable<Float32Array>;
  97842. }
  97843. /**
  97844. * Interface representing a pose controlled object in Babylon.
  97845. * A pose controlled object has both regular pose values as well as pose values
  97846. * from an external device such as a VR head mounted display
  97847. */
  97848. export interface PoseControlled {
  97849. /**
  97850. * The position of the object in babylon space.
  97851. */
  97852. position: Vector3;
  97853. /**
  97854. * The rotation quaternion of the object in babylon space.
  97855. */
  97856. rotationQuaternion: Quaternion;
  97857. /**
  97858. * The position of the device in babylon space.
  97859. */
  97860. devicePosition?: Vector3;
  97861. /**
  97862. * The rotation quaternion of the device in babylon space.
  97863. */
  97864. deviceRotationQuaternion: Quaternion;
  97865. /**
  97866. * The raw pose coming from the device.
  97867. */
  97868. rawPose: Nullable<DevicePose>;
  97869. /**
  97870. * The scale of the device to be used when translating from device space to babylon space.
  97871. */
  97872. deviceScaleFactor: number;
  97873. /**
  97874. * Updates the poseControlled values based on the input device pose.
  97875. * @param poseData the pose data to update the object with
  97876. */
  97877. updateFromDevice(poseData: DevicePose): void;
  97878. }
  97879. /**
  97880. * Set of options to customize the webVRCamera
  97881. */
  97882. export interface WebVROptions {
  97883. /**
  97884. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  97885. */
  97886. trackPosition?: boolean;
  97887. /**
  97888. * Sets the scale of the vrDevice in babylon space. (default: 1)
  97889. */
  97890. positionScale?: number;
  97891. /**
  97892. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  97893. */
  97894. displayName?: string;
  97895. /**
  97896. * Should the native controller meshes be initialized. (default: true)
  97897. */
  97898. controllerMeshes?: boolean;
  97899. /**
  97900. * Creating a default HemiLight only on controllers. (default: true)
  97901. */
  97902. defaultLightingOnControllers?: boolean;
  97903. /**
  97904. * If you don't want to use the default VR button of the helper. (default: false)
  97905. */
  97906. useCustomVRButton?: boolean;
  97907. /**
  97908. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  97909. */
  97910. customVRButton?: HTMLButtonElement;
  97911. /**
  97912. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  97913. */
  97914. rayLength?: number;
  97915. /**
  97916. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  97917. */
  97918. defaultHeight?: number;
  97919. /**
  97920. * If multiview should be used if availible (default: false)
  97921. */
  97922. useMultiview?: boolean;
  97923. }
  97924. /**
  97925. * This represents a WebVR camera.
  97926. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  97927. * @example https://doc.babylonjs.com/how_to/webvr_camera
  97928. */
  97929. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  97930. private webVROptions;
  97931. /**
  97932. * @hidden
  97933. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  97934. */
  97935. _vrDevice: any;
  97936. /**
  97937. * The rawPose of the vrDevice.
  97938. */
  97939. rawPose: Nullable<DevicePose>;
  97940. private _onVREnabled;
  97941. private _specsVersion;
  97942. private _attached;
  97943. private _frameData;
  97944. protected _descendants: Array<Node>;
  97945. private _deviceRoomPosition;
  97946. /** @hidden */
  97947. _deviceRoomRotationQuaternion: Quaternion;
  97948. private _standingMatrix;
  97949. /**
  97950. * Represents device position in babylon space.
  97951. */
  97952. devicePosition: Vector3;
  97953. /**
  97954. * Represents device rotation in babylon space.
  97955. */
  97956. deviceRotationQuaternion: Quaternion;
  97957. /**
  97958. * The scale of the device to be used when translating from device space to babylon space.
  97959. */
  97960. deviceScaleFactor: number;
  97961. private _deviceToWorld;
  97962. private _worldToDevice;
  97963. /**
  97964. * References to the webVR controllers for the vrDevice.
  97965. */
  97966. controllers: Array<WebVRController>;
  97967. /**
  97968. * Emits an event when a controller is attached.
  97969. */
  97970. onControllersAttachedObservable: Observable<WebVRController[]>;
  97971. /**
  97972. * Emits an event when a controller's mesh has been loaded;
  97973. */
  97974. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97975. /**
  97976. * Emits an event when the HMD's pose has been updated.
  97977. */
  97978. onPoseUpdatedFromDeviceObservable: Observable<any>;
  97979. private _poseSet;
  97980. /**
  97981. * If the rig cameras be used as parent instead of this camera.
  97982. */
  97983. rigParenting: boolean;
  97984. private _lightOnControllers;
  97985. private _defaultHeight?;
  97986. /**
  97987. * Instantiates a WebVRFreeCamera.
  97988. * @param name The name of the WebVRFreeCamera
  97989. * @param position The starting anchor position for the camera
  97990. * @param scene The scene the camera belongs to
  97991. * @param webVROptions a set of customizable options for the webVRCamera
  97992. */
  97993. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  97994. /**
  97995. * Gets the device distance from the ground in meters.
  97996. * @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.
  97997. */
  97998. deviceDistanceToRoomGround(): number;
  97999. /**
  98000. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98001. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  98002. */
  98003. useStandingMatrix(callback?: (bool: boolean) => void): void;
  98004. /**
  98005. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98006. * @returns A promise with a boolean set to if the standing matrix is supported.
  98007. */
  98008. useStandingMatrixAsync(): Promise<boolean>;
  98009. /**
  98010. * Disposes the camera
  98011. */
  98012. dispose(): void;
  98013. /**
  98014. * Gets a vrController by name.
  98015. * @param name The name of the controller to retreive
  98016. * @returns the controller matching the name specified or null if not found
  98017. */
  98018. getControllerByName(name: string): Nullable<WebVRController>;
  98019. private _leftController;
  98020. /**
  98021. * The controller corresponding to the users left hand.
  98022. */
  98023. get leftController(): Nullable<WebVRController>;
  98024. private _rightController;
  98025. /**
  98026. * The controller corresponding to the users right hand.
  98027. */
  98028. get rightController(): Nullable<WebVRController>;
  98029. /**
  98030. * Casts a ray forward from the vrCamera's gaze.
  98031. * @param length Length of the ray (default: 100)
  98032. * @returns the ray corresponding to the gaze
  98033. */
  98034. getForwardRay(length?: number): Ray;
  98035. /**
  98036. * @hidden
  98037. * Updates the camera based on device's frame data
  98038. */
  98039. _checkInputs(): void;
  98040. /**
  98041. * Updates the poseControlled values based on the input device pose.
  98042. * @param poseData Pose coming from the device
  98043. */
  98044. updateFromDevice(poseData: DevicePose): void;
  98045. private _htmlElementAttached;
  98046. private _detachIfAttached;
  98047. /**
  98048. * WebVR's attach control will start broadcasting frames to the device.
  98049. * Note that in certain browsers (chrome for example) this function must be called
  98050. * within a user-interaction callback. Example:
  98051. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  98052. *
  98053. * @param element html element to attach the vrDevice to
  98054. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  98055. */
  98056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98057. /**
  98058. * Detaches the camera from the html element and disables VR
  98059. *
  98060. * @param element html element to detach from
  98061. */
  98062. detachControl(element: HTMLElement): void;
  98063. /**
  98064. * @returns the name of this class
  98065. */
  98066. getClassName(): string;
  98067. /**
  98068. * Calls resetPose on the vrDisplay
  98069. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  98070. */
  98071. resetToCurrentRotation(): void;
  98072. /**
  98073. * @hidden
  98074. * Updates the rig cameras (left and right eye)
  98075. */
  98076. _updateRigCameras(): void;
  98077. private _workingVector;
  98078. private _oneVector;
  98079. private _workingMatrix;
  98080. private updateCacheCalled;
  98081. private _correctPositionIfNotTrackPosition;
  98082. /**
  98083. * @hidden
  98084. * Updates the cached values of the camera
  98085. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  98086. */
  98087. _updateCache(ignoreParentClass?: boolean): void;
  98088. /**
  98089. * @hidden
  98090. * Get current device position in babylon world
  98091. */
  98092. _computeDevicePosition(): void;
  98093. /**
  98094. * Updates the current device position and rotation in the babylon world
  98095. */
  98096. update(): void;
  98097. /**
  98098. * @hidden
  98099. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  98100. * @returns an identity matrix
  98101. */
  98102. _getViewMatrix(): Matrix;
  98103. private _tmpMatrix;
  98104. /**
  98105. * This function is called by the two RIG cameras.
  98106. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  98107. * @hidden
  98108. */
  98109. _getWebVRViewMatrix(): Matrix;
  98110. /** @hidden */
  98111. _getWebVRProjectionMatrix(): Matrix;
  98112. private _onGamepadConnectedObserver;
  98113. private _onGamepadDisconnectedObserver;
  98114. private _updateCacheWhenTrackingDisabledObserver;
  98115. /**
  98116. * Initializes the controllers and their meshes
  98117. */
  98118. initControllers(): void;
  98119. }
  98120. }
  98121. declare module BABYLON {
  98122. /**
  98123. * "Static Class" containing the most commonly used helper while dealing with material for
  98124. * rendering purpose.
  98125. *
  98126. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  98127. *
  98128. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  98129. */
  98130. export class MaterialHelper {
  98131. /**
  98132. * Bind the current view position to an effect.
  98133. * @param effect The effect to be bound
  98134. * @param scene The scene the eyes position is used from
  98135. * @param variableName name of the shader variable that will hold the eye position
  98136. */
  98137. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  98138. /**
  98139. * Helps preparing the defines values about the UVs in used in the effect.
  98140. * UVs are shared as much as we can accross channels in the shaders.
  98141. * @param texture The texture we are preparing the UVs for
  98142. * @param defines The defines to update
  98143. * @param key The channel key "diffuse", "specular"... used in the shader
  98144. */
  98145. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  98146. /**
  98147. * Binds a texture matrix value to its corrsponding uniform
  98148. * @param texture The texture to bind the matrix for
  98149. * @param uniformBuffer The uniform buffer receivin the data
  98150. * @param key The channel key "diffuse", "specular"... used in the shader
  98151. */
  98152. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  98153. /**
  98154. * Gets the current status of the fog (should it be enabled?)
  98155. * @param mesh defines the mesh to evaluate for fog support
  98156. * @param scene defines the hosting scene
  98157. * @returns true if fog must be enabled
  98158. */
  98159. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  98160. /**
  98161. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  98162. * @param mesh defines the current mesh
  98163. * @param scene defines the current scene
  98164. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  98165. * @param pointsCloud defines if point cloud rendering has to be turned on
  98166. * @param fogEnabled defines if fog has to be turned on
  98167. * @param alphaTest defines if alpha testing has to be turned on
  98168. * @param defines defines the current list of defines
  98169. */
  98170. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  98171. /**
  98172. * Helper used to prepare the list of defines associated with frame values for shader compilation
  98173. * @param scene defines the current scene
  98174. * @param engine defines the current engine
  98175. * @param defines specifies the list of active defines
  98176. * @param useInstances defines if instances have to be turned on
  98177. * @param useClipPlane defines if clip plane have to be turned on
  98178. * @param useInstances defines if instances have to be turned on
  98179. * @param useThinInstances defines if thin instances have to be turned on
  98180. */
  98181. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  98182. /**
  98183. * Prepares the defines for bones
  98184. * @param mesh The mesh containing the geometry data we will draw
  98185. * @param defines The defines to update
  98186. */
  98187. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  98188. /**
  98189. * Prepares the defines for morph targets
  98190. * @param mesh The mesh containing the geometry data we will draw
  98191. * @param defines The defines to update
  98192. */
  98193. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  98194. /**
  98195. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  98196. * @param mesh The mesh containing the geometry data we will draw
  98197. * @param defines The defines to update
  98198. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  98199. * @param useBones Precise whether bones should be used or not (override mesh info)
  98200. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  98201. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  98202. * @returns false if defines are considered not dirty and have not been checked
  98203. */
  98204. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  98205. /**
  98206. * Prepares the defines related to multiview
  98207. * @param scene The scene we are intending to draw
  98208. * @param defines The defines to update
  98209. */
  98210. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  98211. /**
  98212. * Prepares the defines related to the prepass
  98213. * @param scene The scene we are intending to draw
  98214. * @param defines The defines to update
  98215. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  98216. */
  98217. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  98218. /**
  98219. * Prepares the defines related to the light information passed in parameter
  98220. * @param scene The scene we are intending to draw
  98221. * @param mesh The mesh the effect is compiling for
  98222. * @param light The light the effect is compiling for
  98223. * @param lightIndex The index of the light
  98224. * @param defines The defines to update
  98225. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98226. * @param state Defines the current state regarding what is needed (normals, etc...)
  98227. */
  98228. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  98229. needNormals: boolean;
  98230. needRebuild: boolean;
  98231. shadowEnabled: boolean;
  98232. specularEnabled: boolean;
  98233. lightmapMode: boolean;
  98234. }): void;
  98235. /**
  98236. * Prepares the defines related to the light information passed in parameter
  98237. * @param scene The scene we are intending to draw
  98238. * @param mesh The mesh the effect is compiling for
  98239. * @param defines The defines to update
  98240. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98241. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  98242. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  98243. * @returns true if normals will be required for the rest of the effect
  98244. */
  98245. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  98246. /**
  98247. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  98248. * @param lightIndex defines the light index
  98249. * @param uniformsList The uniform list
  98250. * @param samplersList The sampler list
  98251. * @param projectedLightTexture defines if projected texture must be used
  98252. * @param uniformBuffersList defines an optional list of uniform buffers
  98253. */
  98254. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  98255. /**
  98256. * Prepares the uniforms and samplers list to be used in the effect
  98257. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  98258. * @param samplersList The sampler list
  98259. * @param defines The defines helping in the list generation
  98260. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  98261. */
  98262. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  98263. /**
  98264. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  98265. * @param defines The defines to update while falling back
  98266. * @param fallbacks The authorized effect fallbacks
  98267. * @param maxSimultaneousLights The maximum number of lights allowed
  98268. * @param rank the current rank of the Effect
  98269. * @returns The newly affected rank
  98270. */
  98271. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  98272. private static _TmpMorphInfluencers;
  98273. /**
  98274. * Prepares the list of attributes required for morph targets according to the effect defines.
  98275. * @param attribs The current list of supported attribs
  98276. * @param mesh The mesh to prepare the morph targets attributes for
  98277. * @param influencers The number of influencers
  98278. */
  98279. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  98280. /**
  98281. * Prepares the list of attributes required for morph targets according to the effect defines.
  98282. * @param attribs The current list of supported attribs
  98283. * @param mesh The mesh to prepare the morph targets attributes for
  98284. * @param defines The current Defines of the effect
  98285. */
  98286. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  98287. /**
  98288. * Prepares the list of attributes required for bones according to the effect defines.
  98289. * @param attribs The current list of supported attribs
  98290. * @param mesh The mesh to prepare the bones attributes for
  98291. * @param defines The current Defines of the effect
  98292. * @param fallbacks The current efffect fallback strategy
  98293. */
  98294. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  98295. /**
  98296. * Check and prepare the list of attributes required for instances according to the effect defines.
  98297. * @param attribs The current list of supported attribs
  98298. * @param defines The current MaterialDefines of the effect
  98299. */
  98300. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  98301. /**
  98302. * Add the list of attributes required for instances to the attribs array.
  98303. * @param attribs The current list of supported attribs
  98304. */
  98305. static PushAttributesForInstances(attribs: string[]): void;
  98306. /**
  98307. * Binds the light information to the effect.
  98308. * @param light The light containing the generator
  98309. * @param effect The effect we are binding the data to
  98310. * @param lightIndex The light index in the effect used to render
  98311. */
  98312. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  98313. /**
  98314. * Binds the lights information from the scene to the effect for the given mesh.
  98315. * @param light Light to bind
  98316. * @param lightIndex Light index
  98317. * @param scene The scene where the light belongs to
  98318. * @param effect The effect we are binding the data to
  98319. * @param useSpecular Defines if specular is supported
  98320. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98321. */
  98322. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98323. /**
  98324. * Binds the lights information from the scene to the effect for the given mesh.
  98325. * @param scene The scene the lights belongs to
  98326. * @param mesh The mesh we are binding the information to render
  98327. * @param effect The effect we are binding the data to
  98328. * @param defines The generated defines for the effect
  98329. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  98330. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98331. */
  98332. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  98333. private static _tempFogColor;
  98334. /**
  98335. * Binds the fog information from the scene to the effect for the given mesh.
  98336. * @param scene The scene the lights belongs to
  98337. * @param mesh The mesh we are binding the information to render
  98338. * @param effect The effect we are binding the data to
  98339. * @param linearSpace Defines if the fog effect is applied in linear space
  98340. */
  98341. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  98342. /**
  98343. * Binds the bones information from the mesh to the effect.
  98344. * @param mesh The mesh we are binding the information to render
  98345. * @param effect The effect we are binding the data to
  98346. */
  98347. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  98348. /**
  98349. * Binds the morph targets information from the mesh to the effect.
  98350. * @param abstractMesh The mesh we are binding the information to render
  98351. * @param effect The effect we are binding the data to
  98352. */
  98353. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  98354. /**
  98355. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  98356. * @param defines The generated defines used in the effect
  98357. * @param effect The effect we are binding the data to
  98358. * @param scene The scene we are willing to render with logarithmic scale for
  98359. */
  98360. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  98361. /**
  98362. * Binds the clip plane information from the scene to the effect.
  98363. * @param scene The scene the clip plane information are extracted from
  98364. * @param effect The effect we are binding the data to
  98365. */
  98366. static BindClipPlane(effect: Effect, scene: Scene): void;
  98367. }
  98368. }
  98369. declare module BABYLON {
  98370. /**
  98371. * Block used to expose an input value
  98372. */
  98373. export class InputBlock extends NodeMaterialBlock {
  98374. private _mode;
  98375. private _associatedVariableName;
  98376. private _storedValue;
  98377. private _valueCallback;
  98378. private _type;
  98379. private _animationType;
  98380. /** Gets or set a value used to limit the range of float values */
  98381. min: number;
  98382. /** Gets or set a value used to limit the range of float values */
  98383. max: number;
  98384. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  98385. isBoolean: boolean;
  98386. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  98387. matrixMode: number;
  98388. /** @hidden */
  98389. _systemValue: Nullable<NodeMaterialSystemValues>;
  98390. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  98391. visibleInInspector: boolean;
  98392. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  98393. isConstant: boolean;
  98394. /** Gets or sets the group to use to display this block in the Inspector */
  98395. groupInInspector: string;
  98396. /** Gets an observable raised when the value is changed */
  98397. onValueChangedObservable: Observable<InputBlock>;
  98398. /**
  98399. * Gets or sets the connection point type (default is float)
  98400. */
  98401. get type(): NodeMaterialBlockConnectionPointTypes;
  98402. /**
  98403. * Creates a new InputBlock
  98404. * @param name defines the block name
  98405. * @param target defines the target of that block (Vertex by default)
  98406. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  98407. */
  98408. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  98409. /**
  98410. * Gets the output component
  98411. */
  98412. get output(): NodeMaterialConnectionPoint;
  98413. /**
  98414. * Set the source of this connection point to a vertex attribute
  98415. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  98416. * @returns the current connection point
  98417. */
  98418. setAsAttribute(attributeName?: string): InputBlock;
  98419. /**
  98420. * Set the source of this connection point to a system value
  98421. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  98422. * @returns the current connection point
  98423. */
  98424. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  98425. /**
  98426. * Gets or sets the value of that point.
  98427. * Please note that this value will be ignored if valueCallback is defined
  98428. */
  98429. get value(): any;
  98430. set value(value: any);
  98431. /**
  98432. * Gets or sets a callback used to get the value of that point.
  98433. * Please note that setting this value will force the connection point to ignore the value property
  98434. */
  98435. get valueCallback(): () => any;
  98436. set valueCallback(value: () => any);
  98437. /**
  98438. * Gets or sets the associated variable name in the shader
  98439. */
  98440. get associatedVariableName(): string;
  98441. set associatedVariableName(value: string);
  98442. /** Gets or sets the type of animation applied to the input */
  98443. get animationType(): AnimatedInputBlockTypes;
  98444. set animationType(value: AnimatedInputBlockTypes);
  98445. /**
  98446. * Gets a boolean indicating that this connection point not defined yet
  98447. */
  98448. get isUndefined(): boolean;
  98449. /**
  98450. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  98451. * In this case the connection point name must be the name of the uniform to use.
  98452. * Can only be set on inputs
  98453. */
  98454. get isUniform(): boolean;
  98455. set isUniform(value: boolean);
  98456. /**
  98457. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  98458. * In this case the connection point name must be the name of the attribute to use
  98459. * Can only be set on inputs
  98460. */
  98461. get isAttribute(): boolean;
  98462. set isAttribute(value: boolean);
  98463. /**
  98464. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  98465. * Can only be set on exit points
  98466. */
  98467. get isVarying(): boolean;
  98468. set isVarying(value: boolean);
  98469. /**
  98470. * Gets a boolean indicating that the current connection point is a system value
  98471. */
  98472. get isSystemValue(): boolean;
  98473. /**
  98474. * Gets or sets the current well known value or null if not defined as a system value
  98475. */
  98476. get systemValue(): Nullable<NodeMaterialSystemValues>;
  98477. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  98478. /**
  98479. * Gets the current class name
  98480. * @returns the class name
  98481. */
  98482. getClassName(): string;
  98483. /**
  98484. * Animate the input if animationType !== None
  98485. * @param scene defines the rendering scene
  98486. */
  98487. animate(scene: Scene): void;
  98488. private _emitDefine;
  98489. initialize(state: NodeMaterialBuildState): void;
  98490. /**
  98491. * Set the input block to its default value (based on its type)
  98492. */
  98493. setDefaultValue(): void;
  98494. private _emitConstant;
  98495. /** @hidden */
  98496. get _noContextSwitch(): boolean;
  98497. private _emit;
  98498. /** @hidden */
  98499. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  98500. /** @hidden */
  98501. _transmit(effect: Effect, scene: Scene): void;
  98502. protected _buildBlock(state: NodeMaterialBuildState): void;
  98503. protected _dumpPropertiesCode(): string;
  98504. dispose(): void;
  98505. serialize(): any;
  98506. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98507. }
  98508. }
  98509. declare module BABYLON {
  98510. /**
  98511. * Enum used to define the compatibility state between two connection points
  98512. */
  98513. export enum NodeMaterialConnectionPointCompatibilityStates {
  98514. /** Points are compatibles */
  98515. Compatible = 0,
  98516. /** Points are incompatible because of their types */
  98517. TypeIncompatible = 1,
  98518. /** Points are incompatible because of their targets (vertex vs fragment) */
  98519. TargetIncompatible = 2
  98520. }
  98521. /**
  98522. * Defines the direction of a connection point
  98523. */
  98524. export enum NodeMaterialConnectionPointDirection {
  98525. /** Input */
  98526. Input = 0,
  98527. /** Output */
  98528. Output = 1
  98529. }
  98530. /**
  98531. * Defines a connection point for a block
  98532. */
  98533. export class NodeMaterialConnectionPoint {
  98534. /** @hidden */
  98535. _ownerBlock: NodeMaterialBlock;
  98536. /** @hidden */
  98537. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  98538. private _endpoints;
  98539. private _associatedVariableName;
  98540. private _direction;
  98541. /** @hidden */
  98542. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98543. /** @hidden */
  98544. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98545. private _type;
  98546. /** @hidden */
  98547. _enforceAssociatedVariableName: boolean;
  98548. /** Gets the direction of the point */
  98549. get direction(): NodeMaterialConnectionPointDirection;
  98550. /** Indicates that this connection point needs dual validation before being connected to another point */
  98551. needDualDirectionValidation: boolean;
  98552. /**
  98553. * Gets or sets the additional types supported by this connection point
  98554. */
  98555. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98556. /**
  98557. * Gets or sets the additional types excluded by this connection point
  98558. */
  98559. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98560. /**
  98561. * Observable triggered when this point is connected
  98562. */
  98563. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  98564. /**
  98565. * Gets or sets the associated variable name in the shader
  98566. */
  98567. get associatedVariableName(): string;
  98568. set associatedVariableName(value: string);
  98569. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  98570. get innerType(): NodeMaterialBlockConnectionPointTypes;
  98571. /**
  98572. * Gets or sets the connection point type (default is float)
  98573. */
  98574. get type(): NodeMaterialBlockConnectionPointTypes;
  98575. set type(value: NodeMaterialBlockConnectionPointTypes);
  98576. /**
  98577. * Gets or sets the connection point name
  98578. */
  98579. name: string;
  98580. /**
  98581. * Gets or sets the connection point name
  98582. */
  98583. displayName: string;
  98584. /**
  98585. * Gets or sets a boolean indicating that this connection point can be omitted
  98586. */
  98587. isOptional: boolean;
  98588. /**
  98589. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  98590. */
  98591. isExposedOnFrame: boolean;
  98592. /**
  98593. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  98594. */
  98595. define: string;
  98596. /** @hidden */
  98597. _prioritizeVertex: boolean;
  98598. private _target;
  98599. /** Gets or sets the target of that connection point */
  98600. get target(): NodeMaterialBlockTargets;
  98601. set target(value: NodeMaterialBlockTargets);
  98602. /**
  98603. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  98604. */
  98605. get isConnected(): boolean;
  98606. /**
  98607. * Gets a boolean indicating that the current point is connected to an input block
  98608. */
  98609. get isConnectedToInputBlock(): boolean;
  98610. /**
  98611. * Gets a the connected input block (if any)
  98612. */
  98613. get connectInputBlock(): Nullable<InputBlock>;
  98614. /** Get the other side of the connection (if any) */
  98615. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  98616. /** Get the block that owns this connection point */
  98617. get ownerBlock(): NodeMaterialBlock;
  98618. /** Get the block connected on the other side of this connection (if any) */
  98619. get sourceBlock(): Nullable<NodeMaterialBlock>;
  98620. /** Get the block connected on the endpoints of this connection (if any) */
  98621. get connectedBlocks(): Array<NodeMaterialBlock>;
  98622. /** Gets the list of connected endpoints */
  98623. get endpoints(): NodeMaterialConnectionPoint[];
  98624. /** Gets a boolean indicating if that output point is connected to at least one input */
  98625. get hasEndpoints(): boolean;
  98626. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  98627. get isConnectedInVertexShader(): boolean;
  98628. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  98629. get isConnectedInFragmentShader(): boolean;
  98630. /**
  98631. * Creates a block suitable to be used as an input for this input point.
  98632. * If null is returned, a block based on the point type will be created.
  98633. * @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
  98634. */
  98635. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98636. /**
  98637. * Creates a new connection point
  98638. * @param name defines the connection point name
  98639. * @param ownerBlock defines the block hosting this connection point
  98640. * @param direction defines the direction of the connection point
  98641. */
  98642. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  98643. /**
  98644. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  98645. * @returns the class name
  98646. */
  98647. getClassName(): string;
  98648. /**
  98649. * Gets a boolean indicating if the current point can be connected to another point
  98650. * @param connectionPoint defines the other connection point
  98651. * @returns a boolean
  98652. */
  98653. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  98654. /**
  98655. * Gets a number indicating if the current point can be connected to another point
  98656. * @param connectionPoint defines the other connection point
  98657. * @returns a number defining the compatibility state
  98658. */
  98659. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98660. /**
  98661. * Connect this point to another connection point
  98662. * @param connectionPoint defines the other connection point
  98663. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  98664. * @returns the current connection point
  98665. */
  98666. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  98667. /**
  98668. * Disconnect this point from one of his endpoint
  98669. * @param endpoint defines the other connection point
  98670. * @returns the current connection point
  98671. */
  98672. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  98673. /**
  98674. * Serializes this point in a JSON representation
  98675. * @param isInput defines if the connection point is an input (default is true)
  98676. * @returns the serialized point object
  98677. */
  98678. serialize(isInput?: boolean): any;
  98679. /**
  98680. * Release resources
  98681. */
  98682. dispose(): void;
  98683. }
  98684. }
  98685. declare module BABYLON {
  98686. /**
  98687. * Enum used to define the material modes
  98688. */
  98689. export enum NodeMaterialModes {
  98690. /** Regular material */
  98691. Material = 0,
  98692. /** For post process */
  98693. PostProcess = 1,
  98694. /** For particle system */
  98695. Particle = 2
  98696. }
  98697. }
  98698. declare module BABYLON {
  98699. /**
  98700. * Block used to read a texture from a sampler
  98701. */
  98702. export class TextureBlock extends NodeMaterialBlock {
  98703. private _defineName;
  98704. private _linearDefineName;
  98705. private _gammaDefineName;
  98706. private _tempTextureRead;
  98707. private _samplerName;
  98708. private _transformedUVName;
  98709. private _textureTransformName;
  98710. private _textureInfoName;
  98711. private _mainUVName;
  98712. private _mainUVDefineName;
  98713. private _fragmentOnly;
  98714. /**
  98715. * Gets or sets the texture associated with the node
  98716. */
  98717. texture: Nullable<Texture>;
  98718. /**
  98719. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98720. */
  98721. convertToGammaSpace: boolean;
  98722. /**
  98723. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98724. */
  98725. convertToLinearSpace: boolean;
  98726. /**
  98727. * Create a new TextureBlock
  98728. * @param name defines the block name
  98729. */
  98730. constructor(name: string, fragmentOnly?: boolean);
  98731. /**
  98732. * Gets the current class name
  98733. * @returns the class name
  98734. */
  98735. getClassName(): string;
  98736. /**
  98737. * Gets the uv input component
  98738. */
  98739. get uv(): NodeMaterialConnectionPoint;
  98740. /**
  98741. * Gets the rgba output component
  98742. */
  98743. get rgba(): NodeMaterialConnectionPoint;
  98744. /**
  98745. * Gets the rgb output component
  98746. */
  98747. get rgb(): NodeMaterialConnectionPoint;
  98748. /**
  98749. * Gets the r output component
  98750. */
  98751. get r(): NodeMaterialConnectionPoint;
  98752. /**
  98753. * Gets the g output component
  98754. */
  98755. get g(): NodeMaterialConnectionPoint;
  98756. /**
  98757. * Gets the b output component
  98758. */
  98759. get b(): NodeMaterialConnectionPoint;
  98760. /**
  98761. * Gets the a output component
  98762. */
  98763. get a(): NodeMaterialConnectionPoint;
  98764. get target(): NodeMaterialBlockTargets;
  98765. autoConfigure(material: NodeMaterial): void;
  98766. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98768. isReady(): boolean;
  98769. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98770. private get _isMixed();
  98771. private _injectVertexCode;
  98772. private _writeTextureRead;
  98773. private _writeOutput;
  98774. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98775. protected _dumpPropertiesCode(): string;
  98776. serialize(): any;
  98777. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98778. }
  98779. }
  98780. declare module BABYLON {
  98781. /** @hidden */
  98782. export var reflectionFunction: {
  98783. name: string;
  98784. shader: string;
  98785. };
  98786. }
  98787. declare module BABYLON {
  98788. /**
  98789. * Base block used to read a reflection texture from a sampler
  98790. */
  98791. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  98792. /** @hidden */
  98793. _define3DName: string;
  98794. /** @hidden */
  98795. _defineCubicName: string;
  98796. /** @hidden */
  98797. _defineExplicitName: string;
  98798. /** @hidden */
  98799. _defineProjectionName: string;
  98800. /** @hidden */
  98801. _defineLocalCubicName: string;
  98802. /** @hidden */
  98803. _defineSphericalName: string;
  98804. /** @hidden */
  98805. _definePlanarName: string;
  98806. /** @hidden */
  98807. _defineEquirectangularName: string;
  98808. /** @hidden */
  98809. _defineMirroredEquirectangularFixedName: string;
  98810. /** @hidden */
  98811. _defineEquirectangularFixedName: string;
  98812. /** @hidden */
  98813. _defineSkyboxName: string;
  98814. /** @hidden */
  98815. _defineOppositeZ: string;
  98816. /** @hidden */
  98817. _cubeSamplerName: string;
  98818. /** @hidden */
  98819. _2DSamplerName: string;
  98820. protected _positionUVWName: string;
  98821. protected _directionWName: string;
  98822. protected _reflectionVectorName: string;
  98823. /** @hidden */
  98824. _reflectionCoordsName: string;
  98825. /** @hidden */
  98826. _reflectionMatrixName: string;
  98827. protected _reflectionColorName: string;
  98828. /**
  98829. * Gets or sets the texture associated with the node
  98830. */
  98831. texture: Nullable<BaseTexture>;
  98832. /**
  98833. * Create a new ReflectionTextureBaseBlock
  98834. * @param name defines the block name
  98835. */
  98836. constructor(name: string);
  98837. /**
  98838. * Gets the current class name
  98839. * @returns the class name
  98840. */
  98841. getClassName(): string;
  98842. /**
  98843. * Gets the world position input component
  98844. */
  98845. abstract get position(): NodeMaterialConnectionPoint;
  98846. /**
  98847. * Gets the world position input component
  98848. */
  98849. abstract get worldPosition(): NodeMaterialConnectionPoint;
  98850. /**
  98851. * Gets the world normal input component
  98852. */
  98853. abstract get worldNormal(): NodeMaterialConnectionPoint;
  98854. /**
  98855. * Gets the world input component
  98856. */
  98857. abstract get world(): NodeMaterialConnectionPoint;
  98858. /**
  98859. * Gets the camera (or eye) position component
  98860. */
  98861. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  98862. /**
  98863. * Gets the view input component
  98864. */
  98865. abstract get view(): NodeMaterialConnectionPoint;
  98866. protected _getTexture(): Nullable<BaseTexture>;
  98867. autoConfigure(material: NodeMaterial): void;
  98868. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98869. isReady(): boolean;
  98870. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98871. /**
  98872. * Gets the code to inject in the vertex shader
  98873. * @param state current state of the node material building
  98874. * @returns the shader code
  98875. */
  98876. handleVertexSide(state: NodeMaterialBuildState): string;
  98877. /**
  98878. * Handles the inits for the fragment code path
  98879. * @param state node material build state
  98880. */
  98881. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  98882. /**
  98883. * Generates the reflection coords code for the fragment code path
  98884. * @param worldNormalVarName name of the world normal variable
  98885. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  98886. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  98887. * @returns the shader code
  98888. */
  98889. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  98890. /**
  98891. * Generates the reflection color code for the fragment code path
  98892. * @param lodVarName name of the lod variable
  98893. * @param swizzleLookupTexture swizzle to use for the final color variable
  98894. * @returns the shader code
  98895. */
  98896. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  98897. /**
  98898. * Generates the code corresponding to the connected output points
  98899. * @param state node material build state
  98900. * @param varName name of the variable to output
  98901. * @returns the shader code
  98902. */
  98903. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  98904. protected _buildBlock(state: NodeMaterialBuildState): this;
  98905. protected _dumpPropertiesCode(): string;
  98906. serialize(): any;
  98907. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98908. }
  98909. }
  98910. declare module BABYLON {
  98911. /**
  98912. * Defines a connection point to be used for points with a custom object type
  98913. */
  98914. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  98915. private _blockType;
  98916. private _blockName;
  98917. private _nameForCheking?;
  98918. /**
  98919. * Creates a new connection point
  98920. * @param name defines the connection point name
  98921. * @param ownerBlock defines the block hosting this connection point
  98922. * @param direction defines the direction of the connection point
  98923. */
  98924. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  98925. /**
  98926. * Gets a number indicating if the current point can be connected to another point
  98927. * @param connectionPoint defines the other connection point
  98928. * @returns a number defining the compatibility state
  98929. */
  98930. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98931. /**
  98932. * Creates a block suitable to be used as an input for this input point.
  98933. * If null is returned, a block based on the point type will be created.
  98934. * @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
  98935. */
  98936. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98937. }
  98938. }
  98939. declare module BABYLON {
  98940. /**
  98941. * Enum defining the type of properties that can be edited in the property pages in the NME
  98942. */
  98943. export enum PropertyTypeForEdition {
  98944. /** property is a boolean */
  98945. Boolean = 0,
  98946. /** property is a float */
  98947. Float = 1,
  98948. /** property is a Vector2 */
  98949. Vector2 = 2,
  98950. /** property is a list of values */
  98951. List = 3
  98952. }
  98953. /**
  98954. * Interface that defines an option in a variable of type list
  98955. */
  98956. export interface IEditablePropertyListOption {
  98957. /** label of the option */
  98958. "label": string;
  98959. /** value of the option */
  98960. "value": number;
  98961. }
  98962. /**
  98963. * Interface that defines the options available for an editable property
  98964. */
  98965. export interface IEditablePropertyOption {
  98966. /** min value */
  98967. "min"?: number;
  98968. /** max value */
  98969. "max"?: number;
  98970. /** notifiers: indicates which actions to take when the property is changed */
  98971. "notifiers"?: {
  98972. /** the material should be rebuilt */
  98973. "rebuild"?: boolean;
  98974. /** the preview should be updated */
  98975. "update"?: boolean;
  98976. };
  98977. /** list of the options for a variable of type list */
  98978. "options"?: IEditablePropertyListOption[];
  98979. }
  98980. /**
  98981. * Interface that describes an editable property
  98982. */
  98983. export interface IPropertyDescriptionForEdition {
  98984. /** name of the property */
  98985. "propertyName": string;
  98986. /** display name of the property */
  98987. "displayName": string;
  98988. /** type of the property */
  98989. "type": PropertyTypeForEdition;
  98990. /** group of the property - all properties with the same group value will be displayed in a specific section */
  98991. "groupName": string;
  98992. /** options for the property */
  98993. "options": IEditablePropertyOption;
  98994. }
  98995. /**
  98996. * Decorator that flags a property in a node material block as being editable
  98997. */
  98998. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98999. }
  99000. declare module BABYLON {
  99001. /**
  99002. * Block used to implement the refraction part of the sub surface module of the PBR material
  99003. */
  99004. export class RefractionBlock extends NodeMaterialBlock {
  99005. /** @hidden */
  99006. _define3DName: string;
  99007. /** @hidden */
  99008. _refractionMatrixName: string;
  99009. /** @hidden */
  99010. _defineLODRefractionAlpha: string;
  99011. /** @hidden */
  99012. _defineLinearSpecularRefraction: string;
  99013. /** @hidden */
  99014. _defineOppositeZ: string;
  99015. /** @hidden */
  99016. _cubeSamplerName: string;
  99017. /** @hidden */
  99018. _2DSamplerName: string;
  99019. /** @hidden */
  99020. _vRefractionMicrosurfaceInfosName: string;
  99021. /** @hidden */
  99022. _vRefractionInfosName: string;
  99023. private _scene;
  99024. /**
  99025. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99026. * Materials half opaque for instance using refraction could benefit from this control.
  99027. */
  99028. linkRefractionWithTransparency: boolean;
  99029. /**
  99030. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99031. */
  99032. invertRefractionY: boolean;
  99033. /**
  99034. * Gets or sets the texture associated with the node
  99035. */
  99036. texture: Nullable<BaseTexture>;
  99037. /**
  99038. * Create a new RefractionBlock
  99039. * @param name defines the block name
  99040. */
  99041. constructor(name: string);
  99042. /**
  99043. * Gets the current class name
  99044. * @returns the class name
  99045. */
  99046. getClassName(): string;
  99047. /**
  99048. * Gets the intensity input component
  99049. */
  99050. get intensity(): NodeMaterialConnectionPoint;
  99051. /**
  99052. * Gets the index of refraction input component
  99053. */
  99054. get indexOfRefraction(): NodeMaterialConnectionPoint;
  99055. /**
  99056. * Gets the tint at distance input component
  99057. */
  99058. get tintAtDistance(): NodeMaterialConnectionPoint;
  99059. /**
  99060. * Gets the view input component
  99061. */
  99062. get view(): NodeMaterialConnectionPoint;
  99063. /**
  99064. * Gets the refraction object output component
  99065. */
  99066. get refraction(): NodeMaterialConnectionPoint;
  99067. /**
  99068. * Returns true if the block has a texture
  99069. */
  99070. get hasTexture(): boolean;
  99071. protected _getTexture(): Nullable<BaseTexture>;
  99072. autoConfigure(material: NodeMaterial): void;
  99073. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99074. isReady(): boolean;
  99075. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99076. /**
  99077. * Gets the main code of the block (fragment side)
  99078. * @param state current state of the node material building
  99079. * @returns the shader code
  99080. */
  99081. getCode(state: NodeMaterialBuildState): string;
  99082. protected _buildBlock(state: NodeMaterialBuildState): this;
  99083. protected _dumpPropertiesCode(): string;
  99084. serialize(): any;
  99085. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99086. }
  99087. }
  99088. declare module BABYLON {
  99089. /**
  99090. * Base block used as input for post process
  99091. */
  99092. export class CurrentScreenBlock extends NodeMaterialBlock {
  99093. private _samplerName;
  99094. private _linearDefineName;
  99095. private _gammaDefineName;
  99096. private _mainUVName;
  99097. private _tempTextureRead;
  99098. /**
  99099. * Gets or sets the texture associated with the node
  99100. */
  99101. texture: Nullable<BaseTexture>;
  99102. /**
  99103. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99104. */
  99105. convertToGammaSpace: boolean;
  99106. /**
  99107. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99108. */
  99109. convertToLinearSpace: boolean;
  99110. /**
  99111. * Create a new CurrentScreenBlock
  99112. * @param name defines the block name
  99113. */
  99114. constructor(name: string);
  99115. /**
  99116. * Gets the current class name
  99117. * @returns the class name
  99118. */
  99119. getClassName(): string;
  99120. /**
  99121. * Gets the uv input component
  99122. */
  99123. get uv(): NodeMaterialConnectionPoint;
  99124. /**
  99125. * Gets the rgba output component
  99126. */
  99127. get rgba(): NodeMaterialConnectionPoint;
  99128. /**
  99129. * Gets the rgb output component
  99130. */
  99131. get rgb(): NodeMaterialConnectionPoint;
  99132. /**
  99133. * Gets the r output component
  99134. */
  99135. get r(): NodeMaterialConnectionPoint;
  99136. /**
  99137. * Gets the g output component
  99138. */
  99139. get g(): NodeMaterialConnectionPoint;
  99140. /**
  99141. * Gets the b output component
  99142. */
  99143. get b(): NodeMaterialConnectionPoint;
  99144. /**
  99145. * Gets the a output component
  99146. */
  99147. get a(): NodeMaterialConnectionPoint;
  99148. /**
  99149. * Initialize the block and prepare the context for build
  99150. * @param state defines the state that will be used for the build
  99151. */
  99152. initialize(state: NodeMaterialBuildState): void;
  99153. get target(): NodeMaterialBlockTargets;
  99154. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99155. isReady(): boolean;
  99156. private _injectVertexCode;
  99157. private _writeTextureRead;
  99158. private _writeOutput;
  99159. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99160. serialize(): any;
  99161. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99162. }
  99163. }
  99164. declare module BABYLON {
  99165. /**
  99166. * Base block used for the particle texture
  99167. */
  99168. export class ParticleTextureBlock extends NodeMaterialBlock {
  99169. private _samplerName;
  99170. private _linearDefineName;
  99171. private _gammaDefineName;
  99172. private _tempTextureRead;
  99173. /**
  99174. * Gets or sets the texture associated with the node
  99175. */
  99176. texture: Nullable<BaseTexture>;
  99177. /**
  99178. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99179. */
  99180. convertToGammaSpace: boolean;
  99181. /**
  99182. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99183. */
  99184. convertToLinearSpace: boolean;
  99185. /**
  99186. * Create a new ParticleTextureBlock
  99187. * @param name defines the block name
  99188. */
  99189. constructor(name: string);
  99190. /**
  99191. * Gets the current class name
  99192. * @returns the class name
  99193. */
  99194. getClassName(): string;
  99195. /**
  99196. * Gets the uv input component
  99197. */
  99198. get uv(): NodeMaterialConnectionPoint;
  99199. /**
  99200. * Gets the rgba output component
  99201. */
  99202. get rgba(): NodeMaterialConnectionPoint;
  99203. /**
  99204. * Gets the rgb output component
  99205. */
  99206. get rgb(): NodeMaterialConnectionPoint;
  99207. /**
  99208. * Gets the r output component
  99209. */
  99210. get r(): NodeMaterialConnectionPoint;
  99211. /**
  99212. * Gets the g output component
  99213. */
  99214. get g(): NodeMaterialConnectionPoint;
  99215. /**
  99216. * Gets the b output component
  99217. */
  99218. get b(): NodeMaterialConnectionPoint;
  99219. /**
  99220. * Gets the a output component
  99221. */
  99222. get a(): NodeMaterialConnectionPoint;
  99223. /**
  99224. * Initialize the block and prepare the context for build
  99225. * @param state defines the state that will be used for the build
  99226. */
  99227. initialize(state: NodeMaterialBuildState): void;
  99228. autoConfigure(material: NodeMaterial): void;
  99229. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99230. isReady(): boolean;
  99231. private _writeOutput;
  99232. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99233. serialize(): any;
  99234. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99235. }
  99236. }
  99237. declare module BABYLON {
  99238. /**
  99239. * Class used to store shared data between 2 NodeMaterialBuildState
  99240. */
  99241. export class NodeMaterialBuildStateSharedData {
  99242. /**
  99243. * Gets the list of emitted varyings
  99244. */
  99245. temps: string[];
  99246. /**
  99247. * Gets the list of emitted varyings
  99248. */
  99249. varyings: string[];
  99250. /**
  99251. * Gets the varying declaration string
  99252. */
  99253. varyingDeclaration: string;
  99254. /**
  99255. * Input blocks
  99256. */
  99257. inputBlocks: InputBlock[];
  99258. /**
  99259. * Input blocks
  99260. */
  99261. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99262. /**
  99263. * Bindable blocks (Blocks that need to set data to the effect)
  99264. */
  99265. bindableBlocks: NodeMaterialBlock[];
  99266. /**
  99267. * List of blocks that can provide a compilation fallback
  99268. */
  99269. blocksWithFallbacks: NodeMaterialBlock[];
  99270. /**
  99271. * List of blocks that can provide a define update
  99272. */
  99273. blocksWithDefines: NodeMaterialBlock[];
  99274. /**
  99275. * List of blocks that can provide a repeatable content
  99276. */
  99277. repeatableContentBlocks: NodeMaterialBlock[];
  99278. /**
  99279. * List of blocks that can provide a dynamic list of uniforms
  99280. */
  99281. dynamicUniformBlocks: NodeMaterialBlock[];
  99282. /**
  99283. * List of blocks that can block the isReady function for the material
  99284. */
  99285. blockingBlocks: NodeMaterialBlock[];
  99286. /**
  99287. * Gets the list of animated inputs
  99288. */
  99289. animatedInputs: InputBlock[];
  99290. /**
  99291. * Build Id used to avoid multiple recompilations
  99292. */
  99293. buildId: number;
  99294. /** List of emitted variables */
  99295. variableNames: {
  99296. [key: string]: number;
  99297. };
  99298. /** List of emitted defines */
  99299. defineNames: {
  99300. [key: string]: number;
  99301. };
  99302. /** Should emit comments? */
  99303. emitComments: boolean;
  99304. /** Emit build activity */
  99305. verbose: boolean;
  99306. /** Gets or sets the hosting scene */
  99307. scene: Scene;
  99308. /**
  99309. * Gets the compilation hints emitted at compilation time
  99310. */
  99311. hints: {
  99312. needWorldViewMatrix: boolean;
  99313. needWorldViewProjectionMatrix: boolean;
  99314. needAlphaBlending: boolean;
  99315. needAlphaTesting: boolean;
  99316. };
  99317. /**
  99318. * List of compilation checks
  99319. */
  99320. checks: {
  99321. emitVertex: boolean;
  99322. emitFragment: boolean;
  99323. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  99324. };
  99325. /**
  99326. * Is vertex program allowed to be empty?
  99327. */
  99328. allowEmptyVertexProgram: boolean;
  99329. /** Creates a new shared data */
  99330. constructor();
  99331. /**
  99332. * Emits console errors and exceptions if there is a failing check
  99333. */
  99334. emitErrors(): void;
  99335. }
  99336. }
  99337. declare module BABYLON {
  99338. /**
  99339. * Class used to store node based material build state
  99340. */
  99341. export class NodeMaterialBuildState {
  99342. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  99343. supportUniformBuffers: boolean;
  99344. /**
  99345. * Gets the list of emitted attributes
  99346. */
  99347. attributes: string[];
  99348. /**
  99349. * Gets the list of emitted uniforms
  99350. */
  99351. uniforms: string[];
  99352. /**
  99353. * Gets the list of emitted constants
  99354. */
  99355. constants: string[];
  99356. /**
  99357. * Gets the list of emitted samplers
  99358. */
  99359. samplers: string[];
  99360. /**
  99361. * Gets the list of emitted functions
  99362. */
  99363. functions: {
  99364. [key: string]: string;
  99365. };
  99366. /**
  99367. * Gets the list of emitted extensions
  99368. */
  99369. extensions: {
  99370. [key: string]: string;
  99371. };
  99372. /**
  99373. * Gets the target of the compilation state
  99374. */
  99375. target: NodeMaterialBlockTargets;
  99376. /**
  99377. * Gets the list of emitted counters
  99378. */
  99379. counters: {
  99380. [key: string]: number;
  99381. };
  99382. /**
  99383. * Shared data between multiple NodeMaterialBuildState instances
  99384. */
  99385. sharedData: NodeMaterialBuildStateSharedData;
  99386. /** @hidden */
  99387. _vertexState: NodeMaterialBuildState;
  99388. /** @hidden */
  99389. _attributeDeclaration: string;
  99390. /** @hidden */
  99391. _uniformDeclaration: string;
  99392. /** @hidden */
  99393. _constantDeclaration: string;
  99394. /** @hidden */
  99395. _samplerDeclaration: string;
  99396. /** @hidden */
  99397. _varyingTransfer: string;
  99398. /** @hidden */
  99399. _injectAtEnd: string;
  99400. private _repeatableContentAnchorIndex;
  99401. /** @hidden */
  99402. _builtCompilationString: string;
  99403. /**
  99404. * Gets the emitted compilation strings
  99405. */
  99406. compilationString: string;
  99407. /**
  99408. * Finalize the compilation strings
  99409. * @param state defines the current compilation state
  99410. */
  99411. finalize(state: NodeMaterialBuildState): void;
  99412. /** @hidden */
  99413. get _repeatableContentAnchor(): string;
  99414. /** @hidden */
  99415. _getFreeVariableName(prefix: string): string;
  99416. /** @hidden */
  99417. _getFreeDefineName(prefix: string): string;
  99418. /** @hidden */
  99419. _excludeVariableName(name: string): void;
  99420. /** @hidden */
  99421. _emit2DSampler(name: string): void;
  99422. /** @hidden */
  99423. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  99424. /** @hidden */
  99425. _emitExtension(name: string, extension: string, define?: string): void;
  99426. /** @hidden */
  99427. _emitFunction(name: string, code: string, comments: string): void;
  99428. /** @hidden */
  99429. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  99430. replaceStrings?: {
  99431. search: RegExp;
  99432. replace: string;
  99433. }[];
  99434. repeatKey?: string;
  99435. }): string;
  99436. /** @hidden */
  99437. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  99438. repeatKey?: string;
  99439. removeAttributes?: boolean;
  99440. removeUniforms?: boolean;
  99441. removeVaryings?: boolean;
  99442. removeIfDef?: boolean;
  99443. replaceStrings?: {
  99444. search: RegExp;
  99445. replace: string;
  99446. }[];
  99447. }, storeKey?: string): void;
  99448. /** @hidden */
  99449. _registerTempVariable(name: string): boolean;
  99450. /** @hidden */
  99451. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  99452. /** @hidden */
  99453. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  99454. /** @hidden */
  99455. _emitFloat(value: number): string;
  99456. }
  99457. }
  99458. declare module BABYLON {
  99459. /**
  99460. * Helper class used to generate session unique ID
  99461. */
  99462. export class UniqueIdGenerator {
  99463. private static _UniqueIdCounter;
  99464. /**
  99465. * Gets an unique (relatively to the current scene) Id
  99466. */
  99467. static get UniqueId(): number;
  99468. }
  99469. }
  99470. declare module BABYLON {
  99471. /**
  99472. * Defines a block that can be used inside a node based material
  99473. */
  99474. export class NodeMaterialBlock {
  99475. private _buildId;
  99476. private _buildTarget;
  99477. private _target;
  99478. private _isFinalMerger;
  99479. private _isInput;
  99480. protected _isUnique: boolean;
  99481. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  99482. inputsAreExclusive: boolean;
  99483. /** @hidden */
  99484. _codeVariableName: string;
  99485. /** @hidden */
  99486. _inputs: NodeMaterialConnectionPoint[];
  99487. /** @hidden */
  99488. _outputs: NodeMaterialConnectionPoint[];
  99489. /** @hidden */
  99490. _preparationId: number;
  99491. /**
  99492. * Gets or sets the name of the block
  99493. */
  99494. name: string;
  99495. /**
  99496. * Gets or sets the unique id of the node
  99497. */
  99498. uniqueId: number;
  99499. /**
  99500. * Gets or sets the comments associated with this block
  99501. */
  99502. comments: string;
  99503. /**
  99504. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  99505. */
  99506. get isUnique(): boolean;
  99507. /**
  99508. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  99509. */
  99510. get isFinalMerger(): boolean;
  99511. /**
  99512. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  99513. */
  99514. get isInput(): boolean;
  99515. /**
  99516. * Gets or sets the build Id
  99517. */
  99518. get buildId(): number;
  99519. set buildId(value: number);
  99520. /**
  99521. * Gets or sets the target of the block
  99522. */
  99523. get target(): NodeMaterialBlockTargets;
  99524. set target(value: NodeMaterialBlockTargets);
  99525. /**
  99526. * Gets the list of input points
  99527. */
  99528. get inputs(): NodeMaterialConnectionPoint[];
  99529. /** Gets the list of output points */
  99530. get outputs(): NodeMaterialConnectionPoint[];
  99531. /**
  99532. * Find an input by its name
  99533. * @param name defines the name of the input to look for
  99534. * @returns the input or null if not found
  99535. */
  99536. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99537. /**
  99538. * Find an output by its name
  99539. * @param name defines the name of the outputto look for
  99540. * @returns the output or null if not found
  99541. */
  99542. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99543. /**
  99544. * Creates a new NodeMaterialBlock
  99545. * @param name defines the block name
  99546. * @param target defines the target of that block (Vertex by default)
  99547. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  99548. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  99549. */
  99550. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  99551. /**
  99552. * Initialize the block and prepare the context for build
  99553. * @param state defines the state that will be used for the build
  99554. */
  99555. initialize(state: NodeMaterialBuildState): void;
  99556. /**
  99557. * Bind data to effect. Will only be called for blocks with isBindable === true
  99558. * @param effect defines the effect to bind data to
  99559. * @param nodeMaterial defines the hosting NodeMaterial
  99560. * @param mesh defines the mesh that will be rendered
  99561. * @param subMesh defines the submesh that will be rendered
  99562. */
  99563. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99564. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  99565. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  99566. protected _writeFloat(value: number): string;
  99567. /**
  99568. * Gets the current class name e.g. "NodeMaterialBlock"
  99569. * @returns the class name
  99570. */
  99571. getClassName(): string;
  99572. /**
  99573. * Register a new input. Must be called inside a block constructor
  99574. * @param name defines the connection point name
  99575. * @param type defines the connection point type
  99576. * @param isOptional defines a boolean indicating that this input can be omitted
  99577. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99578. * @param point an already created connection point. If not provided, create a new one
  99579. * @returns the current block
  99580. */
  99581. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99582. /**
  99583. * Register a new output. Must be called inside a block constructor
  99584. * @param name defines the connection point name
  99585. * @param type defines the connection point type
  99586. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99587. * @param point an already created connection point. If not provided, create a new one
  99588. * @returns the current block
  99589. */
  99590. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99591. /**
  99592. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  99593. * @param forOutput defines an optional connection point to check compatibility with
  99594. * @returns the first available input or null
  99595. */
  99596. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  99597. /**
  99598. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  99599. * @param forBlock defines an optional block to check compatibility with
  99600. * @returns the first available input or null
  99601. */
  99602. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  99603. /**
  99604. * Gets the sibling of the given output
  99605. * @param current defines the current output
  99606. * @returns the next output in the list or null
  99607. */
  99608. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  99609. /**
  99610. * Connect current block with another block
  99611. * @param other defines the block to connect with
  99612. * @param options define the various options to help pick the right connections
  99613. * @returns the current block
  99614. */
  99615. connectTo(other: NodeMaterialBlock, options?: {
  99616. input?: string;
  99617. output?: string;
  99618. outputSwizzle?: string;
  99619. }): this | undefined;
  99620. protected _buildBlock(state: NodeMaterialBuildState): void;
  99621. /**
  99622. * Add uniforms, samplers and uniform buffers at compilation time
  99623. * @param state defines the state to update
  99624. * @param nodeMaterial defines the node material requesting the update
  99625. * @param defines defines the material defines to update
  99626. * @param uniformBuffers defines the list of uniform buffer names
  99627. */
  99628. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  99629. /**
  99630. * Add potential fallbacks if shader compilation fails
  99631. * @param mesh defines the mesh to be rendered
  99632. * @param fallbacks defines the current prioritized list of fallbacks
  99633. */
  99634. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  99635. /**
  99636. * Initialize defines for shader compilation
  99637. * @param mesh defines the mesh to be rendered
  99638. * @param nodeMaterial defines the node material requesting the update
  99639. * @param defines defines the material defines to update
  99640. * @param useInstances specifies that instances should be used
  99641. */
  99642. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99643. /**
  99644. * Update defines for shader compilation
  99645. * @param mesh defines the mesh to be rendered
  99646. * @param nodeMaterial defines the node material requesting the update
  99647. * @param defines defines the material defines to update
  99648. * @param useInstances specifies that instances should be used
  99649. * @param subMesh defines which submesh to render
  99650. */
  99651. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99652. /**
  99653. * Lets the block try to connect some inputs automatically
  99654. * @param material defines the hosting NodeMaterial
  99655. */
  99656. autoConfigure(material: NodeMaterial): void;
  99657. /**
  99658. * Function called when a block is declared as repeatable content generator
  99659. * @param vertexShaderState defines the current compilation state for the vertex shader
  99660. * @param fragmentShaderState defines the current compilation state for the fragment shader
  99661. * @param mesh defines the mesh to be rendered
  99662. * @param defines defines the material defines to update
  99663. */
  99664. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  99665. /**
  99666. * Checks if the block is ready
  99667. * @param mesh defines the mesh to be rendered
  99668. * @param nodeMaterial defines the node material requesting the update
  99669. * @param defines defines the material defines to update
  99670. * @param useInstances specifies that instances should be used
  99671. * @returns true if the block is ready
  99672. */
  99673. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  99674. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  99675. private _processBuild;
  99676. /**
  99677. * Compile the current node and generate the shader code
  99678. * @param state defines the current compilation state (uniforms, samplers, current string)
  99679. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  99680. * @returns true if already built
  99681. */
  99682. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  99683. protected _inputRename(name: string): string;
  99684. protected _outputRename(name: string): string;
  99685. protected _dumpPropertiesCode(): string;
  99686. /** @hidden */
  99687. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  99688. /** @hidden */
  99689. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  99690. /**
  99691. * Clone the current block to a new identical block
  99692. * @param scene defines the hosting scene
  99693. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99694. * @returns a copy of the current block
  99695. */
  99696. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  99697. /**
  99698. * Serializes this block in a JSON representation
  99699. * @returns the serialized block object
  99700. */
  99701. serialize(): any;
  99702. /** @hidden */
  99703. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99704. private _deserializePortDisplayNamesAndExposedOnFrame;
  99705. /**
  99706. * Release resources
  99707. */
  99708. dispose(): void;
  99709. }
  99710. }
  99711. declare module BABYLON {
  99712. /**
  99713. * Base class of materials working in push mode in babylon JS
  99714. * @hidden
  99715. */
  99716. export class PushMaterial extends Material {
  99717. protected _activeEffect: Effect;
  99718. protected _normalMatrix: Matrix;
  99719. constructor(name: string, scene: Scene);
  99720. getEffect(): Effect;
  99721. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99722. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  99723. /**
  99724. * Binds the given world matrix to the active effect
  99725. *
  99726. * @param world the matrix to bind
  99727. */
  99728. bindOnlyWorldMatrix(world: Matrix): void;
  99729. /**
  99730. * Binds the given normal matrix to the active effect
  99731. *
  99732. * @param normalMatrix the matrix to bind
  99733. */
  99734. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99735. bind(world: Matrix, mesh?: Mesh): void;
  99736. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99737. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99738. }
  99739. }
  99740. declare module BABYLON {
  99741. /**
  99742. * Root class for all node material optimizers
  99743. */
  99744. export class NodeMaterialOptimizer {
  99745. /**
  99746. * Function used to optimize a NodeMaterial graph
  99747. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  99748. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  99749. */
  99750. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  99751. }
  99752. }
  99753. declare module BABYLON {
  99754. /**
  99755. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  99756. */
  99757. export class TransformBlock extends NodeMaterialBlock {
  99758. /**
  99759. * Defines the value to use to complement W value to transform it to a Vector4
  99760. */
  99761. complementW: number;
  99762. /**
  99763. * Defines the value to use to complement z value to transform it to a Vector4
  99764. */
  99765. complementZ: number;
  99766. /**
  99767. * Creates a new TransformBlock
  99768. * @param name defines the block name
  99769. */
  99770. constructor(name: string);
  99771. /**
  99772. * Gets the current class name
  99773. * @returns the class name
  99774. */
  99775. getClassName(): string;
  99776. /**
  99777. * Gets the vector input
  99778. */
  99779. get vector(): NodeMaterialConnectionPoint;
  99780. /**
  99781. * Gets the output component
  99782. */
  99783. get output(): NodeMaterialConnectionPoint;
  99784. /**
  99785. * Gets the xyz output component
  99786. */
  99787. get xyz(): NodeMaterialConnectionPoint;
  99788. /**
  99789. * Gets the matrix transform input
  99790. */
  99791. get transform(): NodeMaterialConnectionPoint;
  99792. protected _buildBlock(state: NodeMaterialBuildState): this;
  99793. /**
  99794. * Update defines for shader compilation
  99795. * @param mesh defines the mesh to be rendered
  99796. * @param nodeMaterial defines the node material requesting the update
  99797. * @param defines defines the material defines to update
  99798. * @param useInstances specifies that instances should be used
  99799. * @param subMesh defines which submesh to render
  99800. */
  99801. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99802. serialize(): any;
  99803. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99804. protected _dumpPropertiesCode(): string;
  99805. }
  99806. }
  99807. declare module BABYLON {
  99808. /**
  99809. * Block used to output the vertex position
  99810. */
  99811. export class VertexOutputBlock extends NodeMaterialBlock {
  99812. /**
  99813. * Creates a new VertexOutputBlock
  99814. * @param name defines the block name
  99815. */
  99816. constructor(name: string);
  99817. /**
  99818. * Gets the current class name
  99819. * @returns the class name
  99820. */
  99821. getClassName(): string;
  99822. /**
  99823. * Gets the vector input component
  99824. */
  99825. get vector(): NodeMaterialConnectionPoint;
  99826. protected _buildBlock(state: NodeMaterialBuildState): this;
  99827. }
  99828. }
  99829. declare module BABYLON {
  99830. /**
  99831. * Block used to output the final color
  99832. */
  99833. export class FragmentOutputBlock extends NodeMaterialBlock {
  99834. /**
  99835. * Create a new FragmentOutputBlock
  99836. * @param name defines the block name
  99837. */
  99838. constructor(name: string);
  99839. /**
  99840. * Gets the current class name
  99841. * @returns the class name
  99842. */
  99843. getClassName(): string;
  99844. /**
  99845. * Gets the rgba input component
  99846. */
  99847. get rgba(): NodeMaterialConnectionPoint;
  99848. /**
  99849. * Gets the rgb input component
  99850. */
  99851. get rgb(): NodeMaterialConnectionPoint;
  99852. /**
  99853. * Gets the a input component
  99854. */
  99855. get a(): NodeMaterialConnectionPoint;
  99856. protected _buildBlock(state: NodeMaterialBuildState): this;
  99857. }
  99858. }
  99859. declare module BABYLON {
  99860. /**
  99861. * Block used for the particle ramp gradient section
  99862. */
  99863. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  99864. /**
  99865. * Create a new ParticleRampGradientBlock
  99866. * @param name defines the block name
  99867. */
  99868. constructor(name: string);
  99869. /**
  99870. * Gets the current class name
  99871. * @returns the class name
  99872. */
  99873. getClassName(): string;
  99874. /**
  99875. * Gets the color input component
  99876. */
  99877. get color(): NodeMaterialConnectionPoint;
  99878. /**
  99879. * Gets the rampColor output component
  99880. */
  99881. get rampColor(): NodeMaterialConnectionPoint;
  99882. /**
  99883. * Initialize the block and prepare the context for build
  99884. * @param state defines the state that will be used for the build
  99885. */
  99886. initialize(state: NodeMaterialBuildState): void;
  99887. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99888. }
  99889. }
  99890. declare module BABYLON {
  99891. /**
  99892. * Block used for the particle blend multiply section
  99893. */
  99894. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  99895. /**
  99896. * Create a new ParticleBlendMultiplyBlock
  99897. * @param name defines the block name
  99898. */
  99899. constructor(name: string);
  99900. /**
  99901. * Gets the current class name
  99902. * @returns the class name
  99903. */
  99904. getClassName(): string;
  99905. /**
  99906. * Gets the color input component
  99907. */
  99908. get color(): NodeMaterialConnectionPoint;
  99909. /**
  99910. * Gets the alphaTexture input component
  99911. */
  99912. get alphaTexture(): NodeMaterialConnectionPoint;
  99913. /**
  99914. * Gets the alphaColor input component
  99915. */
  99916. get alphaColor(): NodeMaterialConnectionPoint;
  99917. /**
  99918. * Gets the blendColor output component
  99919. */
  99920. get blendColor(): NodeMaterialConnectionPoint;
  99921. /**
  99922. * Initialize the block and prepare the context for build
  99923. * @param state defines the state that will be used for the build
  99924. */
  99925. initialize(state: NodeMaterialBuildState): void;
  99926. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99927. }
  99928. }
  99929. declare module BABYLON {
  99930. /**
  99931. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  99932. */
  99933. export class VectorMergerBlock extends NodeMaterialBlock {
  99934. /**
  99935. * Create a new VectorMergerBlock
  99936. * @param name defines the block name
  99937. */
  99938. constructor(name: string);
  99939. /**
  99940. * Gets the current class name
  99941. * @returns the class name
  99942. */
  99943. getClassName(): string;
  99944. /**
  99945. * Gets the xyz component (input)
  99946. */
  99947. get xyzIn(): NodeMaterialConnectionPoint;
  99948. /**
  99949. * Gets the xy component (input)
  99950. */
  99951. get xyIn(): NodeMaterialConnectionPoint;
  99952. /**
  99953. * Gets the x component (input)
  99954. */
  99955. get x(): NodeMaterialConnectionPoint;
  99956. /**
  99957. * Gets the y component (input)
  99958. */
  99959. get y(): NodeMaterialConnectionPoint;
  99960. /**
  99961. * Gets the z component (input)
  99962. */
  99963. get z(): NodeMaterialConnectionPoint;
  99964. /**
  99965. * Gets the w component (input)
  99966. */
  99967. get w(): NodeMaterialConnectionPoint;
  99968. /**
  99969. * Gets the xyzw component (output)
  99970. */
  99971. get xyzw(): NodeMaterialConnectionPoint;
  99972. /**
  99973. * Gets the xyz component (output)
  99974. */
  99975. get xyzOut(): NodeMaterialConnectionPoint;
  99976. /**
  99977. * Gets the xy component (output)
  99978. */
  99979. get xyOut(): NodeMaterialConnectionPoint;
  99980. /**
  99981. * Gets the xy component (output)
  99982. * @deprecated Please use xyOut instead.
  99983. */
  99984. get xy(): NodeMaterialConnectionPoint;
  99985. /**
  99986. * Gets the xyz component (output)
  99987. * @deprecated Please use xyzOut instead.
  99988. */
  99989. get xyz(): NodeMaterialConnectionPoint;
  99990. protected _buildBlock(state: NodeMaterialBuildState): this;
  99991. }
  99992. }
  99993. declare module BABYLON {
  99994. /**
  99995. * Block used to remap a float from a range to a new one
  99996. */
  99997. export class RemapBlock extends NodeMaterialBlock {
  99998. /**
  99999. * Gets or sets the source range
  100000. */
  100001. sourceRange: Vector2;
  100002. /**
  100003. * Gets or sets the target range
  100004. */
  100005. targetRange: Vector2;
  100006. /**
  100007. * Creates a new RemapBlock
  100008. * @param name defines the block name
  100009. */
  100010. constructor(name: string);
  100011. /**
  100012. * Gets the current class name
  100013. * @returns the class name
  100014. */
  100015. getClassName(): string;
  100016. /**
  100017. * Gets the input component
  100018. */
  100019. get input(): NodeMaterialConnectionPoint;
  100020. /**
  100021. * Gets the source min input component
  100022. */
  100023. get sourceMin(): NodeMaterialConnectionPoint;
  100024. /**
  100025. * Gets the source max input component
  100026. */
  100027. get sourceMax(): NodeMaterialConnectionPoint;
  100028. /**
  100029. * Gets the target min input component
  100030. */
  100031. get targetMin(): NodeMaterialConnectionPoint;
  100032. /**
  100033. * Gets the target max input component
  100034. */
  100035. get targetMax(): NodeMaterialConnectionPoint;
  100036. /**
  100037. * Gets the output component
  100038. */
  100039. get output(): NodeMaterialConnectionPoint;
  100040. protected _buildBlock(state: NodeMaterialBuildState): this;
  100041. protected _dumpPropertiesCode(): string;
  100042. serialize(): any;
  100043. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100044. }
  100045. }
  100046. declare module BABYLON {
  100047. /**
  100048. * Block used to multiply 2 values
  100049. */
  100050. export class MultiplyBlock extends NodeMaterialBlock {
  100051. /**
  100052. * Creates a new MultiplyBlock
  100053. * @param name defines the block name
  100054. */
  100055. constructor(name: string);
  100056. /**
  100057. * Gets the current class name
  100058. * @returns the class name
  100059. */
  100060. getClassName(): string;
  100061. /**
  100062. * Gets the left operand input component
  100063. */
  100064. get left(): NodeMaterialConnectionPoint;
  100065. /**
  100066. * Gets the right operand input component
  100067. */
  100068. get right(): NodeMaterialConnectionPoint;
  100069. /**
  100070. * Gets the output component
  100071. */
  100072. get output(): NodeMaterialConnectionPoint;
  100073. protected _buildBlock(state: NodeMaterialBuildState): this;
  100074. }
  100075. }
  100076. declare module BABYLON {
  100077. /**
  100078. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  100079. */
  100080. export class ColorSplitterBlock extends NodeMaterialBlock {
  100081. /**
  100082. * Create a new ColorSplitterBlock
  100083. * @param name defines the block name
  100084. */
  100085. constructor(name: string);
  100086. /**
  100087. * Gets the current class name
  100088. * @returns the class name
  100089. */
  100090. getClassName(): string;
  100091. /**
  100092. * Gets the rgba component (input)
  100093. */
  100094. get rgba(): NodeMaterialConnectionPoint;
  100095. /**
  100096. * Gets the rgb component (input)
  100097. */
  100098. get rgbIn(): NodeMaterialConnectionPoint;
  100099. /**
  100100. * Gets the rgb component (output)
  100101. */
  100102. get rgbOut(): NodeMaterialConnectionPoint;
  100103. /**
  100104. * Gets the r component (output)
  100105. */
  100106. get r(): NodeMaterialConnectionPoint;
  100107. /**
  100108. * Gets the g component (output)
  100109. */
  100110. get g(): NodeMaterialConnectionPoint;
  100111. /**
  100112. * Gets the b component (output)
  100113. */
  100114. get b(): NodeMaterialConnectionPoint;
  100115. /**
  100116. * Gets the a component (output)
  100117. */
  100118. get a(): NodeMaterialConnectionPoint;
  100119. protected _inputRename(name: string): string;
  100120. protected _outputRename(name: string): string;
  100121. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100122. }
  100123. }
  100124. declare module BABYLON {
  100125. /**
  100126. * Interface used to configure the node material editor
  100127. */
  100128. export interface INodeMaterialEditorOptions {
  100129. /** Define the URl to load node editor script */
  100130. editorURL?: string;
  100131. }
  100132. /** @hidden */
  100133. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100134. NORMAL: boolean;
  100135. TANGENT: boolean;
  100136. UV1: boolean;
  100137. /** BONES */
  100138. NUM_BONE_INFLUENCERS: number;
  100139. BonesPerMesh: number;
  100140. BONETEXTURE: boolean;
  100141. /** MORPH TARGETS */
  100142. MORPHTARGETS: boolean;
  100143. MORPHTARGETS_NORMAL: boolean;
  100144. MORPHTARGETS_TANGENT: boolean;
  100145. MORPHTARGETS_UV: boolean;
  100146. NUM_MORPH_INFLUENCERS: number;
  100147. /** IMAGE PROCESSING */
  100148. IMAGEPROCESSING: boolean;
  100149. VIGNETTE: boolean;
  100150. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100151. VIGNETTEBLENDMODEOPAQUE: boolean;
  100152. TONEMAPPING: boolean;
  100153. TONEMAPPING_ACES: boolean;
  100154. CONTRAST: boolean;
  100155. EXPOSURE: boolean;
  100156. COLORCURVES: boolean;
  100157. COLORGRADING: boolean;
  100158. COLORGRADING3D: boolean;
  100159. SAMPLER3DGREENDEPTH: boolean;
  100160. SAMPLER3DBGRMAP: boolean;
  100161. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100162. /** MISC. */
  100163. BUMPDIRECTUV: number;
  100164. constructor();
  100165. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  100166. }
  100167. /**
  100168. * Class used to configure NodeMaterial
  100169. */
  100170. export interface INodeMaterialOptions {
  100171. /**
  100172. * Defines if blocks should emit comments
  100173. */
  100174. emitComments: boolean;
  100175. }
  100176. /**
  100177. * Class used to create a node based material built by assembling shader blocks
  100178. */
  100179. export class NodeMaterial extends PushMaterial {
  100180. private static _BuildIdGenerator;
  100181. private _options;
  100182. private _vertexCompilationState;
  100183. private _fragmentCompilationState;
  100184. private _sharedData;
  100185. private _buildId;
  100186. private _buildWasSuccessful;
  100187. private _cachedWorldViewMatrix;
  100188. private _cachedWorldViewProjectionMatrix;
  100189. private _optimizers;
  100190. private _animationFrame;
  100191. /** Define the Url to load node editor script */
  100192. static EditorURL: string;
  100193. /** Define the Url to load snippets */
  100194. static SnippetUrl: string;
  100195. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  100196. static IgnoreTexturesAtLoadTime: boolean;
  100197. private BJSNODEMATERIALEDITOR;
  100198. /** Get the inspector from bundle or global */
  100199. private _getGlobalNodeMaterialEditor;
  100200. /**
  100201. * Snippet ID if the material was created from the snippet server
  100202. */
  100203. snippetId: string;
  100204. /**
  100205. * Gets or sets data used by visual editor
  100206. * @see https://nme.babylonjs.com
  100207. */
  100208. editorData: any;
  100209. /**
  100210. * 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)
  100211. */
  100212. ignoreAlpha: boolean;
  100213. /**
  100214. * Defines the maximum number of lights that can be used in the material
  100215. */
  100216. maxSimultaneousLights: number;
  100217. /**
  100218. * Observable raised when the material is built
  100219. */
  100220. onBuildObservable: Observable<NodeMaterial>;
  100221. /**
  100222. * Gets or sets the root nodes of the material vertex shader
  100223. */
  100224. _vertexOutputNodes: NodeMaterialBlock[];
  100225. /**
  100226. * Gets or sets the root nodes of the material fragment (pixel) shader
  100227. */
  100228. _fragmentOutputNodes: NodeMaterialBlock[];
  100229. /** Gets or sets options to control the node material overall behavior */
  100230. get options(): INodeMaterialOptions;
  100231. set options(options: INodeMaterialOptions);
  100232. /**
  100233. * Default configuration related to image processing available in the standard Material.
  100234. */
  100235. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100236. /**
  100237. * Gets the image processing configuration used either in this material.
  100238. */
  100239. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100240. /**
  100241. * Sets the Default image processing configuration used either in the this material.
  100242. *
  100243. * If sets to null, the scene one is in use.
  100244. */
  100245. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100246. /**
  100247. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  100248. */
  100249. attachedBlocks: NodeMaterialBlock[];
  100250. /**
  100251. * Specifies the mode of the node material
  100252. * @hidden
  100253. */
  100254. _mode: NodeMaterialModes;
  100255. /**
  100256. * Gets the mode property
  100257. */
  100258. get mode(): NodeMaterialModes;
  100259. /**
  100260. * Create a new node based material
  100261. * @param name defines the material name
  100262. * @param scene defines the hosting scene
  100263. * @param options defines creation option
  100264. */
  100265. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  100266. /**
  100267. * Gets the current class name of the material e.g. "NodeMaterial"
  100268. * @returns the class name
  100269. */
  100270. getClassName(): string;
  100271. /**
  100272. * Keep track of the image processing observer to allow dispose and replace.
  100273. */
  100274. private _imageProcessingObserver;
  100275. /**
  100276. * Attaches a new image processing configuration to the Standard Material.
  100277. * @param configuration
  100278. */
  100279. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100280. /**
  100281. * Get a block by its name
  100282. * @param name defines the name of the block to retrieve
  100283. * @returns the required block or null if not found
  100284. */
  100285. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  100286. /**
  100287. * Get a block by its name
  100288. * @param predicate defines the predicate used to find the good candidate
  100289. * @returns the required block or null if not found
  100290. */
  100291. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  100292. /**
  100293. * Get an input block by its name
  100294. * @param predicate defines the predicate used to find the good candidate
  100295. * @returns the required input block or null if not found
  100296. */
  100297. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  100298. /**
  100299. * Gets the list of input blocks attached to this material
  100300. * @returns an array of InputBlocks
  100301. */
  100302. getInputBlocks(): InputBlock[];
  100303. /**
  100304. * Adds a new optimizer to the list of optimizers
  100305. * @param optimizer defines the optimizers to add
  100306. * @returns the current material
  100307. */
  100308. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100309. /**
  100310. * Remove an optimizer from the list of optimizers
  100311. * @param optimizer defines the optimizers to remove
  100312. * @returns the current material
  100313. */
  100314. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100315. /**
  100316. * Add a new block to the list of output nodes
  100317. * @param node defines the node to add
  100318. * @returns the current material
  100319. */
  100320. addOutputNode(node: NodeMaterialBlock): this;
  100321. /**
  100322. * Remove a block from the list of root nodes
  100323. * @param node defines the node to remove
  100324. * @returns the current material
  100325. */
  100326. removeOutputNode(node: NodeMaterialBlock): this;
  100327. private _addVertexOutputNode;
  100328. private _removeVertexOutputNode;
  100329. private _addFragmentOutputNode;
  100330. private _removeFragmentOutputNode;
  100331. /**
  100332. * Specifies if the material will require alpha blending
  100333. * @returns a boolean specifying if alpha blending is needed
  100334. */
  100335. needAlphaBlending(): boolean;
  100336. /**
  100337. * Specifies if this material should be rendered in alpha test mode
  100338. * @returns a boolean specifying if an alpha test is needed.
  100339. */
  100340. needAlphaTesting(): boolean;
  100341. private _initializeBlock;
  100342. private _resetDualBlocks;
  100343. /**
  100344. * Remove a block from the current node material
  100345. * @param block defines the block to remove
  100346. */
  100347. removeBlock(block: NodeMaterialBlock): void;
  100348. /**
  100349. * Build the material and generates the inner effect
  100350. * @param verbose defines if the build should log activity
  100351. */
  100352. build(verbose?: boolean): void;
  100353. /**
  100354. * Runs an otpimization phase to try to improve the shader code
  100355. */
  100356. optimize(): void;
  100357. private _prepareDefinesForAttributes;
  100358. /**
  100359. * Create a post process from the material
  100360. * @param camera The camera to apply the render pass to.
  100361. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100363. * @param engine The engine which the post process will be applied. (default: current engine)
  100364. * @param reusable If the post process can be reused on the same frame. (default: false)
  100365. * @param textureType Type of textures used when performing the post process. (default: 0)
  100366. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100367. * @returns the post process created
  100368. */
  100369. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  100370. /**
  100371. * Create the post process effect from the material
  100372. * @param postProcess The post process to create the effect for
  100373. */
  100374. createEffectForPostProcess(postProcess: PostProcess): void;
  100375. private _createEffectOrPostProcess;
  100376. private _createEffectForParticles;
  100377. /**
  100378. * Create the effect to be used as the custom effect for a particle system
  100379. * @param particleSystem Particle system to create the effect for
  100380. * @param onCompiled defines a function to call when the effect creation is successful
  100381. * @param onError defines a function to call when the effect creation has failed
  100382. */
  100383. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100384. private _processDefines;
  100385. /**
  100386. * Get if the submesh is ready to be used and all its information available.
  100387. * Child classes can use it to update shaders
  100388. * @param mesh defines the mesh to check
  100389. * @param subMesh defines which submesh to check
  100390. * @param useInstances specifies that instances should be used
  100391. * @returns a boolean indicating that the submesh is ready or not
  100392. */
  100393. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100394. /**
  100395. * Get a string representing the shaders built by the current node graph
  100396. */
  100397. get compiledShaders(): string;
  100398. /**
  100399. * Binds the world matrix to the material
  100400. * @param world defines the world transformation matrix
  100401. */
  100402. bindOnlyWorldMatrix(world: Matrix): void;
  100403. /**
  100404. * Binds the submesh to this material by preparing the effect and shader to draw
  100405. * @param world defines the world transformation matrix
  100406. * @param mesh defines the mesh containing the submesh
  100407. * @param subMesh defines the submesh to bind the material to
  100408. */
  100409. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100410. /**
  100411. * Gets the active textures from the material
  100412. * @returns an array of textures
  100413. */
  100414. getActiveTextures(): BaseTexture[];
  100415. /**
  100416. * Gets the list of texture blocks
  100417. * @returns an array of texture blocks
  100418. */
  100419. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100420. /**
  100421. * Specifies if the material uses a texture
  100422. * @param texture defines the texture to check against the material
  100423. * @returns a boolean specifying if the material uses the texture
  100424. */
  100425. hasTexture(texture: BaseTexture): boolean;
  100426. /**
  100427. * Disposes the material
  100428. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100429. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100430. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  100431. */
  100432. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  100433. /** Creates the node editor window. */
  100434. private _createNodeEditor;
  100435. /**
  100436. * Launch the node material editor
  100437. * @param config Define the configuration of the editor
  100438. * @return a promise fulfilled when the node editor is visible
  100439. */
  100440. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  100441. /**
  100442. * Clear the current material
  100443. */
  100444. clear(): void;
  100445. /**
  100446. * Clear the current material and set it to a default state
  100447. */
  100448. setToDefault(): void;
  100449. /**
  100450. * Clear the current material and set it to a default state for post process
  100451. */
  100452. setToDefaultPostProcess(): void;
  100453. /**
  100454. * Clear the current material and set it to a default state for particle
  100455. */
  100456. setToDefaultParticle(): void;
  100457. /**
  100458. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  100459. * @param url defines the url to load from
  100460. * @returns a promise that will fullfil when the material is fully loaded
  100461. */
  100462. loadAsync(url: string): Promise<void>;
  100463. private _gatherBlocks;
  100464. /**
  100465. * Generate a string containing the code declaration required to create an equivalent of this material
  100466. * @returns a string
  100467. */
  100468. generateCode(): string;
  100469. /**
  100470. * Serializes this material in a JSON representation
  100471. * @returns the serialized material object
  100472. */
  100473. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  100474. private _restoreConnections;
  100475. /**
  100476. * Clear the current graph and load a new one from a serialization object
  100477. * @param source defines the JSON representation of the material
  100478. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100479. * @param merge defines whether or not the source must be merged or replace the current content
  100480. */
  100481. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  100482. /**
  100483. * Makes a duplicate of the current material.
  100484. * @param name - name to use for the new material.
  100485. */
  100486. clone(name: string): NodeMaterial;
  100487. /**
  100488. * Creates a node material from parsed material data
  100489. * @param source defines the JSON representation of the material
  100490. * @param scene defines the hosting scene
  100491. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100492. * @returns a new node material
  100493. */
  100494. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  100495. /**
  100496. * Creates a node material from a snippet saved in a remote file
  100497. * @param name defines the name of the material to create
  100498. * @param url defines the url to load from
  100499. * @param scene defines the hosting scene
  100500. * @returns a promise that will resolve to the new node material
  100501. */
  100502. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  100503. /**
  100504. * Creates a node material from a snippet saved by the node material editor
  100505. * @param snippetId defines the snippet to load
  100506. * @param scene defines the hosting scene
  100507. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100508. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  100509. * @returns a promise that will resolve to the new node material
  100510. */
  100511. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  100512. /**
  100513. * Creates a new node material set to default basic configuration
  100514. * @param name defines the name of the material
  100515. * @param scene defines the hosting scene
  100516. * @returns a new NodeMaterial
  100517. */
  100518. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  100519. }
  100520. }
  100521. declare module BABYLON {
  100522. /**
  100523. * Size options for a post process
  100524. */
  100525. export type PostProcessOptions = {
  100526. width: number;
  100527. height: number;
  100528. };
  100529. /**
  100530. * PostProcess can be used to apply a shader to a texture after it has been rendered
  100531. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100532. */
  100533. export class PostProcess {
  100534. /** Name of the PostProcess. */
  100535. name: string;
  100536. /**
  100537. * Gets or sets the unique id of the post process
  100538. */
  100539. uniqueId: number;
  100540. /**
  100541. * Width of the texture to apply the post process on
  100542. */
  100543. width: number;
  100544. /**
  100545. * Height of the texture to apply the post process on
  100546. */
  100547. height: number;
  100548. /**
  100549. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  100550. */
  100551. nodeMaterialSource: Nullable<NodeMaterial>;
  100552. /**
  100553. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  100554. * @hidden
  100555. */
  100556. _outputTexture: Nullable<InternalTexture>;
  100557. /**
  100558. * Sampling mode used by the shader
  100559. * See https://doc.babylonjs.com/classes/3.1/texture
  100560. */
  100561. renderTargetSamplingMode: number;
  100562. /**
  100563. * Clear color to use when screen clearing
  100564. */
  100565. clearColor: Color4;
  100566. /**
  100567. * If the buffer needs to be cleared before applying the post process. (default: true)
  100568. * Should be set to false if shader will overwrite all previous pixels.
  100569. */
  100570. autoClear: boolean;
  100571. /**
  100572. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  100573. */
  100574. alphaMode: number;
  100575. /**
  100576. * Sets the setAlphaBlendConstants of the babylon engine
  100577. */
  100578. alphaConstants: Color4;
  100579. /**
  100580. * Animations to be used for the post processing
  100581. */
  100582. animations: Animation[];
  100583. /**
  100584. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  100585. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  100586. */
  100587. enablePixelPerfectMode: boolean;
  100588. /**
  100589. * Force the postprocess to be applied without taking in account viewport
  100590. */
  100591. forceFullscreenViewport: boolean;
  100592. /**
  100593. * List of inspectable custom properties (used by the Inspector)
  100594. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100595. */
  100596. inspectableCustomProperties: IInspectable[];
  100597. /**
  100598. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  100599. *
  100600. * | Value | Type | Description |
  100601. * | ----- | ----------------------------------- | ----------- |
  100602. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  100603. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  100604. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  100605. *
  100606. */
  100607. scaleMode: number;
  100608. /**
  100609. * Force textures to be a power of two (default: false)
  100610. */
  100611. alwaysForcePOT: boolean;
  100612. private _samples;
  100613. /**
  100614. * Number of sample textures (default: 1)
  100615. */
  100616. get samples(): number;
  100617. set samples(n: number);
  100618. /**
  100619. * Modify the scale of the post process to be the same as the viewport (default: false)
  100620. */
  100621. adaptScaleToCurrentViewport: boolean;
  100622. private _camera;
  100623. protected _scene: Scene;
  100624. private _engine;
  100625. private _options;
  100626. private _reusable;
  100627. private _textureType;
  100628. private _textureFormat;
  100629. /**
  100630. * Smart array of input and output textures for the post process.
  100631. * @hidden
  100632. */
  100633. _textures: SmartArray<InternalTexture>;
  100634. /**
  100635. * The index in _textures that corresponds to the output texture.
  100636. * @hidden
  100637. */
  100638. _currentRenderTextureInd: number;
  100639. private _effect;
  100640. private _samplers;
  100641. private _fragmentUrl;
  100642. private _vertexUrl;
  100643. private _parameters;
  100644. private _scaleRatio;
  100645. protected _indexParameters: any;
  100646. private _shareOutputWithPostProcess;
  100647. private _texelSize;
  100648. private _forcedOutputTexture;
  100649. /**
  100650. * Returns the fragment url or shader name used in the post process.
  100651. * @returns the fragment url or name in the shader store.
  100652. */
  100653. getEffectName(): string;
  100654. /**
  100655. * An event triggered when the postprocess is activated.
  100656. */
  100657. onActivateObservable: Observable<Camera>;
  100658. private _onActivateObserver;
  100659. /**
  100660. * A function that is added to the onActivateObservable
  100661. */
  100662. set onActivate(callback: Nullable<(camera: Camera) => void>);
  100663. /**
  100664. * An event triggered when the postprocess changes its size.
  100665. */
  100666. onSizeChangedObservable: Observable<PostProcess>;
  100667. private _onSizeChangedObserver;
  100668. /**
  100669. * A function that is added to the onSizeChangedObservable
  100670. */
  100671. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  100672. /**
  100673. * An event triggered when the postprocess applies its effect.
  100674. */
  100675. onApplyObservable: Observable<Effect>;
  100676. private _onApplyObserver;
  100677. /**
  100678. * A function that is added to the onApplyObservable
  100679. */
  100680. set onApply(callback: (effect: Effect) => void);
  100681. /**
  100682. * An event triggered before rendering the postprocess
  100683. */
  100684. onBeforeRenderObservable: Observable<Effect>;
  100685. private _onBeforeRenderObserver;
  100686. /**
  100687. * A function that is added to the onBeforeRenderObservable
  100688. */
  100689. set onBeforeRender(callback: (effect: Effect) => void);
  100690. /**
  100691. * An event triggered after rendering the postprocess
  100692. */
  100693. onAfterRenderObservable: Observable<Effect>;
  100694. private _onAfterRenderObserver;
  100695. /**
  100696. * A function that is added to the onAfterRenderObservable
  100697. */
  100698. set onAfterRender(callback: (efect: Effect) => void);
  100699. /**
  100700. * 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
  100701. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  100702. */
  100703. get inputTexture(): InternalTexture;
  100704. set inputTexture(value: InternalTexture);
  100705. /**
  100706. * Gets the camera which post process is applied to.
  100707. * @returns The camera the post process is applied to.
  100708. */
  100709. getCamera(): Camera;
  100710. /**
  100711. * Gets the texel size of the postprocess.
  100712. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  100713. */
  100714. get texelSize(): Vector2;
  100715. /**
  100716. * Creates a new instance PostProcess
  100717. * @param name The name of the PostProcess.
  100718. * @param fragmentUrl The url of the fragment shader to be used.
  100719. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  100720. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  100721. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100722. * @param camera The camera to apply the render pass to.
  100723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100724. * @param engine The engine which the post process will be applied. (default: current engine)
  100725. * @param reusable If the post process can be reused on the same frame. (default: false)
  100726. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  100727. * @param textureType Type of textures used when performing the post process. (default: 0)
  100728. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  100729. * @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
  100730. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  100731. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100732. */
  100733. constructor(
  100734. /** Name of the PostProcess. */
  100735. 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);
  100736. /**
  100737. * Gets a string idenfifying the name of the class
  100738. * @returns "PostProcess" string
  100739. */
  100740. getClassName(): string;
  100741. /**
  100742. * Gets the engine which this post process belongs to.
  100743. * @returns The engine the post process was enabled with.
  100744. */
  100745. getEngine(): Engine;
  100746. /**
  100747. * The effect that is created when initializing the post process.
  100748. * @returns The created effect corresponding the the postprocess.
  100749. */
  100750. getEffect(): Effect;
  100751. /**
  100752. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  100753. * @param postProcess The post process to share the output with.
  100754. * @returns This post process.
  100755. */
  100756. shareOutputWith(postProcess: PostProcess): PostProcess;
  100757. /**
  100758. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  100759. * This should be called if the post process that shares output with this post process is disabled/disposed.
  100760. */
  100761. useOwnOutput(): void;
  100762. /**
  100763. * Updates the effect with the current post process compile time values and recompiles the shader.
  100764. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100765. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100766. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100767. * @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
  100768. * @param onCompiled Called when the shader has been compiled.
  100769. * @param onError Called if there is an error when compiling a shader.
  100770. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  100771. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  100772. */
  100773. 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;
  100774. /**
  100775. * The post process is reusable if it can be used multiple times within one frame.
  100776. * @returns If the post process is reusable
  100777. */
  100778. isReusable(): boolean;
  100779. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  100780. markTextureDirty(): void;
  100781. /**
  100782. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  100783. * 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.
  100784. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  100785. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  100786. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  100787. * @returns The target texture that was bound to be written to.
  100788. */
  100789. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  100790. /**
  100791. * If the post process is supported.
  100792. */
  100793. get isSupported(): boolean;
  100794. /**
  100795. * The aspect ratio of the output texture.
  100796. */
  100797. get aspectRatio(): number;
  100798. /**
  100799. * Get a value indicating if the post-process is ready to be used
  100800. * @returns true if the post-process is ready (shader is compiled)
  100801. */
  100802. isReady(): boolean;
  100803. /**
  100804. * Binds all textures and uniforms to the shader, this will be run on every pass.
  100805. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  100806. */
  100807. apply(): Nullable<Effect>;
  100808. private _disposeTextures;
  100809. /**
  100810. * Disposes the post process.
  100811. * @param camera The camera to dispose the post process on.
  100812. */
  100813. dispose(camera?: Camera): void;
  100814. }
  100815. }
  100816. declare module BABYLON {
  100817. /** @hidden */
  100818. export var kernelBlurVaryingDeclaration: {
  100819. name: string;
  100820. shader: string;
  100821. };
  100822. }
  100823. declare module BABYLON {
  100824. /** @hidden */
  100825. export var kernelBlurFragment: {
  100826. name: string;
  100827. shader: string;
  100828. };
  100829. }
  100830. declare module BABYLON {
  100831. /** @hidden */
  100832. export var kernelBlurFragment2: {
  100833. name: string;
  100834. shader: string;
  100835. };
  100836. }
  100837. declare module BABYLON {
  100838. /** @hidden */
  100839. export var kernelBlurPixelShader: {
  100840. name: string;
  100841. shader: string;
  100842. };
  100843. }
  100844. declare module BABYLON {
  100845. /** @hidden */
  100846. export var kernelBlurVertex: {
  100847. name: string;
  100848. shader: string;
  100849. };
  100850. }
  100851. declare module BABYLON {
  100852. /** @hidden */
  100853. export var kernelBlurVertexShader: {
  100854. name: string;
  100855. shader: string;
  100856. };
  100857. }
  100858. declare module BABYLON {
  100859. /**
  100860. * The Blur Post Process which blurs an image based on a kernel and direction.
  100861. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  100862. */
  100863. export class BlurPostProcess extends PostProcess {
  100864. /** The direction in which to blur the image. */
  100865. direction: Vector2;
  100866. private blockCompilation;
  100867. protected _kernel: number;
  100868. protected _idealKernel: number;
  100869. protected _packedFloat: boolean;
  100870. private _staticDefines;
  100871. /**
  100872. * Sets the length in pixels of the blur sample region
  100873. */
  100874. set kernel(v: number);
  100875. /**
  100876. * Gets the length in pixels of the blur sample region
  100877. */
  100878. get kernel(): number;
  100879. /**
  100880. * Sets wether or not the blur needs to unpack/repack floats
  100881. */
  100882. set packedFloat(v: boolean);
  100883. /**
  100884. * Gets wether or not the blur is unpacking/repacking floats
  100885. */
  100886. get packedFloat(): boolean;
  100887. /**
  100888. * Creates a new instance BlurPostProcess
  100889. * @param name The name of the effect.
  100890. * @param direction The direction in which to blur the image.
  100891. * @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.
  100892. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100893. * @param camera The camera to apply the render pass to.
  100894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100895. * @param engine The engine which the post process will be applied. (default: current engine)
  100896. * @param reusable If the post process can be reused on the same frame. (default: false)
  100897. * @param textureType Type of textures used when performing the post process. (default: 0)
  100898. * @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)
  100899. */
  100900. constructor(name: string,
  100901. /** The direction in which to blur the image. */
  100902. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  100903. /**
  100904. * Updates the effect with the current post process compile time values and recompiles the shader.
  100905. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100906. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100907. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100908. * @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
  100909. * @param onCompiled Called when the shader has been compiled.
  100910. * @param onError Called if there is an error when compiling a shader.
  100911. */
  100912. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100913. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100914. /**
  100915. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  100916. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  100917. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  100918. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  100919. * The gaps between physical kernels are compensated for in the weighting of the samples
  100920. * @param idealKernel Ideal blur kernel.
  100921. * @return Nearest best kernel.
  100922. */
  100923. protected _nearestBestKernel(idealKernel: number): number;
  100924. /**
  100925. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  100926. * @param x The point on the Gaussian distribution to sample.
  100927. * @return the value of the Gaussian function at x.
  100928. */
  100929. protected _gaussianWeight(x: number): number;
  100930. /**
  100931. * Generates a string that can be used as a floating point number in GLSL.
  100932. * @param x Value to print.
  100933. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  100934. * @return GLSL float string.
  100935. */
  100936. protected _glslFloat(x: number, decimalFigures?: number): string;
  100937. }
  100938. }
  100939. declare module BABYLON {
  100940. /**
  100941. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100942. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100943. * You can then easily use it as a reflectionTexture on a flat surface.
  100944. * In case the surface is not a plane, please consider relying on reflection probes.
  100945. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100946. */
  100947. export class MirrorTexture extends RenderTargetTexture {
  100948. private scene;
  100949. /**
  100950. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  100951. * 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.
  100952. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100953. */
  100954. mirrorPlane: Plane;
  100955. /**
  100956. * Define the blur ratio used to blur the reflection if needed.
  100957. */
  100958. set blurRatio(value: number);
  100959. get blurRatio(): number;
  100960. /**
  100961. * Define the adaptive blur kernel used to blur the reflection if needed.
  100962. * This will autocompute the closest best match for the `blurKernel`
  100963. */
  100964. set adaptiveBlurKernel(value: number);
  100965. /**
  100966. * Define the blur kernel used to blur the reflection if needed.
  100967. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100968. */
  100969. set blurKernel(value: number);
  100970. /**
  100971. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  100972. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100973. */
  100974. set blurKernelX(value: number);
  100975. get blurKernelX(): number;
  100976. /**
  100977. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  100978. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100979. */
  100980. set blurKernelY(value: number);
  100981. get blurKernelY(): number;
  100982. private _autoComputeBlurKernel;
  100983. protected _onRatioRescale(): void;
  100984. private _updateGammaSpace;
  100985. private _imageProcessingConfigChangeObserver;
  100986. private _transformMatrix;
  100987. private _mirrorMatrix;
  100988. private _savedViewMatrix;
  100989. private _blurX;
  100990. private _blurY;
  100991. private _adaptiveBlurKernel;
  100992. private _blurKernelX;
  100993. private _blurKernelY;
  100994. private _blurRatio;
  100995. /**
  100996. * Instantiates a Mirror Texture.
  100997. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100998. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100999. * You can then easily use it as a reflectionTexture on a flat surface.
  101000. * In case the surface is not a plane, please consider relying on reflection probes.
  101001. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101002. * @param name
  101003. * @param size
  101004. * @param scene
  101005. * @param generateMipMaps
  101006. * @param type
  101007. * @param samplingMode
  101008. * @param generateDepthBuffer
  101009. */
  101010. constructor(name: string, size: number | {
  101011. width: number;
  101012. height: number;
  101013. } | {
  101014. ratio: number;
  101015. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  101016. private _preparePostProcesses;
  101017. /**
  101018. * Clone the mirror texture.
  101019. * @returns the cloned texture
  101020. */
  101021. clone(): MirrorTexture;
  101022. /**
  101023. * Serialize the texture to a JSON representation you could use in Parse later on
  101024. * @returns the serialized JSON representation
  101025. */
  101026. serialize(): any;
  101027. /**
  101028. * Dispose the texture and release its associated resources.
  101029. */
  101030. dispose(): void;
  101031. }
  101032. }
  101033. declare module BABYLON {
  101034. /**
  101035. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101036. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101037. */
  101038. export class Texture extends BaseTexture {
  101039. /**
  101040. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  101041. */
  101042. static SerializeBuffers: boolean;
  101043. /** @hidden */
  101044. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  101045. /** @hidden */
  101046. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  101047. /** @hidden */
  101048. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  101049. /** nearest is mag = nearest and min = nearest and mip = linear */
  101050. static readonly NEAREST_SAMPLINGMODE: number;
  101051. /** nearest is mag = nearest and min = nearest and mip = linear */
  101052. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  101053. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101054. static readonly BILINEAR_SAMPLINGMODE: number;
  101055. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101056. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  101057. /** Trilinear is mag = linear and min = linear and mip = linear */
  101058. static readonly TRILINEAR_SAMPLINGMODE: number;
  101059. /** Trilinear is mag = linear and min = linear and mip = linear */
  101060. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  101061. /** mag = nearest and min = nearest and mip = nearest */
  101062. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  101063. /** mag = nearest and min = linear and mip = nearest */
  101064. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  101065. /** mag = nearest and min = linear and mip = linear */
  101066. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  101067. /** mag = nearest and min = linear and mip = none */
  101068. static readonly NEAREST_LINEAR: number;
  101069. /** mag = nearest and min = nearest and mip = none */
  101070. static readonly NEAREST_NEAREST: number;
  101071. /** mag = linear and min = nearest and mip = nearest */
  101072. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  101073. /** mag = linear and min = nearest and mip = linear */
  101074. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  101075. /** mag = linear and min = linear and mip = none */
  101076. static readonly LINEAR_LINEAR: number;
  101077. /** mag = linear and min = nearest and mip = none */
  101078. static readonly LINEAR_NEAREST: number;
  101079. /** Explicit coordinates mode */
  101080. static readonly EXPLICIT_MODE: number;
  101081. /** Spherical coordinates mode */
  101082. static readonly SPHERICAL_MODE: number;
  101083. /** Planar coordinates mode */
  101084. static readonly PLANAR_MODE: number;
  101085. /** Cubic coordinates mode */
  101086. static readonly CUBIC_MODE: number;
  101087. /** Projection coordinates mode */
  101088. static readonly PROJECTION_MODE: number;
  101089. /** Inverse Cubic coordinates mode */
  101090. static readonly SKYBOX_MODE: number;
  101091. /** Inverse Cubic coordinates mode */
  101092. static readonly INVCUBIC_MODE: number;
  101093. /** Equirectangular coordinates mode */
  101094. static readonly EQUIRECTANGULAR_MODE: number;
  101095. /** Equirectangular Fixed coordinates mode */
  101096. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  101097. /** Equirectangular Fixed Mirrored coordinates mode */
  101098. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101099. /** Texture is not repeating outside of 0..1 UVs */
  101100. static readonly CLAMP_ADDRESSMODE: number;
  101101. /** Texture is repeating outside of 0..1 UVs */
  101102. static readonly WRAP_ADDRESSMODE: number;
  101103. /** Texture is repeating and mirrored */
  101104. static readonly MIRROR_ADDRESSMODE: number;
  101105. /**
  101106. * 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
  101107. */
  101108. static UseSerializedUrlIfAny: boolean;
  101109. /**
  101110. * Define the url of the texture.
  101111. */
  101112. url: Nullable<string>;
  101113. /**
  101114. * Define an offset on the texture to offset the u coordinates of the UVs
  101115. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101116. */
  101117. uOffset: number;
  101118. /**
  101119. * Define an offset on the texture to offset the v coordinates of the UVs
  101120. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101121. */
  101122. vOffset: number;
  101123. /**
  101124. * Define an offset on the texture to scale the u coordinates of the UVs
  101125. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101126. */
  101127. uScale: number;
  101128. /**
  101129. * Define an offset on the texture to scale the v coordinates of the UVs
  101130. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101131. */
  101132. vScale: number;
  101133. /**
  101134. * Define an offset on the texture to rotate around the u coordinates of the UVs
  101135. * @see https://doc.babylonjs.com/how_to/more_materials
  101136. */
  101137. uAng: number;
  101138. /**
  101139. * Define an offset on the texture to rotate around the v coordinates of the UVs
  101140. * @see https://doc.babylonjs.com/how_to/more_materials
  101141. */
  101142. vAng: number;
  101143. /**
  101144. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  101145. * @see https://doc.babylonjs.com/how_to/more_materials
  101146. */
  101147. wAng: number;
  101148. /**
  101149. * Defines the center of rotation (U)
  101150. */
  101151. uRotationCenter: number;
  101152. /**
  101153. * Defines the center of rotation (V)
  101154. */
  101155. vRotationCenter: number;
  101156. /**
  101157. * Defines the center of rotation (W)
  101158. */
  101159. wRotationCenter: number;
  101160. /**
  101161. * Are mip maps generated for this texture or not.
  101162. */
  101163. get noMipmap(): boolean;
  101164. /**
  101165. * List of inspectable custom properties (used by the Inspector)
  101166. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101167. */
  101168. inspectableCustomProperties: Nullable<IInspectable[]>;
  101169. private _noMipmap;
  101170. /** @hidden */
  101171. _invertY: boolean;
  101172. private _rowGenerationMatrix;
  101173. private _cachedTextureMatrix;
  101174. private _projectionModeMatrix;
  101175. private _t0;
  101176. private _t1;
  101177. private _t2;
  101178. private _cachedUOffset;
  101179. private _cachedVOffset;
  101180. private _cachedUScale;
  101181. private _cachedVScale;
  101182. private _cachedUAng;
  101183. private _cachedVAng;
  101184. private _cachedWAng;
  101185. private _cachedProjectionMatrixId;
  101186. private _cachedCoordinatesMode;
  101187. /** @hidden */
  101188. protected _initialSamplingMode: number;
  101189. /** @hidden */
  101190. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101191. private _deleteBuffer;
  101192. protected _format: Nullable<number>;
  101193. private _delayedOnLoad;
  101194. private _delayedOnError;
  101195. private _mimeType?;
  101196. /**
  101197. * Observable triggered once the texture has been loaded.
  101198. */
  101199. onLoadObservable: Observable<Texture>;
  101200. protected _isBlocking: boolean;
  101201. /**
  101202. * Is the texture preventing material to render while loading.
  101203. * If false, a default texture will be used instead of the loading one during the preparation step.
  101204. */
  101205. set isBlocking(value: boolean);
  101206. get isBlocking(): boolean;
  101207. /**
  101208. * Get the current sampling mode associated with the texture.
  101209. */
  101210. get samplingMode(): number;
  101211. /**
  101212. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  101213. */
  101214. get invertY(): boolean;
  101215. /**
  101216. * Instantiates a new texture.
  101217. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101218. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101219. * @param url defines the url of the picture to load as a texture
  101220. * @param sceneOrEngine defines the scene or engine the texture will belong to
  101221. * @param noMipmap defines if the texture will require mip maps or not
  101222. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  101223. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101224. * @param onLoad defines a callback triggered when the texture has been loaded
  101225. * @param onError defines a callback triggered when an error occurred during the loading session
  101226. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  101227. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  101228. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101229. * @param mimeType defines an optional mime type information
  101230. */
  101231. 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);
  101232. /**
  101233. * Update the url (and optional buffer) of this texture if url was null during construction.
  101234. * @param url the url of the texture
  101235. * @param buffer the buffer of the texture (defaults to null)
  101236. * @param onLoad callback called when the texture is loaded (defaults to null)
  101237. */
  101238. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  101239. /**
  101240. * Finish the loading sequence of a texture flagged as delayed load.
  101241. * @hidden
  101242. */
  101243. delayLoad(): void;
  101244. private _prepareRowForTextureGeneration;
  101245. /**
  101246. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  101247. * @returns the transform matrix of the texture.
  101248. */
  101249. getTextureMatrix(uBase?: number): Matrix;
  101250. /**
  101251. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  101252. * @returns The reflection texture transform
  101253. */
  101254. getReflectionTextureMatrix(): Matrix;
  101255. /**
  101256. * Clones the texture.
  101257. * @returns the cloned texture
  101258. */
  101259. clone(): Texture;
  101260. /**
  101261. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101262. * @returns The JSON representation of the texture
  101263. */
  101264. serialize(): any;
  101265. /**
  101266. * Get the current class name of the texture useful for serialization or dynamic coding.
  101267. * @returns "Texture"
  101268. */
  101269. getClassName(): string;
  101270. /**
  101271. * Dispose the texture and release its associated resources.
  101272. */
  101273. dispose(): void;
  101274. /**
  101275. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  101276. * @param parsedTexture Define the JSON representation of the texture
  101277. * @param scene Define the scene the parsed texture should be instantiated in
  101278. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101279. * @returns The parsed texture if successful
  101280. */
  101281. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  101282. /**
  101283. * Creates a texture from its base 64 representation.
  101284. * @param data Define the base64 payload without the data: prefix
  101285. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101286. * @param scene Define the scene the texture should belong to
  101287. * @param noMipmap Forces the texture to not create mip map information if true
  101288. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101289. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101290. * @param onLoad define a callback triggered when the texture has been loaded
  101291. * @param onError define a callback triggered when an error occurred during the loading session
  101292. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101293. * @returns the created texture
  101294. */
  101295. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  101296. /**
  101297. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  101298. * @param data Define the base64 payload without the data: prefix
  101299. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101300. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  101301. * @param scene Define the scene the texture should belong to
  101302. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  101303. * @param noMipmap Forces the texture to not create mip map information if true
  101304. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101305. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101306. * @param onLoad define a callback triggered when the texture has been loaded
  101307. * @param onError define a callback triggered when an error occurred during the loading session
  101308. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101309. * @returns the created texture
  101310. */
  101311. 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;
  101312. }
  101313. }
  101314. declare module BABYLON {
  101315. /**
  101316. * PostProcessManager is used to manage one or more post processes or post process pipelines
  101317. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101318. */
  101319. export class PostProcessManager {
  101320. private _scene;
  101321. private _indexBuffer;
  101322. private _vertexBuffers;
  101323. /**
  101324. * Creates a new instance PostProcess
  101325. * @param scene The scene that the post process is associated with.
  101326. */
  101327. constructor(scene: Scene);
  101328. private _prepareBuffers;
  101329. private _buildIndexBuffer;
  101330. /**
  101331. * Rebuilds the vertex buffers of the manager.
  101332. * @hidden
  101333. */
  101334. _rebuild(): void;
  101335. /**
  101336. * Prepares a frame to be run through a post process.
  101337. * @param sourceTexture The input texture to the post procesess. (default: null)
  101338. * @param postProcesses An array of post processes to be run. (default: null)
  101339. * @returns True if the post processes were able to be run.
  101340. * @hidden
  101341. */
  101342. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  101343. /**
  101344. * Manually render a set of post processes to a texture.
  101345. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  101346. * @param postProcesses An array of post processes to be run.
  101347. * @param targetTexture The target texture to render to.
  101348. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  101349. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  101350. * @param lodLevel defines which lod of the texture to render to
  101351. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  101352. */
  101353. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  101354. /**
  101355. * Finalize the result of the output of the postprocesses.
  101356. * @param doNotPresent If true the result will not be displayed to the screen.
  101357. * @param targetTexture The target texture to render to.
  101358. * @param faceIndex The index of the face to bind the target texture to.
  101359. * @param postProcesses The array of post processes to render.
  101360. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  101361. * @hidden
  101362. */
  101363. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  101364. /**
  101365. * Disposes of the post process manager.
  101366. */
  101367. dispose(): void;
  101368. }
  101369. }
  101370. declare module BABYLON {
  101371. /**
  101372. * This Helps creating a texture that will be created from a camera in your scene.
  101373. * It is basically a dynamic texture that could be used to create special effects for instance.
  101374. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  101375. */
  101376. export class RenderTargetTexture extends Texture {
  101377. isCube: boolean;
  101378. /**
  101379. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  101380. */
  101381. static readonly REFRESHRATE_RENDER_ONCE: number;
  101382. /**
  101383. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  101384. */
  101385. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  101386. /**
  101387. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  101388. * the central point of your effect and can save a lot of performances.
  101389. */
  101390. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  101391. /**
  101392. * Use this predicate to dynamically define the list of mesh you want to render.
  101393. * If set, the renderList property will be overwritten.
  101394. */
  101395. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  101396. private _renderList;
  101397. /**
  101398. * Use this list to define the list of mesh you want to render.
  101399. */
  101400. get renderList(): Nullable<Array<AbstractMesh>>;
  101401. set renderList(value: Nullable<Array<AbstractMesh>>);
  101402. /**
  101403. * Use this function to overload the renderList array at rendering time.
  101404. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  101405. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  101406. * the cube (if the RTT is a cube, else layerOrFace=0).
  101407. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  101408. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  101409. * hold dummy elements!
  101410. */
  101411. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  101412. private _hookArray;
  101413. /**
  101414. * Define if particles should be rendered in your texture.
  101415. */
  101416. renderParticles: boolean;
  101417. /**
  101418. * Define if sprites should be rendered in your texture.
  101419. */
  101420. renderSprites: boolean;
  101421. /**
  101422. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  101423. */
  101424. coordinatesMode: number;
  101425. /**
  101426. * Define the camera used to render the texture.
  101427. */
  101428. activeCamera: Nullable<Camera>;
  101429. /**
  101430. * Override the mesh isReady function with your own one.
  101431. */
  101432. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  101433. /**
  101434. * Override the render function of the texture with your own one.
  101435. */
  101436. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  101437. /**
  101438. * Define if camera post processes should be use while rendering the texture.
  101439. */
  101440. useCameraPostProcesses: boolean;
  101441. /**
  101442. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  101443. */
  101444. ignoreCameraViewport: boolean;
  101445. private _postProcessManager;
  101446. private _postProcesses;
  101447. private _resizeObserver;
  101448. /**
  101449. * An event triggered when the texture is unbind.
  101450. */
  101451. onBeforeBindObservable: Observable<RenderTargetTexture>;
  101452. /**
  101453. * An event triggered when the texture is unbind.
  101454. */
  101455. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  101456. private _onAfterUnbindObserver;
  101457. /**
  101458. * Set a after unbind callback in the texture.
  101459. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  101460. */
  101461. set onAfterUnbind(callback: () => void);
  101462. /**
  101463. * An event triggered before rendering the texture
  101464. */
  101465. onBeforeRenderObservable: Observable<number>;
  101466. private _onBeforeRenderObserver;
  101467. /**
  101468. * Set a before render callback in the texture.
  101469. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  101470. */
  101471. set onBeforeRender(callback: (faceIndex: number) => void);
  101472. /**
  101473. * An event triggered after rendering the texture
  101474. */
  101475. onAfterRenderObservable: Observable<number>;
  101476. private _onAfterRenderObserver;
  101477. /**
  101478. * Set a after render callback in the texture.
  101479. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  101480. */
  101481. set onAfterRender(callback: (faceIndex: number) => void);
  101482. /**
  101483. * An event triggered after the texture clear
  101484. */
  101485. onClearObservable: Observable<Engine>;
  101486. private _onClearObserver;
  101487. /**
  101488. * Set a clear callback in the texture.
  101489. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  101490. */
  101491. set onClear(callback: (Engine: Engine) => void);
  101492. /**
  101493. * An event triggered when the texture is resized.
  101494. */
  101495. onResizeObservable: Observable<RenderTargetTexture>;
  101496. /**
  101497. * Define the clear color of the Render Target if it should be different from the scene.
  101498. */
  101499. clearColor: Color4;
  101500. protected _size: number | {
  101501. width: number;
  101502. height: number;
  101503. layers?: number;
  101504. };
  101505. protected _initialSizeParameter: number | {
  101506. width: number;
  101507. height: number;
  101508. } | {
  101509. ratio: number;
  101510. };
  101511. protected _sizeRatio: Nullable<number>;
  101512. /** @hidden */
  101513. _generateMipMaps: boolean;
  101514. protected _renderingManager: RenderingManager;
  101515. /** @hidden */
  101516. _waitingRenderList: string[];
  101517. protected _doNotChangeAspectRatio: boolean;
  101518. protected _currentRefreshId: number;
  101519. protected _refreshRate: number;
  101520. protected _textureMatrix: Matrix;
  101521. protected _samples: number;
  101522. protected _renderTargetOptions: RenderTargetCreationOptions;
  101523. /**
  101524. * Gets render target creation options that were used.
  101525. */
  101526. get renderTargetOptions(): RenderTargetCreationOptions;
  101527. protected _onRatioRescale(): void;
  101528. /**
  101529. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  101530. * It must define where the camera used to render the texture is set
  101531. */
  101532. boundingBoxPosition: Vector3;
  101533. private _boundingBoxSize;
  101534. /**
  101535. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  101536. * When defined, the cubemap will switch to local mode
  101537. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101538. * @example https://www.babylonjs-playground.com/#RNASML
  101539. */
  101540. set boundingBoxSize(value: Vector3);
  101541. get boundingBoxSize(): Vector3;
  101542. /**
  101543. * In case the RTT has been created with a depth texture, get the associated
  101544. * depth texture.
  101545. * Otherwise, return null.
  101546. */
  101547. get depthStencilTexture(): Nullable<InternalTexture>;
  101548. /**
  101549. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  101550. * or used a shadow, depth texture...
  101551. * @param name The friendly name of the texture
  101552. * @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)
  101553. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  101554. * @param generateMipMaps True if mip maps need to be generated after render.
  101555. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  101556. * @param type The type of the buffer in the RTT (int, half float, float...)
  101557. * @param isCube True if a cube texture needs to be created
  101558. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  101559. * @param generateDepthBuffer True to generate a depth buffer
  101560. * @param generateStencilBuffer True to generate a stencil buffer
  101561. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  101562. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  101563. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101564. */
  101565. constructor(name: string, size: number | {
  101566. width: number;
  101567. height: number;
  101568. layers?: number;
  101569. } | {
  101570. ratio: number;
  101571. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  101572. /**
  101573. * Creates a depth stencil texture.
  101574. * This is only available in WebGL 2 or with the depth texture extension available.
  101575. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  101576. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  101577. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  101578. */
  101579. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  101580. private _processSizeParameter;
  101581. /**
  101582. * Define the number of samples to use in case of MSAA.
  101583. * It defaults to one meaning no MSAA has been enabled.
  101584. */
  101585. get samples(): number;
  101586. set samples(value: number);
  101587. /**
  101588. * Resets the refresh counter of the texture and start bak from scratch.
  101589. * Could be useful to regenerate the texture if it is setup to render only once.
  101590. */
  101591. resetRefreshCounter(): void;
  101592. /**
  101593. * Define the refresh rate of the texture or the rendering frequency.
  101594. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  101595. */
  101596. get refreshRate(): number;
  101597. set refreshRate(value: number);
  101598. /**
  101599. * Adds a post process to the render target rendering passes.
  101600. * @param postProcess define the post process to add
  101601. */
  101602. addPostProcess(postProcess: PostProcess): void;
  101603. /**
  101604. * Clear all the post processes attached to the render target
  101605. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  101606. */
  101607. clearPostProcesses(dispose?: boolean): void;
  101608. /**
  101609. * Remove one of the post process from the list of attached post processes to the texture
  101610. * @param postProcess define the post process to remove from the list
  101611. */
  101612. removePostProcess(postProcess: PostProcess): void;
  101613. /** @hidden */
  101614. _shouldRender(): boolean;
  101615. /**
  101616. * Gets the actual render size of the texture.
  101617. * @returns the width of the render size
  101618. */
  101619. getRenderSize(): number;
  101620. /**
  101621. * Gets the actual render width of the texture.
  101622. * @returns the width of the render size
  101623. */
  101624. getRenderWidth(): number;
  101625. /**
  101626. * Gets the actual render height of the texture.
  101627. * @returns the height of the render size
  101628. */
  101629. getRenderHeight(): number;
  101630. /**
  101631. * Gets the actual number of layers of the texture.
  101632. * @returns the number of layers
  101633. */
  101634. getRenderLayers(): number;
  101635. /**
  101636. * Get if the texture can be rescaled or not.
  101637. */
  101638. get canRescale(): boolean;
  101639. /**
  101640. * Resize the texture using a ratio.
  101641. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  101642. */
  101643. scale(ratio: number): void;
  101644. /**
  101645. * Get the texture reflection matrix used to rotate/transform the reflection.
  101646. * @returns the reflection matrix
  101647. */
  101648. getReflectionTextureMatrix(): Matrix;
  101649. /**
  101650. * Resize the texture to a new desired size.
  101651. * Be carrefull as it will recreate all the data in the new texture.
  101652. * @param size Define the new size. It can be:
  101653. * - a number for squared texture,
  101654. * - an object containing { width: number, height: number }
  101655. * - or an object containing a ratio { ratio: number }
  101656. */
  101657. resize(size: number | {
  101658. width: number;
  101659. height: number;
  101660. } | {
  101661. ratio: number;
  101662. }): void;
  101663. private _defaultRenderListPrepared;
  101664. /**
  101665. * Renders all the objects from the render list into the texture.
  101666. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  101667. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  101668. */
  101669. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  101670. private _bestReflectionRenderTargetDimension;
  101671. private _prepareRenderingManager;
  101672. /**
  101673. * @hidden
  101674. * @param faceIndex face index to bind to if this is a cubetexture
  101675. * @param layer defines the index of the texture to bind in the array
  101676. */
  101677. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  101678. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101679. private renderToTarget;
  101680. /**
  101681. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101682. * This allowed control for front to back rendering or reversly depending of the special needs.
  101683. *
  101684. * @param renderingGroupId The rendering group id corresponding to its index
  101685. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101686. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101687. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101688. */
  101689. 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;
  101690. /**
  101691. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101692. *
  101693. * @param renderingGroupId The rendering group id corresponding to its index
  101694. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101695. */
  101696. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101697. /**
  101698. * Clones the texture.
  101699. * @returns the cloned texture
  101700. */
  101701. clone(): RenderTargetTexture;
  101702. /**
  101703. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101704. * @returns The JSON representation of the texture
  101705. */
  101706. serialize(): any;
  101707. /**
  101708. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  101709. */
  101710. disposeFramebufferObjects(): void;
  101711. /**
  101712. * Dispose the texture and release its associated resources.
  101713. */
  101714. dispose(): void;
  101715. /** @hidden */
  101716. _rebuild(): void;
  101717. /**
  101718. * Clear the info related to rendering groups preventing retention point in material dispose.
  101719. */
  101720. freeRenderingGroups(): void;
  101721. /**
  101722. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101723. * @returns the view count
  101724. */
  101725. getViewCount(): number;
  101726. }
  101727. }
  101728. declare module BABYLON {
  101729. /**
  101730. * Class used to manipulate GUIDs
  101731. */
  101732. export class GUID {
  101733. /**
  101734. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101735. * Be aware Math.random() could cause collisions, but:
  101736. * "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"
  101737. * @returns a pseudo random id
  101738. */
  101739. static RandomId(): string;
  101740. }
  101741. }
  101742. declare module BABYLON {
  101743. /**
  101744. * Options to be used when creating a shadow depth material
  101745. */
  101746. export interface IIOptionShadowDepthMaterial {
  101747. /** Variables in the vertex shader code that need to have their names remapped.
  101748. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  101749. * "var_name" should be either: worldPos or vNormalW
  101750. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  101751. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  101752. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  101753. */
  101754. remappedVariables?: string[];
  101755. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  101756. standalone?: boolean;
  101757. }
  101758. /**
  101759. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  101760. */
  101761. export class ShadowDepthWrapper {
  101762. private _scene;
  101763. private _options?;
  101764. private _baseMaterial;
  101765. private _onEffectCreatedObserver;
  101766. private _subMeshToEffect;
  101767. private _subMeshToDepthEffect;
  101768. private _meshes;
  101769. /** @hidden */
  101770. _matriceNames: any;
  101771. /** Gets the standalone status of the wrapper */
  101772. get standalone(): boolean;
  101773. /** Gets the base material the wrapper is built upon */
  101774. get baseMaterial(): Material;
  101775. /**
  101776. * Instantiate a new shadow depth wrapper.
  101777. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  101778. * generate the shadow depth map. For more information, please refer to the documentation:
  101779. * https://doc.babylonjs.com/babylon101/shadows
  101780. * @param baseMaterial Material to wrap
  101781. * @param scene Define the scene the material belongs to
  101782. * @param options Options used to create the wrapper
  101783. */
  101784. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  101785. /**
  101786. * Gets the effect to use to generate the depth map
  101787. * @param subMesh subMesh to get the effect for
  101788. * @param shadowGenerator shadow generator to get the effect for
  101789. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  101790. */
  101791. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  101792. /**
  101793. * Specifies that the submesh is ready to be used for depth rendering
  101794. * @param subMesh submesh to check
  101795. * @param defines the list of defines to take into account when checking the effect
  101796. * @param shadowGenerator combined with subMesh, it defines the effect to check
  101797. * @param useInstances specifies that instances should be used
  101798. * @returns a boolean indicating that the submesh is ready or not
  101799. */
  101800. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  101801. /**
  101802. * Disposes the resources
  101803. */
  101804. dispose(): void;
  101805. private _makeEffect;
  101806. }
  101807. }
  101808. declare module BABYLON {
  101809. /**
  101810. * Options for compiling materials.
  101811. */
  101812. export interface IMaterialCompilationOptions {
  101813. /**
  101814. * Defines whether clip planes are enabled.
  101815. */
  101816. clipPlane: boolean;
  101817. /**
  101818. * Defines whether instances are enabled.
  101819. */
  101820. useInstances: boolean;
  101821. }
  101822. /**
  101823. * Options passed when calling customShaderNameResolve
  101824. */
  101825. export interface ICustomShaderNameResolveOptions {
  101826. /**
  101827. * 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
  101828. */
  101829. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  101830. }
  101831. /**
  101832. * Base class for the main features of a material in Babylon.js
  101833. */
  101834. export class Material implements IAnimatable {
  101835. /**
  101836. * Returns the triangle fill mode
  101837. */
  101838. static readonly TriangleFillMode: number;
  101839. /**
  101840. * Returns the wireframe mode
  101841. */
  101842. static readonly WireFrameFillMode: number;
  101843. /**
  101844. * Returns the point fill mode
  101845. */
  101846. static readonly PointFillMode: number;
  101847. /**
  101848. * Returns the point list draw mode
  101849. */
  101850. static readonly PointListDrawMode: number;
  101851. /**
  101852. * Returns the line list draw mode
  101853. */
  101854. static readonly LineListDrawMode: number;
  101855. /**
  101856. * Returns the line loop draw mode
  101857. */
  101858. static readonly LineLoopDrawMode: number;
  101859. /**
  101860. * Returns the line strip draw mode
  101861. */
  101862. static readonly LineStripDrawMode: number;
  101863. /**
  101864. * Returns the triangle strip draw mode
  101865. */
  101866. static readonly TriangleStripDrawMode: number;
  101867. /**
  101868. * Returns the triangle fan draw mode
  101869. */
  101870. static readonly TriangleFanDrawMode: number;
  101871. /**
  101872. * Stores the clock-wise side orientation
  101873. */
  101874. static readonly ClockWiseSideOrientation: number;
  101875. /**
  101876. * Stores the counter clock-wise side orientation
  101877. */
  101878. static readonly CounterClockWiseSideOrientation: number;
  101879. /**
  101880. * The dirty texture flag value
  101881. */
  101882. static readonly TextureDirtyFlag: number;
  101883. /**
  101884. * The dirty light flag value
  101885. */
  101886. static readonly LightDirtyFlag: number;
  101887. /**
  101888. * The dirty fresnel flag value
  101889. */
  101890. static readonly FresnelDirtyFlag: number;
  101891. /**
  101892. * The dirty attribute flag value
  101893. */
  101894. static readonly AttributesDirtyFlag: number;
  101895. /**
  101896. * The dirty misc flag value
  101897. */
  101898. static readonly MiscDirtyFlag: number;
  101899. /**
  101900. * The all dirty flag value
  101901. */
  101902. static readonly AllDirtyFlag: number;
  101903. /**
  101904. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101905. */
  101906. static readonly MATERIAL_OPAQUE: number;
  101907. /**
  101908. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101909. */
  101910. static readonly MATERIAL_ALPHATEST: number;
  101911. /**
  101912. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101913. */
  101914. static readonly MATERIAL_ALPHABLEND: number;
  101915. /**
  101916. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101917. * They are also discarded below the alpha cutoff threshold to improve performances.
  101918. */
  101919. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  101920. /**
  101921. * The Whiteout method is used to blend normals.
  101922. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101923. */
  101924. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  101925. /**
  101926. * The Reoriented Normal Mapping method is used to blend normals.
  101927. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101928. */
  101929. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  101930. /**
  101931. * Custom callback helping to override the default shader used in the material.
  101932. */
  101933. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  101934. /**
  101935. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  101936. */
  101937. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  101938. /**
  101939. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  101940. * This means that the material can keep using a previous shader while a new one is being compiled.
  101941. * This is mostly used when shader parallel compilation is supported (true by default)
  101942. */
  101943. allowShaderHotSwapping: boolean;
  101944. /**
  101945. * The ID of the material
  101946. */
  101947. id: string;
  101948. /**
  101949. * Gets or sets the unique id of the material
  101950. */
  101951. uniqueId: number;
  101952. /**
  101953. * The name of the material
  101954. */
  101955. name: string;
  101956. /**
  101957. * Gets or sets user defined metadata
  101958. */
  101959. metadata: any;
  101960. /**
  101961. * For internal use only. Please do not use.
  101962. */
  101963. reservedDataStore: any;
  101964. /**
  101965. * Specifies if the ready state should be checked on each call
  101966. */
  101967. checkReadyOnEveryCall: boolean;
  101968. /**
  101969. * Specifies if the ready state should be checked once
  101970. */
  101971. checkReadyOnlyOnce: boolean;
  101972. /**
  101973. * The state of the material
  101974. */
  101975. state: string;
  101976. /**
  101977. * If the material should be rendered to several textures with MRT extension
  101978. */
  101979. get shouldRenderToMRT(): boolean;
  101980. /**
  101981. * The alpha value of the material
  101982. */
  101983. protected _alpha: number;
  101984. /**
  101985. * List of inspectable custom properties (used by the Inspector)
  101986. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101987. */
  101988. inspectableCustomProperties: IInspectable[];
  101989. /**
  101990. * Sets the alpha value of the material
  101991. */
  101992. set alpha(value: number);
  101993. /**
  101994. * Gets the alpha value of the material
  101995. */
  101996. get alpha(): number;
  101997. /**
  101998. * Specifies if back face culling is enabled
  101999. */
  102000. protected _backFaceCulling: boolean;
  102001. /**
  102002. * Sets the back-face culling state
  102003. */
  102004. set backFaceCulling(value: boolean);
  102005. /**
  102006. * Gets the back-face culling state
  102007. */
  102008. get backFaceCulling(): boolean;
  102009. /**
  102010. * Stores the value for side orientation
  102011. */
  102012. sideOrientation: number;
  102013. /**
  102014. * Callback triggered when the material is compiled
  102015. */
  102016. onCompiled: Nullable<(effect: Effect) => void>;
  102017. /**
  102018. * Callback triggered when an error occurs
  102019. */
  102020. onError: Nullable<(effect: Effect, errors: string) => void>;
  102021. /**
  102022. * Callback triggered to get the render target textures
  102023. */
  102024. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  102025. /**
  102026. * Gets a boolean indicating that current material needs to register RTT
  102027. */
  102028. get hasRenderTargetTextures(): boolean;
  102029. /**
  102030. * Specifies if the material should be serialized
  102031. */
  102032. doNotSerialize: boolean;
  102033. /**
  102034. * @hidden
  102035. */
  102036. _storeEffectOnSubMeshes: boolean;
  102037. /**
  102038. * Stores the animations for the material
  102039. */
  102040. animations: Nullable<Array<Animation>>;
  102041. /**
  102042. * An event triggered when the material is disposed
  102043. */
  102044. onDisposeObservable: Observable<Material>;
  102045. /**
  102046. * An observer which watches for dispose events
  102047. */
  102048. private _onDisposeObserver;
  102049. private _onUnBindObservable;
  102050. /**
  102051. * Called during a dispose event
  102052. */
  102053. set onDispose(callback: () => void);
  102054. private _onBindObservable;
  102055. /**
  102056. * An event triggered when the material is bound
  102057. */
  102058. get onBindObservable(): Observable<AbstractMesh>;
  102059. /**
  102060. * An observer which watches for bind events
  102061. */
  102062. private _onBindObserver;
  102063. /**
  102064. * Called during a bind event
  102065. */
  102066. set onBind(callback: (Mesh: AbstractMesh) => void);
  102067. /**
  102068. * An event triggered when the material is unbound
  102069. */
  102070. get onUnBindObservable(): Observable<Material>;
  102071. protected _onEffectCreatedObservable: Nullable<Observable<{
  102072. effect: Effect;
  102073. subMesh: Nullable<SubMesh>;
  102074. }>>;
  102075. /**
  102076. * An event triggered when the effect is (re)created
  102077. */
  102078. get onEffectCreatedObservable(): Observable<{
  102079. effect: Effect;
  102080. subMesh: Nullable<SubMesh>;
  102081. }>;
  102082. /**
  102083. * Stores the value of the alpha mode
  102084. */
  102085. private _alphaMode;
  102086. /**
  102087. * Sets the value of the alpha mode.
  102088. *
  102089. * | Value | Type | Description |
  102090. * | --- | --- | --- |
  102091. * | 0 | ALPHA_DISABLE | |
  102092. * | 1 | ALPHA_ADD | |
  102093. * | 2 | ALPHA_COMBINE | |
  102094. * | 3 | ALPHA_SUBTRACT | |
  102095. * | 4 | ALPHA_MULTIPLY | |
  102096. * | 5 | ALPHA_MAXIMIZED | |
  102097. * | 6 | ALPHA_ONEONE | |
  102098. * | 7 | ALPHA_PREMULTIPLIED | |
  102099. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  102100. * | 9 | ALPHA_INTERPOLATE | |
  102101. * | 10 | ALPHA_SCREENMODE | |
  102102. *
  102103. */
  102104. set alphaMode(value: number);
  102105. /**
  102106. * Gets the value of the alpha mode
  102107. */
  102108. get alphaMode(): number;
  102109. /**
  102110. * Stores the state of the need depth pre-pass value
  102111. */
  102112. private _needDepthPrePass;
  102113. /**
  102114. * Sets the need depth pre-pass value
  102115. */
  102116. set needDepthPrePass(value: boolean);
  102117. /**
  102118. * Gets the depth pre-pass value
  102119. */
  102120. get needDepthPrePass(): boolean;
  102121. /**
  102122. * Specifies if depth writing should be disabled
  102123. */
  102124. disableDepthWrite: boolean;
  102125. /**
  102126. * Specifies if color writing should be disabled
  102127. */
  102128. disableColorWrite: boolean;
  102129. /**
  102130. * Specifies if depth writing should be forced
  102131. */
  102132. forceDepthWrite: boolean;
  102133. /**
  102134. * Specifies the depth function that should be used. 0 means the default engine function
  102135. */
  102136. depthFunction: number;
  102137. /**
  102138. * Specifies if there should be a separate pass for culling
  102139. */
  102140. separateCullingPass: boolean;
  102141. /**
  102142. * Stores the state specifing if fog should be enabled
  102143. */
  102144. private _fogEnabled;
  102145. /**
  102146. * Sets the state for enabling fog
  102147. */
  102148. set fogEnabled(value: boolean);
  102149. /**
  102150. * Gets the value of the fog enabled state
  102151. */
  102152. get fogEnabled(): boolean;
  102153. /**
  102154. * Stores the size of points
  102155. */
  102156. pointSize: number;
  102157. /**
  102158. * Stores the z offset value
  102159. */
  102160. zOffset: number;
  102161. get wireframe(): boolean;
  102162. /**
  102163. * Sets the state of wireframe mode
  102164. */
  102165. set wireframe(value: boolean);
  102166. /**
  102167. * Gets the value specifying if point clouds are enabled
  102168. */
  102169. get pointsCloud(): boolean;
  102170. /**
  102171. * Sets the state of point cloud mode
  102172. */
  102173. set pointsCloud(value: boolean);
  102174. /**
  102175. * Gets the material fill mode
  102176. */
  102177. get fillMode(): number;
  102178. /**
  102179. * Sets the material fill mode
  102180. */
  102181. set fillMode(value: number);
  102182. /**
  102183. * @hidden
  102184. * Stores the effects for the material
  102185. */
  102186. _effect: Nullable<Effect>;
  102187. /**
  102188. * Specifies if uniform buffers should be used
  102189. */
  102190. private _useUBO;
  102191. /**
  102192. * Stores a reference to the scene
  102193. */
  102194. private _scene;
  102195. /**
  102196. * Stores the fill mode state
  102197. */
  102198. private _fillMode;
  102199. /**
  102200. * Specifies if the depth write state should be cached
  102201. */
  102202. private _cachedDepthWriteState;
  102203. /**
  102204. * Specifies if the color write state should be cached
  102205. */
  102206. private _cachedColorWriteState;
  102207. /**
  102208. * Specifies if the depth function state should be cached
  102209. */
  102210. private _cachedDepthFunctionState;
  102211. /**
  102212. * Stores the uniform buffer
  102213. */
  102214. protected _uniformBuffer: UniformBuffer;
  102215. /** @hidden */
  102216. _indexInSceneMaterialArray: number;
  102217. /** @hidden */
  102218. meshMap: Nullable<{
  102219. [id: string]: AbstractMesh | undefined;
  102220. }>;
  102221. /**
  102222. * Creates a material instance
  102223. * @param name defines the name of the material
  102224. * @param scene defines the scene to reference
  102225. * @param doNotAdd specifies if the material should be added to the scene
  102226. */
  102227. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  102228. /**
  102229. * Returns a string representation of the current material
  102230. * @param fullDetails defines a boolean indicating which levels of logging is desired
  102231. * @returns a string with material information
  102232. */
  102233. toString(fullDetails?: boolean): string;
  102234. /**
  102235. * Gets the class name of the material
  102236. * @returns a string with the class name of the material
  102237. */
  102238. getClassName(): string;
  102239. /**
  102240. * Specifies if updates for the material been locked
  102241. */
  102242. get isFrozen(): boolean;
  102243. /**
  102244. * Locks updates for the material
  102245. */
  102246. freeze(): void;
  102247. /**
  102248. * Unlocks updates for the material
  102249. */
  102250. unfreeze(): void;
  102251. /**
  102252. * Specifies if the material is ready to be used
  102253. * @param mesh defines the mesh to check
  102254. * @param useInstances specifies if instances should be used
  102255. * @returns a boolean indicating if the material is ready to be used
  102256. */
  102257. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102258. /**
  102259. * Specifies that the submesh is ready to be used
  102260. * @param mesh defines the mesh to check
  102261. * @param subMesh defines which submesh to check
  102262. * @param useInstances specifies that instances should be used
  102263. * @returns a boolean indicating that the submesh is ready or not
  102264. */
  102265. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102266. /**
  102267. * Returns the material effect
  102268. * @returns the effect associated with the material
  102269. */
  102270. getEffect(): Nullable<Effect>;
  102271. /**
  102272. * Returns the current scene
  102273. * @returns a Scene
  102274. */
  102275. getScene(): Scene;
  102276. /**
  102277. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102278. */
  102279. protected _forceAlphaTest: boolean;
  102280. /**
  102281. * The transparency mode of the material.
  102282. */
  102283. protected _transparencyMode: Nullable<number>;
  102284. /**
  102285. * Gets the current transparency mode.
  102286. */
  102287. get transparencyMode(): Nullable<number>;
  102288. /**
  102289. * Sets the transparency mode of the material.
  102290. *
  102291. * | Value | Type | Description |
  102292. * | ----- | ----------------------------------- | ----------- |
  102293. * | 0 | OPAQUE | |
  102294. * | 1 | ALPHATEST | |
  102295. * | 2 | ALPHABLEND | |
  102296. * | 3 | ALPHATESTANDBLEND | |
  102297. *
  102298. */
  102299. set transparencyMode(value: Nullable<number>);
  102300. /**
  102301. * Returns true if alpha blending should be disabled.
  102302. */
  102303. protected get _disableAlphaBlending(): boolean;
  102304. /**
  102305. * Specifies whether or not this material should be rendered in alpha blend mode.
  102306. * @returns a boolean specifying if alpha blending is needed
  102307. */
  102308. needAlphaBlending(): boolean;
  102309. /**
  102310. * Specifies if the mesh will require alpha blending
  102311. * @param mesh defines the mesh to check
  102312. * @returns a boolean specifying if alpha blending is needed for the mesh
  102313. */
  102314. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102315. /**
  102316. * Specifies whether or not this material should be rendered in alpha test mode.
  102317. * @returns a boolean specifying if an alpha test is needed.
  102318. */
  102319. needAlphaTesting(): boolean;
  102320. /**
  102321. * Specifies if material alpha testing should be turned on for the mesh
  102322. * @param mesh defines the mesh to check
  102323. */
  102324. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  102325. /**
  102326. * Gets the texture used for the alpha test
  102327. * @returns the texture to use for alpha testing
  102328. */
  102329. getAlphaTestTexture(): Nullable<BaseTexture>;
  102330. /**
  102331. * Marks the material to indicate that it needs to be re-calculated
  102332. */
  102333. markDirty(): void;
  102334. /** @hidden */
  102335. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  102336. /**
  102337. * Binds the material to the mesh
  102338. * @param world defines the world transformation matrix
  102339. * @param mesh defines the mesh to bind the material to
  102340. */
  102341. bind(world: Matrix, mesh?: Mesh): void;
  102342. /**
  102343. * Binds the submesh to the material
  102344. * @param world defines the world transformation matrix
  102345. * @param mesh defines the mesh containing the submesh
  102346. * @param subMesh defines the submesh to bind the material to
  102347. */
  102348. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102349. /**
  102350. * Binds the world matrix to the material
  102351. * @param world defines the world transformation matrix
  102352. */
  102353. bindOnlyWorldMatrix(world: Matrix): void;
  102354. /**
  102355. * Binds the scene's uniform buffer to the effect.
  102356. * @param effect defines the effect to bind to the scene uniform buffer
  102357. * @param sceneUbo defines the uniform buffer storing scene data
  102358. */
  102359. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  102360. /**
  102361. * Binds the view matrix to the effect
  102362. * @param effect defines the effect to bind the view matrix to
  102363. */
  102364. bindView(effect: Effect): void;
  102365. /**
  102366. * Binds the view projection matrix to the effect
  102367. * @param effect defines the effect to bind the view projection matrix to
  102368. */
  102369. bindViewProjection(effect: Effect): void;
  102370. /**
  102371. * Processes to execute after binding the material to a mesh
  102372. * @param mesh defines the rendered mesh
  102373. */
  102374. protected _afterBind(mesh?: Mesh): void;
  102375. /**
  102376. * Unbinds the material from the mesh
  102377. */
  102378. unbind(): void;
  102379. /**
  102380. * Gets the active textures from the material
  102381. * @returns an array of textures
  102382. */
  102383. getActiveTextures(): BaseTexture[];
  102384. /**
  102385. * Specifies if the material uses a texture
  102386. * @param texture defines the texture to check against the material
  102387. * @returns a boolean specifying if the material uses the texture
  102388. */
  102389. hasTexture(texture: BaseTexture): boolean;
  102390. /**
  102391. * Makes a duplicate of the material, and gives it a new name
  102392. * @param name defines the new name for the duplicated material
  102393. * @returns the cloned material
  102394. */
  102395. clone(name: string): Nullable<Material>;
  102396. /**
  102397. * Gets the meshes bound to the material
  102398. * @returns an array of meshes bound to the material
  102399. */
  102400. getBindedMeshes(): AbstractMesh[];
  102401. /**
  102402. * Force shader compilation
  102403. * @param mesh defines the mesh associated with this material
  102404. * @param onCompiled defines a function to execute once the material is compiled
  102405. * @param options defines the options to configure the compilation
  102406. * @param onError defines a function to execute if the material fails compiling
  102407. */
  102408. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  102409. /**
  102410. * Force shader compilation
  102411. * @param mesh defines the mesh that will use this material
  102412. * @param options defines additional options for compiling the shaders
  102413. * @returns a promise that resolves when the compilation completes
  102414. */
  102415. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  102416. private static readonly _AllDirtyCallBack;
  102417. private static readonly _ImageProcessingDirtyCallBack;
  102418. private static readonly _TextureDirtyCallBack;
  102419. private static readonly _FresnelDirtyCallBack;
  102420. private static readonly _MiscDirtyCallBack;
  102421. private static readonly _LightsDirtyCallBack;
  102422. private static readonly _AttributeDirtyCallBack;
  102423. private static _FresnelAndMiscDirtyCallBack;
  102424. private static _TextureAndMiscDirtyCallBack;
  102425. private static readonly _DirtyCallbackArray;
  102426. private static readonly _RunDirtyCallBacks;
  102427. /**
  102428. * Marks a define in the material to indicate that it needs to be re-computed
  102429. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  102430. */
  102431. markAsDirty(flag: number): void;
  102432. /**
  102433. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  102434. * @param func defines a function which checks material defines against the submeshes
  102435. */
  102436. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  102437. /**
  102438. * Indicates that the scene should check if the rendering now needs a prepass
  102439. */
  102440. protected _markScenePrePassDirty(): void;
  102441. /**
  102442. * Indicates that we need to re-calculated for all submeshes
  102443. */
  102444. protected _markAllSubMeshesAsAllDirty(): void;
  102445. /**
  102446. * Indicates that image processing needs to be re-calculated for all submeshes
  102447. */
  102448. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  102449. /**
  102450. * Indicates that textures need to be re-calculated for all submeshes
  102451. */
  102452. protected _markAllSubMeshesAsTexturesDirty(): void;
  102453. /**
  102454. * Indicates that fresnel needs to be re-calculated for all submeshes
  102455. */
  102456. protected _markAllSubMeshesAsFresnelDirty(): void;
  102457. /**
  102458. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  102459. */
  102460. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  102461. /**
  102462. * Indicates that lights need to be re-calculated for all submeshes
  102463. */
  102464. protected _markAllSubMeshesAsLightsDirty(): void;
  102465. /**
  102466. * Indicates that attributes need to be re-calculated for all submeshes
  102467. */
  102468. protected _markAllSubMeshesAsAttributesDirty(): void;
  102469. /**
  102470. * Indicates that misc needs to be re-calculated for all submeshes
  102471. */
  102472. protected _markAllSubMeshesAsMiscDirty(): void;
  102473. /**
  102474. * Indicates that textures and misc need to be re-calculated for all submeshes
  102475. */
  102476. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  102477. /**
  102478. * Disposes the material
  102479. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102480. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102481. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102482. */
  102483. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102484. /** @hidden */
  102485. private releaseVertexArrayObject;
  102486. /**
  102487. * Serializes this material
  102488. * @returns the serialized material object
  102489. */
  102490. serialize(): any;
  102491. /**
  102492. * Creates a material from parsed material data
  102493. * @param parsedMaterial defines parsed material data
  102494. * @param scene defines the hosting scene
  102495. * @param rootUrl defines the root URL to use to load textures
  102496. * @returns a new material
  102497. */
  102498. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  102499. }
  102500. }
  102501. declare module BABYLON {
  102502. /**
  102503. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102504. * separate meshes. This can be use to improve performances.
  102505. * @see https://doc.babylonjs.com/how_to/multi_materials
  102506. */
  102507. export class MultiMaterial extends Material {
  102508. private _subMaterials;
  102509. /**
  102510. * Gets or Sets the list of Materials used within the multi material.
  102511. * They need to be ordered according to the submeshes order in the associated mesh
  102512. */
  102513. get subMaterials(): Nullable<Material>[];
  102514. set subMaterials(value: Nullable<Material>[]);
  102515. /**
  102516. * Function used to align with Node.getChildren()
  102517. * @returns the list of Materials used within the multi material
  102518. */
  102519. getChildren(): Nullable<Material>[];
  102520. /**
  102521. * Instantiates a new Multi Material
  102522. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102523. * separate meshes. This can be use to improve performances.
  102524. * @see https://doc.babylonjs.com/how_to/multi_materials
  102525. * @param name Define the name in the scene
  102526. * @param scene Define the scene the material belongs to
  102527. */
  102528. constructor(name: string, scene: Scene);
  102529. private _hookArray;
  102530. /**
  102531. * Get one of the submaterial by its index in the submaterials array
  102532. * @param index The index to look the sub material at
  102533. * @returns The Material if the index has been defined
  102534. */
  102535. getSubMaterial(index: number): Nullable<Material>;
  102536. /**
  102537. * Get the list of active textures for the whole sub materials list.
  102538. * @returns All the textures that will be used during the rendering
  102539. */
  102540. getActiveTextures(): BaseTexture[];
  102541. /**
  102542. * Gets the current class name of the material e.g. "MultiMaterial"
  102543. * Mainly use in serialization.
  102544. * @returns the class name
  102545. */
  102546. getClassName(): string;
  102547. /**
  102548. * Checks if the material is ready to render the requested sub mesh
  102549. * @param mesh Define the mesh the submesh belongs to
  102550. * @param subMesh Define the sub mesh to look readyness for
  102551. * @param useInstances Define whether or not the material is used with instances
  102552. * @returns true if ready, otherwise false
  102553. */
  102554. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102555. /**
  102556. * Clones the current material and its related sub materials
  102557. * @param name Define the name of the newly cloned material
  102558. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  102559. * @returns the cloned material
  102560. */
  102561. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  102562. /**
  102563. * Serializes the materials into a JSON representation.
  102564. * @returns the JSON representation
  102565. */
  102566. serialize(): any;
  102567. /**
  102568. * Dispose the material and release its associated resources
  102569. * @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)
  102570. * @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)
  102571. * @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)
  102572. */
  102573. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  102574. /**
  102575. * Creates a MultiMaterial from parsed MultiMaterial data.
  102576. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  102577. * @param scene defines the hosting scene
  102578. * @returns a new MultiMaterial
  102579. */
  102580. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  102581. }
  102582. }
  102583. declare module BABYLON {
  102584. /**
  102585. * Defines a subdivision inside a mesh
  102586. */
  102587. export class SubMesh implements ICullable {
  102588. /** the material index to use */
  102589. materialIndex: number;
  102590. /** vertex index start */
  102591. verticesStart: number;
  102592. /** vertices count */
  102593. verticesCount: number;
  102594. /** index start */
  102595. indexStart: number;
  102596. /** indices count */
  102597. indexCount: number;
  102598. /** @hidden */
  102599. _materialDefines: Nullable<MaterialDefines>;
  102600. /** @hidden */
  102601. _materialEffect: Nullable<Effect>;
  102602. /** @hidden */
  102603. _effectOverride: Nullable<Effect>;
  102604. /**
  102605. * Gets material defines used by the effect associated to the sub mesh
  102606. */
  102607. get materialDefines(): Nullable<MaterialDefines>;
  102608. /**
  102609. * Sets material defines used by the effect associated to the sub mesh
  102610. */
  102611. set materialDefines(defines: Nullable<MaterialDefines>);
  102612. /**
  102613. * Gets associated effect
  102614. */
  102615. get effect(): Nullable<Effect>;
  102616. /**
  102617. * Sets associated effect (effect used to render this submesh)
  102618. * @param effect defines the effect to associate with
  102619. * @param defines defines the set of defines used to compile this effect
  102620. */
  102621. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  102622. /** @hidden */
  102623. _linesIndexCount: number;
  102624. private _mesh;
  102625. private _renderingMesh;
  102626. private _boundingInfo;
  102627. private _linesIndexBuffer;
  102628. /** @hidden */
  102629. _lastColliderWorldVertices: Nullable<Vector3[]>;
  102630. /** @hidden */
  102631. _trianglePlanes: Plane[];
  102632. /** @hidden */
  102633. _lastColliderTransformMatrix: Nullable<Matrix>;
  102634. /** @hidden */
  102635. _renderId: number;
  102636. /** @hidden */
  102637. _alphaIndex: number;
  102638. /** @hidden */
  102639. _distanceToCamera: number;
  102640. /** @hidden */
  102641. _id: number;
  102642. private _currentMaterial;
  102643. /**
  102644. * Add a new submesh to a mesh
  102645. * @param materialIndex defines the material index to use
  102646. * @param verticesStart defines vertex index start
  102647. * @param verticesCount defines vertices count
  102648. * @param indexStart defines index start
  102649. * @param indexCount defines indices count
  102650. * @param mesh defines the parent mesh
  102651. * @param renderingMesh defines an optional rendering mesh
  102652. * @param createBoundingBox defines if bounding box should be created for this submesh
  102653. * @returns the new submesh
  102654. */
  102655. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  102656. /**
  102657. * Creates a new submesh
  102658. * @param materialIndex defines the material index to use
  102659. * @param verticesStart defines vertex index start
  102660. * @param verticesCount defines vertices count
  102661. * @param indexStart defines index start
  102662. * @param indexCount defines indices count
  102663. * @param mesh defines the parent mesh
  102664. * @param renderingMesh defines an optional rendering mesh
  102665. * @param createBoundingBox defines if bounding box should be created for this submesh
  102666. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  102667. */
  102668. constructor(
  102669. /** the material index to use */
  102670. materialIndex: number,
  102671. /** vertex index start */
  102672. verticesStart: number,
  102673. /** vertices count */
  102674. verticesCount: number,
  102675. /** index start */
  102676. indexStart: number,
  102677. /** indices count */
  102678. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  102679. /**
  102680. * Returns true if this submesh covers the entire parent mesh
  102681. * @ignorenaming
  102682. */
  102683. get IsGlobal(): boolean;
  102684. /**
  102685. * Returns the submesh BoudingInfo object
  102686. * @returns current bounding info (or mesh's one if the submesh is global)
  102687. */
  102688. getBoundingInfo(): BoundingInfo;
  102689. /**
  102690. * Sets the submesh BoundingInfo
  102691. * @param boundingInfo defines the new bounding info to use
  102692. * @returns the SubMesh
  102693. */
  102694. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  102695. /**
  102696. * Returns the mesh of the current submesh
  102697. * @return the parent mesh
  102698. */
  102699. getMesh(): AbstractMesh;
  102700. /**
  102701. * Returns the rendering mesh of the submesh
  102702. * @returns the rendering mesh (could be different from parent mesh)
  102703. */
  102704. getRenderingMesh(): Mesh;
  102705. /**
  102706. * Returns the replacement mesh of the submesh
  102707. * @returns the replacement mesh (could be different from parent mesh)
  102708. */
  102709. getReplacementMesh(): Nullable<AbstractMesh>;
  102710. /**
  102711. * Returns the effective mesh of the submesh
  102712. * @returns the effective mesh (could be different from parent mesh)
  102713. */
  102714. getEffectiveMesh(): AbstractMesh;
  102715. /**
  102716. * Returns the submesh material
  102717. * @returns null or the current material
  102718. */
  102719. getMaterial(): Nullable<Material>;
  102720. private _IsMultiMaterial;
  102721. /**
  102722. * Sets a new updated BoundingInfo object to the submesh
  102723. * @param data defines an optional position array to use to determine the bounding info
  102724. * @returns the SubMesh
  102725. */
  102726. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  102727. /** @hidden */
  102728. _checkCollision(collider: Collider): boolean;
  102729. /**
  102730. * Updates the submesh BoundingInfo
  102731. * @param world defines the world matrix to use to update the bounding info
  102732. * @returns the submesh
  102733. */
  102734. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  102735. /**
  102736. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  102737. * @param frustumPlanes defines the frustum planes
  102738. * @returns true if the submesh is intersecting with the frustum
  102739. */
  102740. isInFrustum(frustumPlanes: Plane[]): boolean;
  102741. /**
  102742. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  102743. * @param frustumPlanes defines the frustum planes
  102744. * @returns true if the submesh is inside the frustum
  102745. */
  102746. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102747. /**
  102748. * Renders the submesh
  102749. * @param enableAlphaMode defines if alpha needs to be used
  102750. * @returns the submesh
  102751. */
  102752. render(enableAlphaMode: boolean): SubMesh;
  102753. /**
  102754. * @hidden
  102755. */
  102756. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  102757. /**
  102758. * Checks if the submesh intersects with a ray
  102759. * @param ray defines the ray to test
  102760. * @returns true is the passed ray intersects the submesh bounding box
  102761. */
  102762. canIntersects(ray: Ray): boolean;
  102763. /**
  102764. * Intersects current submesh with a ray
  102765. * @param ray defines the ray to test
  102766. * @param positions defines mesh's positions array
  102767. * @param indices defines mesh's indices array
  102768. * @param fastCheck defines if the first intersection will be used (and not the closest)
  102769. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102770. * @returns intersection info or null if no intersection
  102771. */
  102772. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  102773. /** @hidden */
  102774. private _intersectLines;
  102775. /** @hidden */
  102776. private _intersectUnIndexedLines;
  102777. /** @hidden */
  102778. private _intersectTriangles;
  102779. /** @hidden */
  102780. private _intersectUnIndexedTriangles;
  102781. /** @hidden */
  102782. _rebuild(): void;
  102783. /**
  102784. * Creates a new submesh from the passed mesh
  102785. * @param newMesh defines the new hosting mesh
  102786. * @param newRenderingMesh defines an optional rendering mesh
  102787. * @returns the new submesh
  102788. */
  102789. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  102790. /**
  102791. * Release associated resources
  102792. */
  102793. dispose(): void;
  102794. /**
  102795. * Gets the class name
  102796. * @returns the string "SubMesh".
  102797. */
  102798. getClassName(): string;
  102799. /**
  102800. * Creates a new submesh from indices data
  102801. * @param materialIndex the index of the main mesh material
  102802. * @param startIndex the index where to start the copy in the mesh indices array
  102803. * @param indexCount the number of indices to copy then from the startIndex
  102804. * @param mesh the main mesh to create the submesh from
  102805. * @param renderingMesh the optional rendering mesh
  102806. * @returns a new submesh
  102807. */
  102808. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  102809. }
  102810. }
  102811. declare module BABYLON {
  102812. /**
  102813. * Class used to represent data loading progression
  102814. */
  102815. export class SceneLoaderFlags {
  102816. private static _ForceFullSceneLoadingForIncremental;
  102817. private static _ShowLoadingScreen;
  102818. private static _CleanBoneMatrixWeights;
  102819. private static _loggingLevel;
  102820. /**
  102821. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  102822. */
  102823. static get ForceFullSceneLoadingForIncremental(): boolean;
  102824. static set ForceFullSceneLoadingForIncremental(value: boolean);
  102825. /**
  102826. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  102827. */
  102828. static get ShowLoadingScreen(): boolean;
  102829. static set ShowLoadingScreen(value: boolean);
  102830. /**
  102831. * Defines the current logging level (while loading the scene)
  102832. * @ignorenaming
  102833. */
  102834. static get loggingLevel(): number;
  102835. static set loggingLevel(value: number);
  102836. /**
  102837. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  102838. */
  102839. static get CleanBoneMatrixWeights(): boolean;
  102840. static set CleanBoneMatrixWeights(value: boolean);
  102841. }
  102842. }
  102843. declare module BABYLON {
  102844. /**
  102845. * Class used to store geometry data (vertex buffers + index buffer)
  102846. */
  102847. export class Geometry implements IGetSetVerticesData {
  102848. /**
  102849. * Gets or sets the ID of the geometry
  102850. */
  102851. id: string;
  102852. /**
  102853. * Gets or sets the unique ID of the geometry
  102854. */
  102855. uniqueId: number;
  102856. /**
  102857. * Gets the delay loading state of the geometry (none by default which means not delayed)
  102858. */
  102859. delayLoadState: number;
  102860. /**
  102861. * Gets the file containing the data to load when running in delay load state
  102862. */
  102863. delayLoadingFile: Nullable<string>;
  102864. /**
  102865. * Callback called when the geometry is updated
  102866. */
  102867. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  102868. private _scene;
  102869. private _engine;
  102870. private _meshes;
  102871. private _totalVertices;
  102872. /** @hidden */
  102873. _indices: IndicesArray;
  102874. /** @hidden */
  102875. _vertexBuffers: {
  102876. [key: string]: VertexBuffer;
  102877. };
  102878. private _isDisposed;
  102879. private _extend;
  102880. private _boundingBias;
  102881. /** @hidden */
  102882. _delayInfo: Array<string>;
  102883. private _indexBuffer;
  102884. private _indexBufferIsUpdatable;
  102885. /** @hidden */
  102886. _boundingInfo: Nullable<BoundingInfo>;
  102887. /** @hidden */
  102888. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  102889. /** @hidden */
  102890. _softwareSkinningFrameId: number;
  102891. private _vertexArrayObjects;
  102892. private _updatable;
  102893. /** @hidden */
  102894. _positions: Nullable<Vector3[]>;
  102895. /**
  102896. * 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
  102897. */
  102898. get boundingBias(): Vector2;
  102899. /**
  102900. * 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
  102901. */
  102902. set boundingBias(value: Vector2);
  102903. /**
  102904. * Static function used to attach a new empty geometry to a mesh
  102905. * @param mesh defines the mesh to attach the geometry to
  102906. * @returns the new Geometry
  102907. */
  102908. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  102909. /** Get the list of meshes using this geometry */
  102910. get meshes(): Mesh[];
  102911. /**
  102912. * 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
  102913. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  102914. */
  102915. useBoundingInfoFromGeometry: boolean;
  102916. /**
  102917. * Creates a new geometry
  102918. * @param id defines the unique ID
  102919. * @param scene defines the hosting scene
  102920. * @param vertexData defines the VertexData used to get geometry data
  102921. * @param updatable defines if geometry must be updatable (false by default)
  102922. * @param mesh defines the mesh that will be associated with the geometry
  102923. */
  102924. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  102925. /**
  102926. * Gets the current extend of the geometry
  102927. */
  102928. get extend(): {
  102929. minimum: Vector3;
  102930. maximum: Vector3;
  102931. };
  102932. /**
  102933. * Gets the hosting scene
  102934. * @returns the hosting Scene
  102935. */
  102936. getScene(): Scene;
  102937. /**
  102938. * Gets the hosting engine
  102939. * @returns the hosting Engine
  102940. */
  102941. getEngine(): Engine;
  102942. /**
  102943. * Defines if the geometry is ready to use
  102944. * @returns true if the geometry is ready to be used
  102945. */
  102946. isReady(): boolean;
  102947. /**
  102948. * Gets a value indicating that the geometry should not be serialized
  102949. */
  102950. get doNotSerialize(): boolean;
  102951. /** @hidden */
  102952. _rebuild(): void;
  102953. /**
  102954. * Affects all geometry data in one call
  102955. * @param vertexData defines the geometry data
  102956. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  102957. */
  102958. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  102959. /**
  102960. * Set specific vertex data
  102961. * @param kind defines the data kind (Position, normal, etc...)
  102962. * @param data defines the vertex data to use
  102963. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102964. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102965. */
  102966. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  102967. /**
  102968. * Removes a specific vertex data
  102969. * @param kind defines the data kind (Position, normal, etc...)
  102970. */
  102971. removeVerticesData(kind: string): void;
  102972. /**
  102973. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  102974. * @param buffer defines the vertex buffer to use
  102975. * @param totalVertices defines the total number of vertices for position kind (could be null)
  102976. */
  102977. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  102978. /**
  102979. * Update a specific vertex buffer
  102980. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  102981. * It will do nothing if the buffer is not updatable
  102982. * @param kind defines the data kind (Position, normal, etc...)
  102983. * @param data defines the data to use
  102984. * @param offset defines the offset in the target buffer where to store the data
  102985. * @param useBytes set to true if the offset is in bytes
  102986. */
  102987. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  102988. /**
  102989. * Update a specific vertex buffer
  102990. * This function will create a new buffer if the current one is not updatable
  102991. * @param kind defines the data kind (Position, normal, etc...)
  102992. * @param data defines the data to use
  102993. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  102994. */
  102995. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  102996. private _updateBoundingInfo;
  102997. /** @hidden */
  102998. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  102999. /**
  103000. * Gets total number of vertices
  103001. * @returns the total number of vertices
  103002. */
  103003. getTotalVertices(): number;
  103004. /**
  103005. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  103006. * @param kind defines the data kind (Position, normal, etc...)
  103007. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103008. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103009. * @returns a float array containing vertex data
  103010. */
  103011. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  103012. /**
  103013. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  103014. * @param kind defines the data kind (Position, normal, etc...)
  103015. * @returns true if the vertex buffer with the specified kind is updatable
  103016. */
  103017. isVertexBufferUpdatable(kind: string): boolean;
  103018. /**
  103019. * Gets a specific vertex buffer
  103020. * @param kind defines the data kind (Position, normal, etc...)
  103021. * @returns a VertexBuffer
  103022. */
  103023. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  103024. /**
  103025. * Returns all vertex buffers
  103026. * @return an object holding all vertex buffers indexed by kind
  103027. */
  103028. getVertexBuffers(): Nullable<{
  103029. [key: string]: VertexBuffer;
  103030. }>;
  103031. /**
  103032. * Gets a boolean indicating if specific vertex buffer is present
  103033. * @param kind defines the data kind (Position, normal, etc...)
  103034. * @returns true if data is present
  103035. */
  103036. isVerticesDataPresent(kind: string): boolean;
  103037. /**
  103038. * Gets a list of all attached data kinds (Position, normal, etc...)
  103039. * @returns a list of string containing all kinds
  103040. */
  103041. getVerticesDataKinds(): string[];
  103042. /**
  103043. * Update index buffer
  103044. * @param indices defines the indices to store in the index buffer
  103045. * @param offset defines the offset in the target buffer where to store the data
  103046. * @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)
  103047. */
  103048. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  103049. /**
  103050. * Creates a new index buffer
  103051. * @param indices defines the indices to store in the index buffer
  103052. * @param totalVertices defines the total number of vertices (could be null)
  103053. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  103054. */
  103055. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  103056. /**
  103057. * Return the total number of indices
  103058. * @returns the total number of indices
  103059. */
  103060. getTotalIndices(): number;
  103061. /**
  103062. * Gets the index buffer array
  103063. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103064. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103065. * @returns the index buffer array
  103066. */
  103067. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  103068. /**
  103069. * Gets the index buffer
  103070. * @return the index buffer
  103071. */
  103072. getIndexBuffer(): Nullable<DataBuffer>;
  103073. /** @hidden */
  103074. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  103075. /**
  103076. * Release the associated resources for a specific mesh
  103077. * @param mesh defines the source mesh
  103078. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  103079. */
  103080. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  103081. /**
  103082. * Apply current geometry to a given mesh
  103083. * @param mesh defines the mesh to apply geometry to
  103084. */
  103085. applyToMesh(mesh: Mesh): void;
  103086. private _updateExtend;
  103087. private _applyToMesh;
  103088. private notifyUpdate;
  103089. /**
  103090. * Load the geometry if it was flagged as delay loaded
  103091. * @param scene defines the hosting scene
  103092. * @param onLoaded defines a callback called when the geometry is loaded
  103093. */
  103094. load(scene: Scene, onLoaded?: () => void): void;
  103095. private _queueLoad;
  103096. /**
  103097. * Invert the geometry to move from a right handed system to a left handed one.
  103098. */
  103099. toLeftHanded(): void;
  103100. /** @hidden */
  103101. _resetPointsArrayCache(): void;
  103102. /** @hidden */
  103103. _generatePointsArray(): boolean;
  103104. /**
  103105. * Gets a value indicating if the geometry is disposed
  103106. * @returns true if the geometry was disposed
  103107. */
  103108. isDisposed(): boolean;
  103109. private _disposeVertexArrayObjects;
  103110. /**
  103111. * Free all associated resources
  103112. */
  103113. dispose(): void;
  103114. /**
  103115. * Clone the current geometry into a new geometry
  103116. * @param id defines the unique ID of the new geometry
  103117. * @returns a new geometry object
  103118. */
  103119. copy(id: string): Geometry;
  103120. /**
  103121. * Serialize the current geometry info (and not the vertices data) into a JSON object
  103122. * @return a JSON representation of the current geometry data (without the vertices data)
  103123. */
  103124. serialize(): any;
  103125. private toNumberArray;
  103126. /**
  103127. * Serialize all vertices data into a JSON oject
  103128. * @returns a JSON representation of the current geometry data
  103129. */
  103130. serializeVerticeData(): any;
  103131. /**
  103132. * Extracts a clone of a mesh geometry
  103133. * @param mesh defines the source mesh
  103134. * @param id defines the unique ID of the new geometry object
  103135. * @returns the new geometry object
  103136. */
  103137. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  103138. /**
  103139. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  103140. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103141. * Be aware Math.random() could cause collisions, but:
  103142. * "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"
  103143. * @returns a string containing a new GUID
  103144. */
  103145. static RandomId(): string;
  103146. /** @hidden */
  103147. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  103148. private static _CleanMatricesWeights;
  103149. /**
  103150. * Create a new geometry from persisted data (Using .babylon file format)
  103151. * @param parsedVertexData defines the persisted data
  103152. * @param scene defines the hosting scene
  103153. * @param rootUrl defines the root url to use to load assets (like delayed data)
  103154. * @returns the new geometry object
  103155. */
  103156. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  103157. }
  103158. }
  103159. declare module BABYLON {
  103160. /**
  103161. * Define an interface for all classes that will get and set the data on vertices
  103162. */
  103163. export interface IGetSetVerticesData {
  103164. /**
  103165. * Gets a boolean indicating if specific vertex data is present
  103166. * @param kind defines the vertex data kind to use
  103167. * @returns true is data kind is present
  103168. */
  103169. isVerticesDataPresent(kind: string): boolean;
  103170. /**
  103171. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  103172. * @param kind defines the data kind (Position, normal, etc...)
  103173. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103174. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103175. * @returns a float array containing vertex data
  103176. */
  103177. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  103178. /**
  103179. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  103180. * @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.
  103181. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103182. * @returns the indices array or an empty array if the mesh has no geometry
  103183. */
  103184. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  103185. /**
  103186. * Set specific vertex data
  103187. * @param kind defines the data kind (Position, normal, etc...)
  103188. * @param data defines the vertex data to use
  103189. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  103190. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  103191. */
  103192. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  103193. /**
  103194. * Update a specific associated vertex buffer
  103195. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  103196. * - VertexBuffer.PositionKind
  103197. * - VertexBuffer.UVKind
  103198. * - VertexBuffer.UV2Kind
  103199. * - VertexBuffer.UV3Kind
  103200. * - VertexBuffer.UV4Kind
  103201. * - VertexBuffer.UV5Kind
  103202. * - VertexBuffer.UV6Kind
  103203. * - VertexBuffer.ColorKind
  103204. * - VertexBuffer.MatricesIndicesKind
  103205. * - VertexBuffer.MatricesIndicesExtraKind
  103206. * - VertexBuffer.MatricesWeightsKind
  103207. * - VertexBuffer.MatricesWeightsExtraKind
  103208. * @param data defines the data source
  103209. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  103210. * @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)
  103211. */
  103212. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  103213. /**
  103214. * Creates a new index buffer
  103215. * @param indices defines the indices to store in the index buffer
  103216. * @param totalVertices defines the total number of vertices (could be null)
  103217. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  103218. */
  103219. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  103220. }
  103221. /**
  103222. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  103223. */
  103224. export class VertexData {
  103225. /**
  103226. * Mesh side orientation : usually the external or front surface
  103227. */
  103228. static readonly FRONTSIDE: number;
  103229. /**
  103230. * Mesh side orientation : usually the internal or back surface
  103231. */
  103232. static readonly BACKSIDE: number;
  103233. /**
  103234. * Mesh side orientation : both internal and external or front and back surfaces
  103235. */
  103236. static readonly DOUBLESIDE: number;
  103237. /**
  103238. * Mesh side orientation : by default, `FRONTSIDE`
  103239. */
  103240. static readonly DEFAULTSIDE: number;
  103241. /**
  103242. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  103243. */
  103244. positions: Nullable<FloatArray>;
  103245. /**
  103246. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  103247. */
  103248. normals: Nullable<FloatArray>;
  103249. /**
  103250. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  103251. */
  103252. tangents: Nullable<FloatArray>;
  103253. /**
  103254. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103255. */
  103256. uvs: Nullable<FloatArray>;
  103257. /**
  103258. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103259. */
  103260. uvs2: Nullable<FloatArray>;
  103261. /**
  103262. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103263. */
  103264. uvs3: Nullable<FloatArray>;
  103265. /**
  103266. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103267. */
  103268. uvs4: Nullable<FloatArray>;
  103269. /**
  103270. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103271. */
  103272. uvs5: Nullable<FloatArray>;
  103273. /**
  103274. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103275. */
  103276. uvs6: Nullable<FloatArray>;
  103277. /**
  103278. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  103279. */
  103280. colors: Nullable<FloatArray>;
  103281. /**
  103282. * 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).
  103283. */
  103284. matricesIndices: Nullable<FloatArray>;
  103285. /**
  103286. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  103287. */
  103288. matricesWeights: Nullable<FloatArray>;
  103289. /**
  103290. * An array extending the number of possible indices
  103291. */
  103292. matricesIndicesExtra: Nullable<FloatArray>;
  103293. /**
  103294. * An array extending the number of possible weights when the number of indices is extended
  103295. */
  103296. matricesWeightsExtra: Nullable<FloatArray>;
  103297. /**
  103298. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  103299. */
  103300. indices: Nullable<IndicesArray>;
  103301. /**
  103302. * Uses the passed data array to set the set the values for the specified kind of data
  103303. * @param data a linear array of floating numbers
  103304. * @param kind the type of data that is being set, eg positions, colors etc
  103305. */
  103306. set(data: FloatArray, kind: string): void;
  103307. /**
  103308. * Associates the vertexData to the passed Mesh.
  103309. * Sets it as updatable or not (default `false`)
  103310. * @param mesh the mesh the vertexData is applied to
  103311. * @param updatable when used and having the value true allows new data to update the vertexData
  103312. * @returns the VertexData
  103313. */
  103314. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  103315. /**
  103316. * Associates the vertexData to the passed Geometry.
  103317. * Sets it as updatable or not (default `false`)
  103318. * @param geometry the geometry the vertexData is applied to
  103319. * @param updatable when used and having the value true allows new data to update the vertexData
  103320. * @returns VertexData
  103321. */
  103322. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  103323. /**
  103324. * Updates the associated mesh
  103325. * @param mesh the mesh to be updated
  103326. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  103327. * @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
  103328. * @returns VertexData
  103329. */
  103330. updateMesh(mesh: Mesh): VertexData;
  103331. /**
  103332. * Updates the associated geometry
  103333. * @param geometry the geometry to be updated
  103334. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  103335. * @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
  103336. * @returns VertexData.
  103337. */
  103338. updateGeometry(geometry: Geometry): VertexData;
  103339. private _applyTo;
  103340. private _update;
  103341. /**
  103342. * Transforms each position and each normal of the vertexData according to the passed Matrix
  103343. * @param matrix the transforming matrix
  103344. * @returns the VertexData
  103345. */
  103346. transform(matrix: Matrix): VertexData;
  103347. /**
  103348. * Merges the passed VertexData into the current one
  103349. * @param other the VertexData to be merged into the current one
  103350. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  103351. * @returns the modified VertexData
  103352. */
  103353. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  103354. private _mergeElement;
  103355. private _validate;
  103356. /**
  103357. * Serializes the VertexData
  103358. * @returns a serialized object
  103359. */
  103360. serialize(): any;
  103361. /**
  103362. * Extracts the vertexData from a mesh
  103363. * @param mesh the mesh from which to extract the VertexData
  103364. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  103365. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  103366. * @returns the object VertexData associated to the passed mesh
  103367. */
  103368. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  103369. /**
  103370. * Extracts the vertexData from the geometry
  103371. * @param geometry the geometry from which to extract the VertexData
  103372. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  103373. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  103374. * @returns the object VertexData associated to the passed mesh
  103375. */
  103376. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  103377. private static _ExtractFrom;
  103378. /**
  103379. * Creates the VertexData for a Ribbon
  103380. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  103381. * * pathArray array of paths, each of which an array of successive Vector3
  103382. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  103383. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  103384. * * 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
  103385. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103386. * * 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)
  103387. * * 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)
  103388. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  103389. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  103390. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  103391. * @returns the VertexData of the ribbon
  103392. */
  103393. static CreateRibbon(options: {
  103394. pathArray: Vector3[][];
  103395. closeArray?: boolean;
  103396. closePath?: boolean;
  103397. offset?: number;
  103398. sideOrientation?: number;
  103399. frontUVs?: Vector4;
  103400. backUVs?: Vector4;
  103401. invertUV?: boolean;
  103402. uvs?: Vector2[];
  103403. colors?: Color4[];
  103404. }): VertexData;
  103405. /**
  103406. * Creates the VertexData for a box
  103407. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103408. * * size sets the width, height and depth of the box to the value of size, optional default 1
  103409. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  103410. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  103411. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  103412. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103413. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103414. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103415. * * 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)
  103416. * * 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)
  103417. * @returns the VertexData of the box
  103418. */
  103419. static CreateBox(options: {
  103420. size?: number;
  103421. width?: number;
  103422. height?: number;
  103423. depth?: number;
  103424. faceUV?: Vector4[];
  103425. faceColors?: Color4[];
  103426. sideOrientation?: number;
  103427. frontUVs?: Vector4;
  103428. backUVs?: Vector4;
  103429. }): VertexData;
  103430. /**
  103431. * Creates the VertexData for a tiled box
  103432. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103433. * * faceTiles sets the pattern, tile size and number of tiles for a face
  103434. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103435. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103436. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103437. * @returns the VertexData of the box
  103438. */
  103439. static CreateTiledBox(options: {
  103440. pattern?: number;
  103441. width?: number;
  103442. height?: number;
  103443. depth?: number;
  103444. tileSize?: number;
  103445. tileWidth?: number;
  103446. tileHeight?: number;
  103447. alignHorizontal?: number;
  103448. alignVertical?: number;
  103449. faceUV?: Vector4[];
  103450. faceColors?: Color4[];
  103451. sideOrientation?: number;
  103452. }): VertexData;
  103453. /**
  103454. * Creates the VertexData for a tiled plane
  103455. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103456. * * pattern a limited pattern arrangement depending on the number
  103457. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  103458. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  103459. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  103460. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103461. * * 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)
  103462. * * 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)
  103463. * @returns the VertexData of the tiled plane
  103464. */
  103465. static CreateTiledPlane(options: {
  103466. pattern?: number;
  103467. tileSize?: number;
  103468. tileWidth?: number;
  103469. tileHeight?: number;
  103470. size?: number;
  103471. width?: number;
  103472. height?: number;
  103473. alignHorizontal?: number;
  103474. alignVertical?: number;
  103475. sideOrientation?: number;
  103476. frontUVs?: Vector4;
  103477. backUVs?: Vector4;
  103478. }): VertexData;
  103479. /**
  103480. * Creates the VertexData for an ellipsoid, defaults to a sphere
  103481. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103482. * * segments sets the number of horizontal strips optional, default 32
  103483. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  103484. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  103485. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  103486. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  103487. * * 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
  103488. * * 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
  103489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103490. * * 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)
  103491. * * 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)
  103492. * @returns the VertexData of the ellipsoid
  103493. */
  103494. static CreateSphere(options: {
  103495. segments?: number;
  103496. diameter?: number;
  103497. diameterX?: number;
  103498. diameterY?: number;
  103499. diameterZ?: number;
  103500. arc?: number;
  103501. slice?: number;
  103502. sideOrientation?: number;
  103503. frontUVs?: Vector4;
  103504. backUVs?: Vector4;
  103505. }): VertexData;
  103506. /**
  103507. * Creates the VertexData for a cylinder, cone or prism
  103508. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103509. * * height sets the height (y direction) of the cylinder, optional, default 2
  103510. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  103511. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  103512. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  103513. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103514. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  103515. * * 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
  103516. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103517. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103518. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  103519. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  103520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103521. * * 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)
  103522. * * 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)
  103523. * @returns the VertexData of the cylinder, cone or prism
  103524. */
  103525. static CreateCylinder(options: {
  103526. height?: number;
  103527. diameterTop?: number;
  103528. diameterBottom?: number;
  103529. diameter?: number;
  103530. tessellation?: number;
  103531. subdivisions?: number;
  103532. arc?: number;
  103533. faceColors?: Color4[];
  103534. faceUV?: Vector4[];
  103535. hasRings?: boolean;
  103536. enclose?: boolean;
  103537. sideOrientation?: number;
  103538. frontUVs?: Vector4;
  103539. backUVs?: Vector4;
  103540. }): VertexData;
  103541. /**
  103542. * Creates the VertexData for a torus
  103543. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103544. * * diameter the diameter of the torus, optional default 1
  103545. * * thickness the diameter of the tube forming the torus, optional default 0.5
  103546. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103547. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103548. * * 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)
  103549. * * 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)
  103550. * @returns the VertexData of the torus
  103551. */
  103552. static CreateTorus(options: {
  103553. diameter?: number;
  103554. thickness?: number;
  103555. tessellation?: number;
  103556. sideOrientation?: number;
  103557. frontUVs?: Vector4;
  103558. backUVs?: Vector4;
  103559. }): VertexData;
  103560. /**
  103561. * Creates the VertexData of the LineSystem
  103562. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  103563. * - lines an array of lines, each line being an array of successive Vector3
  103564. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  103565. * @returns the VertexData of the LineSystem
  103566. */
  103567. static CreateLineSystem(options: {
  103568. lines: Vector3[][];
  103569. colors?: Nullable<Color4[][]>;
  103570. }): VertexData;
  103571. /**
  103572. * Create the VertexData for a DashedLines
  103573. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  103574. * - points an array successive Vector3
  103575. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  103576. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  103577. * - dashNb the intended total number of dashes, optional, default 200
  103578. * @returns the VertexData for the DashedLines
  103579. */
  103580. static CreateDashedLines(options: {
  103581. points: Vector3[];
  103582. dashSize?: number;
  103583. gapSize?: number;
  103584. dashNb?: number;
  103585. }): VertexData;
  103586. /**
  103587. * Creates the VertexData for a Ground
  103588. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103589. * - width the width (x direction) of the ground, optional, default 1
  103590. * - height the height (z direction) of the ground, optional, default 1
  103591. * - subdivisions the number of subdivisions per side, optional, default 1
  103592. * @returns the VertexData of the Ground
  103593. */
  103594. static CreateGround(options: {
  103595. width?: number;
  103596. height?: number;
  103597. subdivisions?: number;
  103598. subdivisionsX?: number;
  103599. subdivisionsY?: number;
  103600. }): VertexData;
  103601. /**
  103602. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  103603. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103604. * * xmin the ground minimum X coordinate, optional, default -1
  103605. * * zmin the ground minimum Z coordinate, optional, default -1
  103606. * * xmax the ground maximum X coordinate, optional, default 1
  103607. * * zmax the ground maximum Z coordinate, optional, default 1
  103608. * * 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}
  103609. * * 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}
  103610. * @returns the VertexData of the TiledGround
  103611. */
  103612. static CreateTiledGround(options: {
  103613. xmin: number;
  103614. zmin: number;
  103615. xmax: number;
  103616. zmax: number;
  103617. subdivisions?: {
  103618. w: number;
  103619. h: number;
  103620. };
  103621. precision?: {
  103622. w: number;
  103623. h: number;
  103624. };
  103625. }): VertexData;
  103626. /**
  103627. * Creates the VertexData of the Ground designed from a heightmap
  103628. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  103629. * * width the width (x direction) of the ground
  103630. * * height the height (z direction) of the ground
  103631. * * subdivisions the number of subdivisions per side
  103632. * * minHeight the minimum altitude on the ground, optional, default 0
  103633. * * maxHeight the maximum altitude on the ground, optional default 1
  103634. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  103635. * * buffer the array holding the image color data
  103636. * * bufferWidth the width of image
  103637. * * bufferHeight the height of image
  103638. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  103639. * @returns the VertexData of the Ground designed from a heightmap
  103640. */
  103641. static CreateGroundFromHeightMap(options: {
  103642. width: number;
  103643. height: number;
  103644. subdivisions: number;
  103645. minHeight: number;
  103646. maxHeight: number;
  103647. colorFilter: Color3;
  103648. buffer: Uint8Array;
  103649. bufferWidth: number;
  103650. bufferHeight: number;
  103651. alphaFilter: number;
  103652. }): VertexData;
  103653. /**
  103654. * Creates the VertexData for a Plane
  103655. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  103656. * * size sets the width and height of the plane to the value of size, optional default 1
  103657. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  103658. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  103659. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103660. * * 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)
  103661. * * 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)
  103662. * @returns the VertexData of the box
  103663. */
  103664. static CreatePlane(options: {
  103665. size?: number;
  103666. width?: number;
  103667. height?: number;
  103668. sideOrientation?: number;
  103669. frontUVs?: Vector4;
  103670. backUVs?: Vector4;
  103671. }): VertexData;
  103672. /**
  103673. * Creates the VertexData of the Disc or regular Polygon
  103674. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  103675. * * radius the radius of the disc, optional default 0.5
  103676. * * tessellation the number of polygon sides, optional, default 64
  103677. * * 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
  103678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103679. * * 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)
  103680. * * 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)
  103681. * @returns the VertexData of the box
  103682. */
  103683. static CreateDisc(options: {
  103684. radius?: number;
  103685. tessellation?: number;
  103686. arc?: number;
  103687. sideOrientation?: number;
  103688. frontUVs?: Vector4;
  103689. backUVs?: Vector4;
  103690. }): VertexData;
  103691. /**
  103692. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  103693. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  103694. * @param polygon a mesh built from polygonTriangulation.build()
  103695. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103696. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103697. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103698. * @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)
  103699. * @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)
  103700. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  103701. * @returns the VertexData of the Polygon
  103702. */
  103703. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  103704. /**
  103705. * Creates the VertexData of the IcoSphere
  103706. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  103707. * * radius the radius of the IcoSphere, optional default 1
  103708. * * radiusX allows stretching in the x direction, optional, default radius
  103709. * * radiusY allows stretching in the y direction, optional, default radius
  103710. * * radiusZ allows stretching in the z direction, optional, default radius
  103711. * * flat when true creates a flat shaded mesh, optional, default true
  103712. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103713. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103714. * * 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)
  103715. * * 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)
  103716. * @returns the VertexData of the IcoSphere
  103717. */
  103718. static CreateIcoSphere(options: {
  103719. radius?: number;
  103720. radiusX?: number;
  103721. radiusY?: number;
  103722. radiusZ?: number;
  103723. flat?: boolean;
  103724. subdivisions?: number;
  103725. sideOrientation?: number;
  103726. frontUVs?: Vector4;
  103727. backUVs?: Vector4;
  103728. }): VertexData;
  103729. /**
  103730. * Creates the VertexData for a Polyhedron
  103731. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  103732. * * type provided types are:
  103733. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  103734. * * 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)
  103735. * * size the size of the IcoSphere, optional default 1
  103736. * * sizeX allows stretching in the x direction, optional, default size
  103737. * * sizeY allows stretching in the y direction, optional, default size
  103738. * * sizeZ allows stretching in the z direction, optional, default size
  103739. * * 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
  103740. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103741. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103742. * * flat when true creates a flat shaded mesh, optional, default true
  103743. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103744. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103745. * * 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)
  103746. * * 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)
  103747. * @returns the VertexData of the Polyhedron
  103748. */
  103749. static CreatePolyhedron(options: {
  103750. type?: number;
  103751. size?: number;
  103752. sizeX?: number;
  103753. sizeY?: number;
  103754. sizeZ?: number;
  103755. custom?: any;
  103756. faceUV?: Vector4[];
  103757. faceColors?: Color4[];
  103758. flat?: boolean;
  103759. sideOrientation?: number;
  103760. frontUVs?: Vector4;
  103761. backUVs?: Vector4;
  103762. }): VertexData;
  103763. /**
  103764. * Creates the VertexData for a TorusKnot
  103765. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  103766. * * radius the radius of the torus knot, optional, default 2
  103767. * * tube the thickness of the tube, optional, default 0.5
  103768. * * radialSegments the number of sides on each tube segments, optional, default 32
  103769. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  103770. * * p the number of windings around the z axis, optional, default 2
  103771. * * q the number of windings around the x axis, optional, default 3
  103772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103773. * * 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)
  103774. * * 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)
  103775. * @returns the VertexData of the Torus Knot
  103776. */
  103777. static CreateTorusKnot(options: {
  103778. radius?: number;
  103779. tube?: number;
  103780. radialSegments?: number;
  103781. tubularSegments?: number;
  103782. p?: number;
  103783. q?: number;
  103784. sideOrientation?: number;
  103785. frontUVs?: Vector4;
  103786. backUVs?: Vector4;
  103787. }): VertexData;
  103788. /**
  103789. * Compute normals for given positions and indices
  103790. * @param positions an array of vertex positions, [...., x, y, z, ......]
  103791. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  103792. * @param normals an array of vertex normals, [...., x, y, z, ......]
  103793. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  103794. * * facetNormals : optional array of facet normals (vector3)
  103795. * * facetPositions : optional array of facet positions (vector3)
  103796. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  103797. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  103798. * * bInfo : optional bounding info, required for facetPartitioning computation
  103799. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  103800. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  103801. * * useRightHandedSystem: optional boolean to for right handed system computation
  103802. * * depthSort : optional boolean to enable the facet depth sort computation
  103803. * * distanceTo : optional Vector3 to compute the facet depth from this location
  103804. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  103805. */
  103806. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  103807. facetNormals?: any;
  103808. facetPositions?: any;
  103809. facetPartitioning?: any;
  103810. ratio?: number;
  103811. bInfo?: any;
  103812. bbSize?: Vector3;
  103813. subDiv?: any;
  103814. useRightHandedSystem?: boolean;
  103815. depthSort?: boolean;
  103816. distanceTo?: Vector3;
  103817. depthSortedFacets?: any;
  103818. }): void;
  103819. /** @hidden */
  103820. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  103821. /**
  103822. * Applies VertexData created from the imported parameters to the geometry
  103823. * @param parsedVertexData the parsed data from an imported file
  103824. * @param geometry the geometry to apply the VertexData to
  103825. */
  103826. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  103827. }
  103828. }
  103829. declare module BABYLON {
  103830. /**
  103831. * Defines a target to use with MorphTargetManager
  103832. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103833. */
  103834. export class MorphTarget implements IAnimatable {
  103835. /** defines the name of the target */
  103836. name: string;
  103837. /**
  103838. * Gets or sets the list of animations
  103839. */
  103840. animations: Animation[];
  103841. private _scene;
  103842. private _positions;
  103843. private _normals;
  103844. private _tangents;
  103845. private _uvs;
  103846. private _influence;
  103847. private _uniqueId;
  103848. /**
  103849. * Observable raised when the influence changes
  103850. */
  103851. onInfluenceChanged: Observable<boolean>;
  103852. /** @hidden */
  103853. _onDataLayoutChanged: Observable<void>;
  103854. /**
  103855. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  103856. */
  103857. get influence(): number;
  103858. set influence(influence: number);
  103859. /**
  103860. * Gets or sets the id of the morph Target
  103861. */
  103862. id: string;
  103863. private _animationPropertiesOverride;
  103864. /**
  103865. * Gets or sets the animation properties override
  103866. */
  103867. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103868. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103869. /**
  103870. * Creates a new MorphTarget
  103871. * @param name defines the name of the target
  103872. * @param influence defines the influence to use
  103873. * @param scene defines the scene the morphtarget belongs to
  103874. */
  103875. constructor(
  103876. /** defines the name of the target */
  103877. name: string, influence?: number, scene?: Nullable<Scene>);
  103878. /**
  103879. * Gets the unique ID of this manager
  103880. */
  103881. get uniqueId(): number;
  103882. /**
  103883. * Gets a boolean defining if the target contains position data
  103884. */
  103885. get hasPositions(): boolean;
  103886. /**
  103887. * Gets a boolean defining if the target contains normal data
  103888. */
  103889. get hasNormals(): boolean;
  103890. /**
  103891. * Gets a boolean defining if the target contains tangent data
  103892. */
  103893. get hasTangents(): boolean;
  103894. /**
  103895. * Gets a boolean defining if the target contains texture coordinates data
  103896. */
  103897. get hasUVs(): boolean;
  103898. /**
  103899. * Affects position data to this target
  103900. * @param data defines the position data to use
  103901. */
  103902. setPositions(data: Nullable<FloatArray>): void;
  103903. /**
  103904. * Gets the position data stored in this target
  103905. * @returns a FloatArray containing the position data (or null if not present)
  103906. */
  103907. getPositions(): Nullable<FloatArray>;
  103908. /**
  103909. * Affects normal data to this target
  103910. * @param data defines the normal data to use
  103911. */
  103912. setNormals(data: Nullable<FloatArray>): void;
  103913. /**
  103914. * Gets the normal data stored in this target
  103915. * @returns a FloatArray containing the normal data (or null if not present)
  103916. */
  103917. getNormals(): Nullable<FloatArray>;
  103918. /**
  103919. * Affects tangent data to this target
  103920. * @param data defines the tangent data to use
  103921. */
  103922. setTangents(data: Nullable<FloatArray>): void;
  103923. /**
  103924. * Gets the tangent data stored in this target
  103925. * @returns a FloatArray containing the tangent data (or null if not present)
  103926. */
  103927. getTangents(): Nullable<FloatArray>;
  103928. /**
  103929. * Affects texture coordinates data to this target
  103930. * @param data defines the texture coordinates data to use
  103931. */
  103932. setUVs(data: Nullable<FloatArray>): void;
  103933. /**
  103934. * Gets the texture coordinates data stored in this target
  103935. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  103936. */
  103937. getUVs(): Nullable<FloatArray>;
  103938. /**
  103939. * Clone the current target
  103940. * @returns a new MorphTarget
  103941. */
  103942. clone(): MorphTarget;
  103943. /**
  103944. * Serializes the current target into a Serialization object
  103945. * @returns the serialized object
  103946. */
  103947. serialize(): any;
  103948. /**
  103949. * Returns the string "MorphTarget"
  103950. * @returns "MorphTarget"
  103951. */
  103952. getClassName(): string;
  103953. /**
  103954. * Creates a new target from serialized data
  103955. * @param serializationObject defines the serialized data to use
  103956. * @returns a new MorphTarget
  103957. */
  103958. static Parse(serializationObject: any): MorphTarget;
  103959. /**
  103960. * Creates a MorphTarget from mesh data
  103961. * @param mesh defines the source mesh
  103962. * @param name defines the name to use for the new target
  103963. * @param influence defines the influence to attach to the target
  103964. * @returns a new MorphTarget
  103965. */
  103966. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  103967. }
  103968. }
  103969. declare module BABYLON {
  103970. /**
  103971. * This class is used to deform meshes using morphing between different targets
  103972. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103973. */
  103974. export class MorphTargetManager {
  103975. private _targets;
  103976. private _targetInfluenceChangedObservers;
  103977. private _targetDataLayoutChangedObservers;
  103978. private _activeTargets;
  103979. private _scene;
  103980. private _influences;
  103981. private _supportsNormals;
  103982. private _supportsTangents;
  103983. private _supportsUVs;
  103984. private _vertexCount;
  103985. private _uniqueId;
  103986. private _tempInfluences;
  103987. /**
  103988. * Gets or sets a boolean indicating if normals must be morphed
  103989. */
  103990. enableNormalMorphing: boolean;
  103991. /**
  103992. * Gets or sets a boolean indicating if tangents must be morphed
  103993. */
  103994. enableTangentMorphing: boolean;
  103995. /**
  103996. * Gets or sets a boolean indicating if UV must be morphed
  103997. */
  103998. enableUVMorphing: boolean;
  103999. /**
  104000. * Creates a new MorphTargetManager
  104001. * @param scene defines the current scene
  104002. */
  104003. constructor(scene?: Nullable<Scene>);
  104004. /**
  104005. * Gets the unique ID of this manager
  104006. */
  104007. get uniqueId(): number;
  104008. /**
  104009. * Gets the number of vertices handled by this manager
  104010. */
  104011. get vertexCount(): number;
  104012. /**
  104013. * Gets a boolean indicating if this manager supports morphing of normals
  104014. */
  104015. get supportsNormals(): boolean;
  104016. /**
  104017. * Gets a boolean indicating if this manager supports morphing of tangents
  104018. */
  104019. get supportsTangents(): boolean;
  104020. /**
  104021. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  104022. */
  104023. get supportsUVs(): boolean;
  104024. /**
  104025. * Gets the number of targets stored in this manager
  104026. */
  104027. get numTargets(): number;
  104028. /**
  104029. * Gets the number of influencers (ie. the number of targets with influences > 0)
  104030. */
  104031. get numInfluencers(): number;
  104032. /**
  104033. * Gets the list of influences (one per target)
  104034. */
  104035. get influences(): Float32Array;
  104036. /**
  104037. * Gets the active target at specified index. An active target is a target with an influence > 0
  104038. * @param index defines the index to check
  104039. * @returns the requested target
  104040. */
  104041. getActiveTarget(index: number): MorphTarget;
  104042. /**
  104043. * Gets the target at specified index
  104044. * @param index defines the index to check
  104045. * @returns the requested target
  104046. */
  104047. getTarget(index: number): MorphTarget;
  104048. /**
  104049. * Add a new target to this manager
  104050. * @param target defines the target to add
  104051. */
  104052. addTarget(target: MorphTarget): void;
  104053. /**
  104054. * Removes a target from the manager
  104055. * @param target defines the target to remove
  104056. */
  104057. removeTarget(target: MorphTarget): void;
  104058. /**
  104059. * Clone the current manager
  104060. * @returns a new MorphTargetManager
  104061. */
  104062. clone(): MorphTargetManager;
  104063. /**
  104064. * Serializes the current manager into a Serialization object
  104065. * @returns the serialized object
  104066. */
  104067. serialize(): any;
  104068. private _syncActiveTargets;
  104069. /**
  104070. * Syncrhonize the targets with all the meshes using this morph target manager
  104071. */
  104072. synchronize(): void;
  104073. /**
  104074. * Creates a new MorphTargetManager from serialized data
  104075. * @param serializationObject defines the serialized data
  104076. * @param scene defines the hosting scene
  104077. * @returns the new MorphTargetManager
  104078. */
  104079. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  104080. }
  104081. }
  104082. declare module BABYLON {
  104083. /**
  104084. * Class used to represent a specific level of detail of a mesh
  104085. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104086. */
  104087. export class MeshLODLevel {
  104088. /** Defines the distance where this level should start being displayed */
  104089. distance: number;
  104090. /** Defines the mesh to use to render this level */
  104091. mesh: Nullable<Mesh>;
  104092. /**
  104093. * Creates a new LOD level
  104094. * @param distance defines the distance where this level should star being displayed
  104095. * @param mesh defines the mesh to use to render this level
  104096. */
  104097. constructor(
  104098. /** Defines the distance where this level should start being displayed */
  104099. distance: number,
  104100. /** Defines the mesh to use to render this level */
  104101. mesh: Nullable<Mesh>);
  104102. }
  104103. }
  104104. declare module BABYLON {
  104105. /**
  104106. * Helper class used to generate a canvas to manipulate images
  104107. */
  104108. export class CanvasGenerator {
  104109. /**
  104110. * Create a new canvas (or offscreen canvas depending on the context)
  104111. * @param width defines the expected width
  104112. * @param height defines the expected height
  104113. * @return a new canvas or offscreen canvas
  104114. */
  104115. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  104116. }
  104117. }
  104118. declare module BABYLON {
  104119. /**
  104120. * Mesh representing the gorund
  104121. */
  104122. export class GroundMesh extends Mesh {
  104123. /** If octree should be generated */
  104124. generateOctree: boolean;
  104125. private _heightQuads;
  104126. /** @hidden */
  104127. _subdivisionsX: number;
  104128. /** @hidden */
  104129. _subdivisionsY: number;
  104130. /** @hidden */
  104131. _width: number;
  104132. /** @hidden */
  104133. _height: number;
  104134. /** @hidden */
  104135. _minX: number;
  104136. /** @hidden */
  104137. _maxX: number;
  104138. /** @hidden */
  104139. _minZ: number;
  104140. /** @hidden */
  104141. _maxZ: number;
  104142. constructor(name: string, scene: Scene);
  104143. /**
  104144. * "GroundMesh"
  104145. * @returns "GroundMesh"
  104146. */
  104147. getClassName(): string;
  104148. /**
  104149. * The minimum of x and y subdivisions
  104150. */
  104151. get subdivisions(): number;
  104152. /**
  104153. * X subdivisions
  104154. */
  104155. get subdivisionsX(): number;
  104156. /**
  104157. * Y subdivisions
  104158. */
  104159. get subdivisionsY(): number;
  104160. /**
  104161. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  104162. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  104163. * @param chunksCount the number of subdivisions for x and y
  104164. * @param octreeBlocksSize (Default: 32)
  104165. */
  104166. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  104167. /**
  104168. * Returns a height (y) value in the Worl system :
  104169. * the ground altitude at the coordinates (x, z) expressed in the World system.
  104170. * @param x x coordinate
  104171. * @param z z coordinate
  104172. * @returns the ground y position if (x, z) are outside the ground surface.
  104173. */
  104174. getHeightAtCoordinates(x: number, z: number): number;
  104175. /**
  104176. * Returns a normalized vector (Vector3) orthogonal to the ground
  104177. * at the ground coordinates (x, z) expressed in the World system.
  104178. * @param x x coordinate
  104179. * @param z z coordinate
  104180. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  104181. */
  104182. getNormalAtCoordinates(x: number, z: number): Vector3;
  104183. /**
  104184. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  104185. * at the ground coordinates (x, z) expressed in the World system.
  104186. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  104187. * @param x x coordinate
  104188. * @param z z coordinate
  104189. * @param ref vector to store the result
  104190. * @returns the GroundMesh.
  104191. */
  104192. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  104193. /**
  104194. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  104195. * if the ground has been updated.
  104196. * This can be used in the render loop.
  104197. * @returns the GroundMesh.
  104198. */
  104199. updateCoordinateHeights(): GroundMesh;
  104200. private _getFacetAt;
  104201. private _initHeightQuads;
  104202. private _computeHeightQuads;
  104203. /**
  104204. * Serializes this ground mesh
  104205. * @param serializationObject object to write serialization to
  104206. */
  104207. serialize(serializationObject: any): void;
  104208. /**
  104209. * Parses a serialized ground mesh
  104210. * @param parsedMesh the serialized mesh
  104211. * @param scene the scene to create the ground mesh in
  104212. * @returns the created ground mesh
  104213. */
  104214. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  104215. }
  104216. }
  104217. declare module BABYLON {
  104218. /**
  104219. * Interface for Physics-Joint data
  104220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104221. */
  104222. export interface PhysicsJointData {
  104223. /**
  104224. * The main pivot of the joint
  104225. */
  104226. mainPivot?: Vector3;
  104227. /**
  104228. * The connected pivot of the joint
  104229. */
  104230. connectedPivot?: Vector3;
  104231. /**
  104232. * The main axis of the joint
  104233. */
  104234. mainAxis?: Vector3;
  104235. /**
  104236. * The connected axis of the joint
  104237. */
  104238. connectedAxis?: Vector3;
  104239. /**
  104240. * The collision of the joint
  104241. */
  104242. collision?: boolean;
  104243. /**
  104244. * Native Oimo/Cannon/Energy data
  104245. */
  104246. nativeParams?: any;
  104247. }
  104248. /**
  104249. * This is a holder class for the physics joint created by the physics plugin
  104250. * It holds a set of functions to control the underlying joint
  104251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104252. */
  104253. export class PhysicsJoint {
  104254. /**
  104255. * The type of the physics joint
  104256. */
  104257. type: number;
  104258. /**
  104259. * The data for the physics joint
  104260. */
  104261. jointData: PhysicsJointData;
  104262. private _physicsJoint;
  104263. protected _physicsPlugin: IPhysicsEnginePlugin;
  104264. /**
  104265. * Initializes the physics joint
  104266. * @param type The type of the physics joint
  104267. * @param jointData The data for the physics joint
  104268. */
  104269. constructor(
  104270. /**
  104271. * The type of the physics joint
  104272. */
  104273. type: number,
  104274. /**
  104275. * The data for the physics joint
  104276. */
  104277. jointData: PhysicsJointData);
  104278. /**
  104279. * Gets the physics joint
  104280. */
  104281. get physicsJoint(): any;
  104282. /**
  104283. * Sets the physics joint
  104284. */
  104285. set physicsJoint(newJoint: any);
  104286. /**
  104287. * Sets the physics plugin
  104288. */
  104289. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  104290. /**
  104291. * Execute a function that is physics-plugin specific.
  104292. * @param {Function} func the function that will be executed.
  104293. * It accepts two parameters: the physics world and the physics joint
  104294. */
  104295. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  104296. /**
  104297. * Distance-Joint type
  104298. */
  104299. static DistanceJoint: number;
  104300. /**
  104301. * Hinge-Joint type
  104302. */
  104303. static HingeJoint: number;
  104304. /**
  104305. * Ball-and-Socket joint type
  104306. */
  104307. static BallAndSocketJoint: number;
  104308. /**
  104309. * Wheel-Joint type
  104310. */
  104311. static WheelJoint: number;
  104312. /**
  104313. * Slider-Joint type
  104314. */
  104315. static SliderJoint: number;
  104316. /**
  104317. * Prismatic-Joint type
  104318. */
  104319. static PrismaticJoint: number;
  104320. /**
  104321. * Universal-Joint type
  104322. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  104323. */
  104324. static UniversalJoint: number;
  104325. /**
  104326. * Hinge-Joint 2 type
  104327. */
  104328. static Hinge2Joint: number;
  104329. /**
  104330. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  104331. */
  104332. static PointToPointJoint: number;
  104333. /**
  104334. * Spring-Joint type
  104335. */
  104336. static SpringJoint: number;
  104337. /**
  104338. * Lock-Joint type
  104339. */
  104340. static LockJoint: number;
  104341. }
  104342. /**
  104343. * A class representing a physics distance joint
  104344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104345. */
  104346. export class DistanceJoint extends PhysicsJoint {
  104347. /**
  104348. *
  104349. * @param jointData The data for the Distance-Joint
  104350. */
  104351. constructor(jointData: DistanceJointData);
  104352. /**
  104353. * Update the predefined distance.
  104354. * @param maxDistance The maximum preferred distance
  104355. * @param minDistance The minimum preferred distance
  104356. */
  104357. updateDistance(maxDistance: number, minDistance?: number): void;
  104358. }
  104359. /**
  104360. * Represents a Motor-Enabled Joint
  104361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104362. */
  104363. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  104364. /**
  104365. * Initializes the Motor-Enabled Joint
  104366. * @param type The type of the joint
  104367. * @param jointData The physica joint data for the joint
  104368. */
  104369. constructor(type: number, jointData: PhysicsJointData);
  104370. /**
  104371. * Set the motor values.
  104372. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104373. * @param force the force to apply
  104374. * @param maxForce max force for this motor.
  104375. */
  104376. setMotor(force?: number, maxForce?: number): void;
  104377. /**
  104378. * Set the motor's limits.
  104379. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104380. * @param upperLimit The upper limit of the motor
  104381. * @param lowerLimit The lower limit of the motor
  104382. */
  104383. setLimit(upperLimit: number, lowerLimit?: number): void;
  104384. }
  104385. /**
  104386. * This class represents a single physics Hinge-Joint
  104387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104388. */
  104389. export class HingeJoint extends MotorEnabledJoint {
  104390. /**
  104391. * Initializes the Hinge-Joint
  104392. * @param jointData The joint data for the Hinge-Joint
  104393. */
  104394. constructor(jointData: PhysicsJointData);
  104395. /**
  104396. * Set the motor values.
  104397. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104398. * @param {number} force the force to apply
  104399. * @param {number} maxForce max force for this motor.
  104400. */
  104401. setMotor(force?: number, maxForce?: number): void;
  104402. /**
  104403. * Set the motor's limits.
  104404. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104405. * @param upperLimit The upper limit of the motor
  104406. * @param lowerLimit The lower limit of the motor
  104407. */
  104408. setLimit(upperLimit: number, lowerLimit?: number): void;
  104409. }
  104410. /**
  104411. * This class represents a dual hinge physics joint (same as wheel joint)
  104412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104413. */
  104414. export class Hinge2Joint extends MotorEnabledJoint {
  104415. /**
  104416. * Initializes the Hinge2-Joint
  104417. * @param jointData The joint data for the Hinge2-Joint
  104418. */
  104419. constructor(jointData: PhysicsJointData);
  104420. /**
  104421. * Set the motor values.
  104422. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104423. * @param {number} targetSpeed the speed the motor is to reach
  104424. * @param {number} maxForce max force for this motor.
  104425. * @param {motorIndex} the motor's index, 0 or 1.
  104426. */
  104427. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  104428. /**
  104429. * Set the motor limits.
  104430. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104431. * @param {number} upperLimit the upper limit
  104432. * @param {number} lowerLimit lower limit
  104433. * @param {motorIndex} the motor's index, 0 or 1.
  104434. */
  104435. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104436. }
  104437. /**
  104438. * Interface for a motor enabled joint
  104439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104440. */
  104441. export interface IMotorEnabledJoint {
  104442. /**
  104443. * Physics joint
  104444. */
  104445. physicsJoint: any;
  104446. /**
  104447. * Sets the motor of the motor-enabled joint
  104448. * @param force The force of the motor
  104449. * @param maxForce The maximum force of the motor
  104450. * @param motorIndex The index of the motor
  104451. */
  104452. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  104453. /**
  104454. * Sets the limit of the motor
  104455. * @param upperLimit The upper limit of the motor
  104456. * @param lowerLimit The lower limit of the motor
  104457. * @param motorIndex The index of the motor
  104458. */
  104459. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104460. }
  104461. /**
  104462. * Joint data for a Distance-Joint
  104463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104464. */
  104465. export interface DistanceJointData extends PhysicsJointData {
  104466. /**
  104467. * Max distance the 2 joint objects can be apart
  104468. */
  104469. maxDistance: number;
  104470. }
  104471. /**
  104472. * Joint data from a spring joint
  104473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104474. */
  104475. export interface SpringJointData extends PhysicsJointData {
  104476. /**
  104477. * Length of the spring
  104478. */
  104479. length: number;
  104480. /**
  104481. * Stiffness of the spring
  104482. */
  104483. stiffness: number;
  104484. /**
  104485. * Damping of the spring
  104486. */
  104487. damping: number;
  104488. /** this callback will be called when applying the force to the impostors. */
  104489. forceApplicationCallback: () => void;
  104490. }
  104491. }
  104492. declare module BABYLON {
  104493. /**
  104494. * Holds the data for the raycast result
  104495. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104496. */
  104497. export class PhysicsRaycastResult {
  104498. private _hasHit;
  104499. private _hitDistance;
  104500. private _hitNormalWorld;
  104501. private _hitPointWorld;
  104502. private _rayFromWorld;
  104503. private _rayToWorld;
  104504. /**
  104505. * Gets if there was a hit
  104506. */
  104507. get hasHit(): boolean;
  104508. /**
  104509. * Gets the distance from the hit
  104510. */
  104511. get hitDistance(): number;
  104512. /**
  104513. * Gets the hit normal/direction in the world
  104514. */
  104515. get hitNormalWorld(): Vector3;
  104516. /**
  104517. * Gets the hit point in the world
  104518. */
  104519. get hitPointWorld(): Vector3;
  104520. /**
  104521. * Gets the ray "start point" of the ray in the world
  104522. */
  104523. get rayFromWorld(): Vector3;
  104524. /**
  104525. * Gets the ray "end point" of the ray in the world
  104526. */
  104527. get rayToWorld(): Vector3;
  104528. /**
  104529. * Sets the hit data (normal & point in world space)
  104530. * @param hitNormalWorld defines the normal in world space
  104531. * @param hitPointWorld defines the point in world space
  104532. */
  104533. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  104534. /**
  104535. * Sets the distance from the start point to the hit point
  104536. * @param distance
  104537. */
  104538. setHitDistance(distance: number): void;
  104539. /**
  104540. * Calculates the distance manually
  104541. */
  104542. calculateHitDistance(): void;
  104543. /**
  104544. * Resets all the values to default
  104545. * @param from The from point on world space
  104546. * @param to The to point on world space
  104547. */
  104548. reset(from?: Vector3, to?: Vector3): void;
  104549. }
  104550. /**
  104551. * Interface for the size containing width and height
  104552. */
  104553. interface IXYZ {
  104554. /**
  104555. * X
  104556. */
  104557. x: number;
  104558. /**
  104559. * Y
  104560. */
  104561. y: number;
  104562. /**
  104563. * Z
  104564. */
  104565. z: number;
  104566. }
  104567. }
  104568. declare module BABYLON {
  104569. /**
  104570. * Interface used to describe a physics joint
  104571. */
  104572. export interface PhysicsImpostorJoint {
  104573. /** Defines the main impostor to which the joint is linked */
  104574. mainImpostor: PhysicsImpostor;
  104575. /** Defines the impostor that is connected to the main impostor using this joint */
  104576. connectedImpostor: PhysicsImpostor;
  104577. /** Defines the joint itself */
  104578. joint: PhysicsJoint;
  104579. }
  104580. /** @hidden */
  104581. export interface IPhysicsEnginePlugin {
  104582. world: any;
  104583. name: string;
  104584. setGravity(gravity: Vector3): void;
  104585. setTimeStep(timeStep: number): void;
  104586. getTimeStep(): number;
  104587. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104588. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104589. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104590. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104591. removePhysicsBody(impostor: PhysicsImpostor): void;
  104592. generateJoint(joint: PhysicsImpostorJoint): void;
  104593. removeJoint(joint: PhysicsImpostorJoint): void;
  104594. isSupported(): boolean;
  104595. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104596. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104597. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104598. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104599. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104600. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104601. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104602. getBodyMass(impostor: PhysicsImpostor): number;
  104603. getBodyFriction(impostor: PhysicsImpostor): number;
  104604. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104605. getBodyRestitution(impostor: PhysicsImpostor): number;
  104606. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104607. getBodyPressure?(impostor: PhysicsImpostor): number;
  104608. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  104609. getBodyStiffness?(impostor: PhysicsImpostor): number;
  104610. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  104611. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  104612. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  104613. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  104614. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  104615. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104616. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104617. sleepBody(impostor: PhysicsImpostor): void;
  104618. wakeUpBody(impostor: PhysicsImpostor): void;
  104619. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104620. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104621. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  104622. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104623. getRadius(impostor: PhysicsImpostor): number;
  104624. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104625. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104626. dispose(): void;
  104627. }
  104628. /**
  104629. * Interface used to define a physics engine
  104630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104631. */
  104632. export interface IPhysicsEngine {
  104633. /**
  104634. * Gets the gravity vector used by the simulation
  104635. */
  104636. gravity: Vector3;
  104637. /**
  104638. * Sets the gravity vector used by the simulation
  104639. * @param gravity defines the gravity vector to use
  104640. */
  104641. setGravity(gravity: Vector3): void;
  104642. /**
  104643. * Set the time step of the physics engine.
  104644. * Default is 1/60.
  104645. * To slow it down, enter 1/600 for example.
  104646. * To speed it up, 1/30
  104647. * @param newTimeStep the new timestep to apply to this world.
  104648. */
  104649. setTimeStep(newTimeStep: number): void;
  104650. /**
  104651. * Get the time step of the physics engine.
  104652. * @returns the current time step
  104653. */
  104654. getTimeStep(): number;
  104655. /**
  104656. * Set the sub time step of the physics engine.
  104657. * Default is 0 meaning there is no sub steps
  104658. * To increase physics resolution precision, set a small value (like 1 ms)
  104659. * @param subTimeStep defines the new sub timestep used for physics resolution.
  104660. */
  104661. setSubTimeStep(subTimeStep: number): void;
  104662. /**
  104663. * Get the sub time step of the physics engine.
  104664. * @returns the current sub time step
  104665. */
  104666. getSubTimeStep(): number;
  104667. /**
  104668. * Release all resources
  104669. */
  104670. dispose(): void;
  104671. /**
  104672. * Gets the name of the current physics plugin
  104673. * @returns the name of the plugin
  104674. */
  104675. getPhysicsPluginName(): string;
  104676. /**
  104677. * Adding a new impostor for the impostor tracking.
  104678. * This will be done by the impostor itself.
  104679. * @param impostor the impostor to add
  104680. */
  104681. addImpostor(impostor: PhysicsImpostor): void;
  104682. /**
  104683. * Remove an impostor from the engine.
  104684. * This impostor and its mesh will not longer be updated by the physics engine.
  104685. * @param impostor the impostor to remove
  104686. */
  104687. removeImpostor(impostor: PhysicsImpostor): void;
  104688. /**
  104689. * Add a joint to the physics engine
  104690. * @param mainImpostor defines the main impostor to which the joint is added.
  104691. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104692. * @param joint defines the joint that will connect both impostors.
  104693. */
  104694. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104695. /**
  104696. * Removes a joint from the simulation
  104697. * @param mainImpostor defines the impostor used with the joint
  104698. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104699. * @param joint defines the joint to remove
  104700. */
  104701. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104702. /**
  104703. * Gets the current plugin used to run the simulation
  104704. * @returns current plugin
  104705. */
  104706. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104707. /**
  104708. * Gets the list of physic impostors
  104709. * @returns an array of PhysicsImpostor
  104710. */
  104711. getImpostors(): Array<PhysicsImpostor>;
  104712. /**
  104713. * Gets the impostor for a physics enabled object
  104714. * @param object defines the object impersonated by the impostor
  104715. * @returns the PhysicsImpostor or null if not found
  104716. */
  104717. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104718. /**
  104719. * Gets the impostor for a physics body object
  104720. * @param body defines physics body used by the impostor
  104721. * @returns the PhysicsImpostor or null if not found
  104722. */
  104723. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104724. /**
  104725. * Does a raycast in the physics world
  104726. * @param from when should the ray start?
  104727. * @param to when should the ray end?
  104728. * @returns PhysicsRaycastResult
  104729. */
  104730. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104731. /**
  104732. * Called by the scene. No need to call it.
  104733. * @param delta defines the timespam between frames
  104734. */
  104735. _step(delta: number): void;
  104736. }
  104737. }
  104738. declare module BABYLON {
  104739. /**
  104740. * The interface for the physics imposter parameters
  104741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104742. */
  104743. export interface PhysicsImpostorParameters {
  104744. /**
  104745. * The mass of the physics imposter
  104746. */
  104747. mass: number;
  104748. /**
  104749. * The friction of the physics imposter
  104750. */
  104751. friction?: number;
  104752. /**
  104753. * The coefficient of restitution of the physics imposter
  104754. */
  104755. restitution?: number;
  104756. /**
  104757. * The native options of the physics imposter
  104758. */
  104759. nativeOptions?: any;
  104760. /**
  104761. * Specifies if the parent should be ignored
  104762. */
  104763. ignoreParent?: boolean;
  104764. /**
  104765. * Specifies if bi-directional transformations should be disabled
  104766. */
  104767. disableBidirectionalTransformation?: boolean;
  104768. /**
  104769. * The pressure inside the physics imposter, soft object only
  104770. */
  104771. pressure?: number;
  104772. /**
  104773. * The stiffness the physics imposter, soft object only
  104774. */
  104775. stiffness?: number;
  104776. /**
  104777. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  104778. */
  104779. velocityIterations?: number;
  104780. /**
  104781. * The number of iterations used in maintaining consistent vertex positions, soft object only
  104782. */
  104783. positionIterations?: number;
  104784. /**
  104785. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  104786. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  104787. * Add to fix multiple points
  104788. */
  104789. fixedPoints?: number;
  104790. /**
  104791. * The collision margin around a soft object
  104792. */
  104793. margin?: number;
  104794. /**
  104795. * The collision margin around a soft object
  104796. */
  104797. damping?: number;
  104798. /**
  104799. * The path for a rope based on an extrusion
  104800. */
  104801. path?: any;
  104802. /**
  104803. * The shape of an extrusion used for a rope based on an extrusion
  104804. */
  104805. shape?: any;
  104806. }
  104807. /**
  104808. * Interface for a physics-enabled object
  104809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104810. */
  104811. export interface IPhysicsEnabledObject {
  104812. /**
  104813. * The position of the physics-enabled object
  104814. */
  104815. position: Vector3;
  104816. /**
  104817. * The rotation of the physics-enabled object
  104818. */
  104819. rotationQuaternion: Nullable<Quaternion>;
  104820. /**
  104821. * The scale of the physics-enabled object
  104822. */
  104823. scaling: Vector3;
  104824. /**
  104825. * The rotation of the physics-enabled object
  104826. */
  104827. rotation?: Vector3;
  104828. /**
  104829. * The parent of the physics-enabled object
  104830. */
  104831. parent?: any;
  104832. /**
  104833. * The bounding info of the physics-enabled object
  104834. * @returns The bounding info of the physics-enabled object
  104835. */
  104836. getBoundingInfo(): BoundingInfo;
  104837. /**
  104838. * Computes the world matrix
  104839. * @param force Specifies if the world matrix should be computed by force
  104840. * @returns A world matrix
  104841. */
  104842. computeWorldMatrix(force: boolean): Matrix;
  104843. /**
  104844. * Gets the world matrix
  104845. * @returns A world matrix
  104846. */
  104847. getWorldMatrix?(): Matrix;
  104848. /**
  104849. * Gets the child meshes
  104850. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  104851. * @returns An array of abstract meshes
  104852. */
  104853. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  104854. /**
  104855. * Gets the vertex data
  104856. * @param kind The type of vertex data
  104857. * @returns A nullable array of numbers, or a float32 array
  104858. */
  104859. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  104860. /**
  104861. * Gets the indices from the mesh
  104862. * @returns A nullable array of index arrays
  104863. */
  104864. getIndices?(): Nullable<IndicesArray>;
  104865. /**
  104866. * Gets the scene from the mesh
  104867. * @returns the indices array or null
  104868. */
  104869. getScene?(): Scene;
  104870. /**
  104871. * Gets the absolute position from the mesh
  104872. * @returns the absolute position
  104873. */
  104874. getAbsolutePosition(): Vector3;
  104875. /**
  104876. * Gets the absolute pivot point from the mesh
  104877. * @returns the absolute pivot point
  104878. */
  104879. getAbsolutePivotPoint(): Vector3;
  104880. /**
  104881. * Rotates the mesh
  104882. * @param axis The axis of rotation
  104883. * @param amount The amount of rotation
  104884. * @param space The space of the rotation
  104885. * @returns The rotation transform node
  104886. */
  104887. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  104888. /**
  104889. * Translates the mesh
  104890. * @param axis The axis of translation
  104891. * @param distance The distance of translation
  104892. * @param space The space of the translation
  104893. * @returns The transform node
  104894. */
  104895. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  104896. /**
  104897. * Sets the absolute position of the mesh
  104898. * @param absolutePosition The absolute position of the mesh
  104899. * @returns The transform node
  104900. */
  104901. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  104902. /**
  104903. * Gets the class name of the mesh
  104904. * @returns The class name
  104905. */
  104906. getClassName(): string;
  104907. }
  104908. /**
  104909. * Represents a physics imposter
  104910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104911. */
  104912. export class PhysicsImpostor {
  104913. /**
  104914. * The physics-enabled object used as the physics imposter
  104915. */
  104916. object: IPhysicsEnabledObject;
  104917. /**
  104918. * The type of the physics imposter
  104919. */
  104920. type: number;
  104921. private _options;
  104922. private _scene?;
  104923. /**
  104924. * The default object size of the imposter
  104925. */
  104926. static DEFAULT_OBJECT_SIZE: Vector3;
  104927. /**
  104928. * The identity quaternion of the imposter
  104929. */
  104930. static IDENTITY_QUATERNION: Quaternion;
  104931. /** @hidden */
  104932. _pluginData: any;
  104933. private _physicsEngine;
  104934. private _physicsBody;
  104935. private _bodyUpdateRequired;
  104936. private _onBeforePhysicsStepCallbacks;
  104937. private _onAfterPhysicsStepCallbacks;
  104938. /** @hidden */
  104939. _onPhysicsCollideCallbacks: Array<{
  104940. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  104941. otherImpostors: Array<PhysicsImpostor>;
  104942. }>;
  104943. private _deltaPosition;
  104944. private _deltaRotation;
  104945. private _deltaRotationConjugated;
  104946. /** @hidden */
  104947. _isFromLine: boolean;
  104948. private _parent;
  104949. private _isDisposed;
  104950. private static _tmpVecs;
  104951. private static _tmpQuat;
  104952. /**
  104953. * Specifies if the physics imposter is disposed
  104954. */
  104955. get isDisposed(): boolean;
  104956. /**
  104957. * Gets the mass of the physics imposter
  104958. */
  104959. get mass(): number;
  104960. set mass(value: number);
  104961. /**
  104962. * Gets the coefficient of friction
  104963. */
  104964. get friction(): number;
  104965. /**
  104966. * Sets the coefficient of friction
  104967. */
  104968. set friction(value: number);
  104969. /**
  104970. * Gets the coefficient of restitution
  104971. */
  104972. get restitution(): number;
  104973. /**
  104974. * Sets the coefficient of restitution
  104975. */
  104976. set restitution(value: number);
  104977. /**
  104978. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  104979. */
  104980. get pressure(): number;
  104981. /**
  104982. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  104983. */
  104984. set pressure(value: number);
  104985. /**
  104986. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104987. */
  104988. get stiffness(): number;
  104989. /**
  104990. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104991. */
  104992. set stiffness(value: number);
  104993. /**
  104994. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104995. */
  104996. get velocityIterations(): number;
  104997. /**
  104998. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104999. */
  105000. set velocityIterations(value: number);
  105001. /**
  105002. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  105003. */
  105004. get positionIterations(): number;
  105005. /**
  105006. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  105007. */
  105008. set positionIterations(value: number);
  105009. /**
  105010. * The unique id of the physics imposter
  105011. * set by the physics engine when adding this impostor to the array
  105012. */
  105013. uniqueId: number;
  105014. /**
  105015. * @hidden
  105016. */
  105017. soft: boolean;
  105018. /**
  105019. * @hidden
  105020. */
  105021. segments: number;
  105022. private _joints;
  105023. /**
  105024. * Initializes the physics imposter
  105025. * @param object The physics-enabled object used as the physics imposter
  105026. * @param type The type of the physics imposter
  105027. * @param _options The options for the physics imposter
  105028. * @param _scene The Babylon scene
  105029. */
  105030. constructor(
  105031. /**
  105032. * The physics-enabled object used as the physics imposter
  105033. */
  105034. object: IPhysicsEnabledObject,
  105035. /**
  105036. * The type of the physics imposter
  105037. */
  105038. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  105039. /**
  105040. * This function will completly initialize this impostor.
  105041. * It will create a new body - but only if this mesh has no parent.
  105042. * If it has, this impostor will not be used other than to define the impostor
  105043. * of the child mesh.
  105044. * @hidden
  105045. */
  105046. _init(): void;
  105047. private _getPhysicsParent;
  105048. /**
  105049. * Should a new body be generated.
  105050. * @returns boolean specifying if body initialization is required
  105051. */
  105052. isBodyInitRequired(): boolean;
  105053. /**
  105054. * Sets the updated scaling
  105055. * @param updated Specifies if the scaling is updated
  105056. */
  105057. setScalingUpdated(): void;
  105058. /**
  105059. * Force a regeneration of this or the parent's impostor's body.
  105060. * Use under cautious - This will remove all joints already implemented.
  105061. */
  105062. forceUpdate(): void;
  105063. /**
  105064. * Gets the body that holds this impostor. Either its own, or its parent.
  105065. */
  105066. get physicsBody(): any;
  105067. /**
  105068. * Get the parent of the physics imposter
  105069. * @returns Physics imposter or null
  105070. */
  105071. get parent(): Nullable<PhysicsImpostor>;
  105072. /**
  105073. * Sets the parent of the physics imposter
  105074. */
  105075. set parent(value: Nullable<PhysicsImpostor>);
  105076. /**
  105077. * Set the physics body. Used mainly by the physics engine/plugin
  105078. */
  105079. set physicsBody(physicsBody: any);
  105080. /**
  105081. * Resets the update flags
  105082. */
  105083. resetUpdateFlags(): void;
  105084. /**
  105085. * Gets the object extend size
  105086. * @returns the object extend size
  105087. */
  105088. getObjectExtendSize(): Vector3;
  105089. /**
  105090. * Gets the object center
  105091. * @returns The object center
  105092. */
  105093. getObjectCenter(): Vector3;
  105094. /**
  105095. * Get a specific parameter from the options parameters
  105096. * @param paramName The object parameter name
  105097. * @returns The object parameter
  105098. */
  105099. getParam(paramName: string): any;
  105100. /**
  105101. * Sets a specific parameter in the options given to the physics plugin
  105102. * @param paramName The parameter name
  105103. * @param value The value of the parameter
  105104. */
  105105. setParam(paramName: string, value: number): void;
  105106. /**
  105107. * Specifically change the body's mass option. Won't recreate the physics body object
  105108. * @param mass The mass of the physics imposter
  105109. */
  105110. setMass(mass: number): void;
  105111. /**
  105112. * Gets the linear velocity
  105113. * @returns linear velocity or null
  105114. */
  105115. getLinearVelocity(): Nullable<Vector3>;
  105116. /**
  105117. * Sets the linear velocity
  105118. * @param velocity linear velocity or null
  105119. */
  105120. setLinearVelocity(velocity: Nullable<Vector3>): void;
  105121. /**
  105122. * Gets the angular velocity
  105123. * @returns angular velocity or null
  105124. */
  105125. getAngularVelocity(): Nullable<Vector3>;
  105126. /**
  105127. * Sets the angular velocity
  105128. * @param velocity The velocity or null
  105129. */
  105130. setAngularVelocity(velocity: Nullable<Vector3>): void;
  105131. /**
  105132. * Execute a function with the physics plugin native code
  105133. * Provide a function the will have two variables - the world object and the physics body object
  105134. * @param func The function to execute with the physics plugin native code
  105135. */
  105136. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  105137. /**
  105138. * Register a function that will be executed before the physics world is stepping forward
  105139. * @param func The function to execute before the physics world is stepped forward
  105140. */
  105141. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105142. /**
  105143. * Unregister a function that will be executed before the physics world is stepping forward
  105144. * @param func The function to execute before the physics world is stepped forward
  105145. */
  105146. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105147. /**
  105148. * Register a function that will be executed after the physics step
  105149. * @param func The function to execute after physics step
  105150. */
  105151. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105152. /**
  105153. * Unregisters a function that will be executed after the physics step
  105154. * @param func The function to execute after physics step
  105155. */
  105156. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105157. /**
  105158. * register a function that will be executed when this impostor collides against a different body
  105159. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  105160. * @param func Callback that is executed on collision
  105161. */
  105162. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  105163. /**
  105164. * Unregisters the physics imposter on contact
  105165. * @param collideAgainst The physics object to collide against
  105166. * @param func Callback to execute on collision
  105167. */
  105168. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  105169. private _tmpQuat;
  105170. private _tmpQuat2;
  105171. /**
  105172. * Get the parent rotation
  105173. * @returns The parent rotation
  105174. */
  105175. getParentsRotation(): Quaternion;
  105176. /**
  105177. * this function is executed by the physics engine.
  105178. */
  105179. beforeStep: () => void;
  105180. /**
  105181. * this function is executed by the physics engine
  105182. */
  105183. afterStep: () => void;
  105184. /**
  105185. * Legacy collision detection event support
  105186. */
  105187. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  105188. /**
  105189. * event and body object due to cannon's event-based architecture.
  105190. */
  105191. onCollide: (e: {
  105192. body: any;
  105193. }) => void;
  105194. /**
  105195. * Apply a force
  105196. * @param force The force to apply
  105197. * @param contactPoint The contact point for the force
  105198. * @returns The physics imposter
  105199. */
  105200. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  105201. /**
  105202. * Apply an impulse
  105203. * @param force The impulse force
  105204. * @param contactPoint The contact point for the impulse force
  105205. * @returns The physics imposter
  105206. */
  105207. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  105208. /**
  105209. * A help function to create a joint
  105210. * @param otherImpostor A physics imposter used to create a joint
  105211. * @param jointType The type of joint
  105212. * @param jointData The data for the joint
  105213. * @returns The physics imposter
  105214. */
  105215. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  105216. /**
  105217. * Add a joint to this impostor with a different impostor
  105218. * @param otherImpostor A physics imposter used to add a joint
  105219. * @param joint The joint to add
  105220. * @returns The physics imposter
  105221. */
  105222. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  105223. /**
  105224. * Add an anchor to a cloth impostor
  105225. * @param otherImpostor rigid impostor to anchor to
  105226. * @param width ratio across width from 0 to 1
  105227. * @param height ratio up height from 0 to 1
  105228. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  105229. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  105230. * @returns impostor the soft imposter
  105231. */
  105232. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  105233. /**
  105234. * Add a hook to a rope impostor
  105235. * @param otherImpostor rigid impostor to anchor to
  105236. * @param length ratio across rope from 0 to 1
  105237. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  105238. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  105239. * @returns impostor the rope imposter
  105240. */
  105241. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  105242. /**
  105243. * Will keep this body still, in a sleep mode.
  105244. * @returns the physics imposter
  105245. */
  105246. sleep(): PhysicsImpostor;
  105247. /**
  105248. * Wake the body up.
  105249. * @returns The physics imposter
  105250. */
  105251. wakeUp(): PhysicsImpostor;
  105252. /**
  105253. * Clones the physics imposter
  105254. * @param newObject The physics imposter clones to this physics-enabled object
  105255. * @returns A nullable physics imposter
  105256. */
  105257. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105258. /**
  105259. * Disposes the physics imposter
  105260. */
  105261. dispose(): void;
  105262. /**
  105263. * Sets the delta position
  105264. * @param position The delta position amount
  105265. */
  105266. setDeltaPosition(position: Vector3): void;
  105267. /**
  105268. * Sets the delta rotation
  105269. * @param rotation The delta rotation amount
  105270. */
  105271. setDeltaRotation(rotation: Quaternion): void;
  105272. /**
  105273. * Gets the box size of the physics imposter and stores the result in the input parameter
  105274. * @param result Stores the box size
  105275. * @returns The physics imposter
  105276. */
  105277. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  105278. /**
  105279. * Gets the radius of the physics imposter
  105280. * @returns Radius of the physics imposter
  105281. */
  105282. getRadius(): number;
  105283. /**
  105284. * Sync a bone with this impostor
  105285. * @param bone The bone to sync to the impostor.
  105286. * @param boneMesh The mesh that the bone is influencing.
  105287. * @param jointPivot The pivot of the joint / bone in local space.
  105288. * @param distToJoint Optional distance from the impostor to the joint.
  105289. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  105290. */
  105291. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  105292. /**
  105293. * Sync impostor to a bone
  105294. * @param bone The bone that the impostor will be synced to.
  105295. * @param boneMesh The mesh that the bone is influencing.
  105296. * @param jointPivot The pivot of the joint / bone in local space.
  105297. * @param distToJoint Optional distance from the impostor to the joint.
  105298. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  105299. * @param boneAxis Optional vector3 axis the bone is aligned with
  105300. */
  105301. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  105302. /**
  105303. * No-Imposter type
  105304. */
  105305. static NoImpostor: number;
  105306. /**
  105307. * Sphere-Imposter type
  105308. */
  105309. static SphereImpostor: number;
  105310. /**
  105311. * Box-Imposter type
  105312. */
  105313. static BoxImpostor: number;
  105314. /**
  105315. * Plane-Imposter type
  105316. */
  105317. static PlaneImpostor: number;
  105318. /**
  105319. * Mesh-imposter type
  105320. */
  105321. static MeshImpostor: number;
  105322. /**
  105323. * Capsule-Impostor type (Ammo.js plugin only)
  105324. */
  105325. static CapsuleImpostor: number;
  105326. /**
  105327. * Cylinder-Imposter type
  105328. */
  105329. static CylinderImpostor: number;
  105330. /**
  105331. * Particle-Imposter type
  105332. */
  105333. static ParticleImpostor: number;
  105334. /**
  105335. * Heightmap-Imposter type
  105336. */
  105337. static HeightmapImpostor: number;
  105338. /**
  105339. * ConvexHull-Impostor type (Ammo.js plugin only)
  105340. */
  105341. static ConvexHullImpostor: number;
  105342. /**
  105343. * Custom-Imposter type (Ammo.js plugin only)
  105344. */
  105345. static CustomImpostor: number;
  105346. /**
  105347. * Rope-Imposter type
  105348. */
  105349. static RopeImpostor: number;
  105350. /**
  105351. * Cloth-Imposter type
  105352. */
  105353. static ClothImpostor: number;
  105354. /**
  105355. * Softbody-Imposter type
  105356. */
  105357. static SoftbodyImpostor: number;
  105358. }
  105359. }
  105360. declare module BABYLON {
  105361. /**
  105362. * @hidden
  105363. **/
  105364. export class _CreationDataStorage {
  105365. closePath?: boolean;
  105366. closeArray?: boolean;
  105367. idx: number[];
  105368. dashSize: number;
  105369. gapSize: number;
  105370. path3D: Path3D;
  105371. pathArray: Vector3[][];
  105372. arc: number;
  105373. radius: number;
  105374. cap: number;
  105375. tessellation: number;
  105376. }
  105377. /**
  105378. * @hidden
  105379. **/
  105380. class _InstanceDataStorage {
  105381. visibleInstances: any;
  105382. batchCache: _InstancesBatch;
  105383. instancesBufferSize: number;
  105384. instancesBuffer: Nullable<Buffer>;
  105385. instancesData: Float32Array;
  105386. overridenInstanceCount: number;
  105387. isFrozen: boolean;
  105388. previousBatch: Nullable<_InstancesBatch>;
  105389. hardwareInstancedRendering: boolean;
  105390. sideOrientation: number;
  105391. manualUpdate: boolean;
  105392. }
  105393. /**
  105394. * @hidden
  105395. **/
  105396. export class _InstancesBatch {
  105397. mustReturn: boolean;
  105398. visibleInstances: Nullable<InstancedMesh[]>[];
  105399. renderSelf: boolean[];
  105400. hardwareInstancedRendering: boolean[];
  105401. }
  105402. /**
  105403. * @hidden
  105404. **/
  105405. class _ThinInstanceDataStorage {
  105406. instancesCount: number;
  105407. matrixBuffer: Nullable<Buffer>;
  105408. matrixBufferSize: number;
  105409. matrixData: Nullable<Float32Array>;
  105410. boundingVectors: Array<Vector3>;
  105411. }
  105412. /**
  105413. * Class used to represent renderable models
  105414. */
  105415. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  105416. /**
  105417. * Mesh side orientation : usually the external or front surface
  105418. */
  105419. static readonly FRONTSIDE: number;
  105420. /**
  105421. * Mesh side orientation : usually the internal or back surface
  105422. */
  105423. static readonly BACKSIDE: number;
  105424. /**
  105425. * Mesh side orientation : both internal and external or front and back surfaces
  105426. */
  105427. static readonly DOUBLESIDE: number;
  105428. /**
  105429. * Mesh side orientation : by default, `FRONTSIDE`
  105430. */
  105431. static readonly DEFAULTSIDE: number;
  105432. /**
  105433. * Mesh cap setting : no cap
  105434. */
  105435. static readonly NO_CAP: number;
  105436. /**
  105437. * Mesh cap setting : one cap at the beginning of the mesh
  105438. */
  105439. static readonly CAP_START: number;
  105440. /**
  105441. * Mesh cap setting : one cap at the end of the mesh
  105442. */
  105443. static readonly CAP_END: number;
  105444. /**
  105445. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  105446. */
  105447. static readonly CAP_ALL: number;
  105448. /**
  105449. * Mesh pattern setting : no flip or rotate
  105450. */
  105451. static readonly NO_FLIP: number;
  105452. /**
  105453. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  105454. */
  105455. static readonly FLIP_TILE: number;
  105456. /**
  105457. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  105458. */
  105459. static readonly ROTATE_TILE: number;
  105460. /**
  105461. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  105462. */
  105463. static readonly FLIP_ROW: number;
  105464. /**
  105465. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  105466. */
  105467. static readonly ROTATE_ROW: number;
  105468. /**
  105469. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  105470. */
  105471. static readonly FLIP_N_ROTATE_TILE: number;
  105472. /**
  105473. * Mesh pattern setting : rotate pattern and rotate
  105474. */
  105475. static readonly FLIP_N_ROTATE_ROW: number;
  105476. /**
  105477. * Mesh tile positioning : part tiles same on left/right or top/bottom
  105478. */
  105479. static readonly CENTER: number;
  105480. /**
  105481. * Mesh tile positioning : part tiles on left
  105482. */
  105483. static readonly LEFT: number;
  105484. /**
  105485. * Mesh tile positioning : part tiles on right
  105486. */
  105487. static readonly RIGHT: number;
  105488. /**
  105489. * Mesh tile positioning : part tiles on top
  105490. */
  105491. static readonly TOP: number;
  105492. /**
  105493. * Mesh tile positioning : part tiles on bottom
  105494. */
  105495. static readonly BOTTOM: number;
  105496. /**
  105497. * Gets the default side orientation.
  105498. * @param orientation the orientation to value to attempt to get
  105499. * @returns the default orientation
  105500. * @hidden
  105501. */
  105502. static _GetDefaultSideOrientation(orientation?: number): number;
  105503. private _internalMeshDataInfo;
  105504. /**
  105505. * An event triggered before rendering the mesh
  105506. */
  105507. get onBeforeRenderObservable(): Observable<Mesh>;
  105508. /**
  105509. * An event triggered before binding the mesh
  105510. */
  105511. get onBeforeBindObservable(): Observable<Mesh>;
  105512. /**
  105513. * An event triggered after rendering the mesh
  105514. */
  105515. get onAfterRenderObservable(): Observable<Mesh>;
  105516. /**
  105517. * An event triggered before drawing the mesh
  105518. */
  105519. get onBeforeDrawObservable(): Observable<Mesh>;
  105520. private _onBeforeDrawObserver;
  105521. /**
  105522. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  105523. */
  105524. set onBeforeDraw(callback: () => void);
  105525. get hasInstances(): boolean;
  105526. get hasThinInstances(): boolean;
  105527. /**
  105528. * Gets the delay loading state of the mesh (when delay loading is turned on)
  105529. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  105530. */
  105531. delayLoadState: number;
  105532. /**
  105533. * Gets the list of instances created from this mesh
  105534. * it is not supposed to be modified manually.
  105535. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  105536. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  105537. */
  105538. instances: InstancedMesh[];
  105539. /**
  105540. * Gets the file containing delay loading data for this mesh
  105541. */
  105542. delayLoadingFile: string;
  105543. /** @hidden */
  105544. _binaryInfo: any;
  105545. /**
  105546. * User defined function used to change how LOD level selection is done
  105547. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105548. */
  105549. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  105550. /**
  105551. * Gets or sets the morph target manager
  105552. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105553. */
  105554. get morphTargetManager(): Nullable<MorphTargetManager>;
  105555. set morphTargetManager(value: Nullable<MorphTargetManager>);
  105556. /** @hidden */
  105557. _creationDataStorage: Nullable<_CreationDataStorage>;
  105558. /** @hidden */
  105559. _geometry: Nullable<Geometry>;
  105560. /** @hidden */
  105561. _delayInfo: Array<string>;
  105562. /** @hidden */
  105563. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  105564. /** @hidden */
  105565. _instanceDataStorage: _InstanceDataStorage;
  105566. /** @hidden */
  105567. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  105568. private _effectiveMaterial;
  105569. /** @hidden */
  105570. _shouldGenerateFlatShading: boolean;
  105571. /** @hidden */
  105572. _originalBuilderSideOrientation: number;
  105573. /**
  105574. * Use this property to change the original side orientation defined at construction time
  105575. */
  105576. overrideMaterialSideOrientation: Nullable<number>;
  105577. /**
  105578. * Gets the source mesh (the one used to clone this one from)
  105579. */
  105580. get source(): Nullable<Mesh>;
  105581. /**
  105582. * Gets or sets a boolean indicating that this mesh does not use index buffer
  105583. */
  105584. get isUnIndexed(): boolean;
  105585. set isUnIndexed(value: boolean);
  105586. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  105587. get worldMatrixInstancedBuffer(): Float32Array;
  105588. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  105589. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  105590. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  105591. /**
  105592. * @constructor
  105593. * @param name The value used by scene.getMeshByName() to do a lookup.
  105594. * @param scene The scene to add this mesh to.
  105595. * @param parent The parent of this mesh, if it has one
  105596. * @param source An optional Mesh from which geometry is shared, cloned.
  105597. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  105598. * When false, achieved by calling a clone(), also passing False.
  105599. * This will make creation of children, recursive.
  105600. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  105601. */
  105602. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  105603. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  105604. doNotInstantiate: boolean;
  105605. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  105606. /**
  105607. * Gets the class name
  105608. * @returns the string "Mesh".
  105609. */
  105610. getClassName(): string;
  105611. /** @hidden */
  105612. get _isMesh(): boolean;
  105613. /**
  105614. * Returns a description of this mesh
  105615. * @param fullDetails define if full details about this mesh must be used
  105616. * @returns a descriptive string representing this mesh
  105617. */
  105618. toString(fullDetails?: boolean): string;
  105619. /** @hidden */
  105620. _unBindEffect(): void;
  105621. /**
  105622. * Gets a boolean indicating if this mesh has LOD
  105623. */
  105624. get hasLODLevels(): boolean;
  105625. /**
  105626. * Gets the list of MeshLODLevel associated with the current mesh
  105627. * @returns an array of MeshLODLevel
  105628. */
  105629. getLODLevels(): MeshLODLevel[];
  105630. private _sortLODLevels;
  105631. /**
  105632. * Add a mesh as LOD level triggered at the given distance.
  105633. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105634. * @param distance The distance from the center of the object to show this level
  105635. * @param mesh The mesh to be added as LOD level (can be null)
  105636. * @return This mesh (for chaining)
  105637. */
  105638. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  105639. /**
  105640. * Returns the LOD level mesh at the passed distance or null if not found.
  105641. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105642. * @param distance The distance from the center of the object to show this level
  105643. * @returns a Mesh or `null`
  105644. */
  105645. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  105646. /**
  105647. * Remove a mesh from the LOD array
  105648. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105649. * @param mesh defines the mesh to be removed
  105650. * @return This mesh (for chaining)
  105651. */
  105652. removeLODLevel(mesh: Mesh): Mesh;
  105653. /**
  105654. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  105655. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105656. * @param camera defines the camera to use to compute distance
  105657. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  105658. * @return This mesh (for chaining)
  105659. */
  105660. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  105661. /**
  105662. * Gets the mesh internal Geometry object
  105663. */
  105664. get geometry(): Nullable<Geometry>;
  105665. /**
  105666. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  105667. * @returns the total number of vertices
  105668. */
  105669. getTotalVertices(): number;
  105670. /**
  105671. * Returns the content of an associated vertex buffer
  105672. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105673. * - VertexBuffer.PositionKind
  105674. * - VertexBuffer.UVKind
  105675. * - VertexBuffer.UV2Kind
  105676. * - VertexBuffer.UV3Kind
  105677. * - VertexBuffer.UV4Kind
  105678. * - VertexBuffer.UV5Kind
  105679. * - VertexBuffer.UV6Kind
  105680. * - VertexBuffer.ColorKind
  105681. * - VertexBuffer.MatricesIndicesKind
  105682. * - VertexBuffer.MatricesIndicesExtraKind
  105683. * - VertexBuffer.MatricesWeightsKind
  105684. * - VertexBuffer.MatricesWeightsExtraKind
  105685. * @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
  105686. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  105687. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  105688. */
  105689. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105690. /**
  105691. * Returns the mesh VertexBuffer object from the requested `kind`
  105692. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105693. * - VertexBuffer.PositionKind
  105694. * - VertexBuffer.NormalKind
  105695. * - VertexBuffer.UVKind
  105696. * - VertexBuffer.UV2Kind
  105697. * - VertexBuffer.UV3Kind
  105698. * - VertexBuffer.UV4Kind
  105699. * - VertexBuffer.UV5Kind
  105700. * - VertexBuffer.UV6Kind
  105701. * - VertexBuffer.ColorKind
  105702. * - VertexBuffer.MatricesIndicesKind
  105703. * - VertexBuffer.MatricesIndicesExtraKind
  105704. * - VertexBuffer.MatricesWeightsKind
  105705. * - VertexBuffer.MatricesWeightsExtraKind
  105706. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  105707. */
  105708. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105709. /**
  105710. * Tests if a specific vertex buffer is associated with this mesh
  105711. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105712. * - VertexBuffer.PositionKind
  105713. * - VertexBuffer.NormalKind
  105714. * - VertexBuffer.UVKind
  105715. * - VertexBuffer.UV2Kind
  105716. * - VertexBuffer.UV3Kind
  105717. * - VertexBuffer.UV4Kind
  105718. * - VertexBuffer.UV5Kind
  105719. * - VertexBuffer.UV6Kind
  105720. * - VertexBuffer.ColorKind
  105721. * - VertexBuffer.MatricesIndicesKind
  105722. * - VertexBuffer.MatricesIndicesExtraKind
  105723. * - VertexBuffer.MatricesWeightsKind
  105724. * - VertexBuffer.MatricesWeightsExtraKind
  105725. * @returns a boolean
  105726. */
  105727. isVerticesDataPresent(kind: string): boolean;
  105728. /**
  105729. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  105730. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105731. * - VertexBuffer.PositionKind
  105732. * - VertexBuffer.UVKind
  105733. * - VertexBuffer.UV2Kind
  105734. * - VertexBuffer.UV3Kind
  105735. * - VertexBuffer.UV4Kind
  105736. * - VertexBuffer.UV5Kind
  105737. * - VertexBuffer.UV6Kind
  105738. * - VertexBuffer.ColorKind
  105739. * - VertexBuffer.MatricesIndicesKind
  105740. * - VertexBuffer.MatricesIndicesExtraKind
  105741. * - VertexBuffer.MatricesWeightsKind
  105742. * - VertexBuffer.MatricesWeightsExtraKind
  105743. * @returns a boolean
  105744. */
  105745. isVertexBufferUpdatable(kind: string): boolean;
  105746. /**
  105747. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  105748. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105749. * - VertexBuffer.PositionKind
  105750. * - VertexBuffer.NormalKind
  105751. * - VertexBuffer.UVKind
  105752. * - VertexBuffer.UV2Kind
  105753. * - VertexBuffer.UV3Kind
  105754. * - VertexBuffer.UV4Kind
  105755. * - VertexBuffer.UV5Kind
  105756. * - VertexBuffer.UV6Kind
  105757. * - VertexBuffer.ColorKind
  105758. * - VertexBuffer.MatricesIndicesKind
  105759. * - VertexBuffer.MatricesIndicesExtraKind
  105760. * - VertexBuffer.MatricesWeightsKind
  105761. * - VertexBuffer.MatricesWeightsExtraKind
  105762. * @returns an array of strings
  105763. */
  105764. getVerticesDataKinds(): string[];
  105765. /**
  105766. * Returns a positive integer : the total number of indices in this mesh geometry.
  105767. * @returns the numner of indices or zero if the mesh has no geometry.
  105768. */
  105769. getTotalIndices(): number;
  105770. /**
  105771. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105772. * @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.
  105773. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105774. * @returns the indices array or an empty array if the mesh has no geometry
  105775. */
  105776. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105777. get isBlocked(): boolean;
  105778. /**
  105779. * Determine if the current mesh is ready to be rendered
  105780. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105781. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  105782. * @returns true if all associated assets are ready (material, textures, shaders)
  105783. */
  105784. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  105785. /**
  105786. * 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.
  105787. */
  105788. get areNormalsFrozen(): boolean;
  105789. /**
  105790. * 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.
  105791. * @returns the current mesh
  105792. */
  105793. freezeNormals(): Mesh;
  105794. /**
  105795. * 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
  105796. * @returns the current mesh
  105797. */
  105798. unfreezeNormals(): Mesh;
  105799. /**
  105800. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  105801. */
  105802. set overridenInstanceCount(count: number);
  105803. /** @hidden */
  105804. _preActivate(): Mesh;
  105805. /** @hidden */
  105806. _preActivateForIntermediateRendering(renderId: number): Mesh;
  105807. /** @hidden */
  105808. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  105809. protected _afterComputeWorldMatrix(): void;
  105810. /** @hidden */
  105811. _postActivate(): void;
  105812. /**
  105813. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  105814. * This means the mesh underlying bounding box and sphere are recomputed.
  105815. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  105816. * @returns the current mesh
  105817. */
  105818. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  105819. /** @hidden */
  105820. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  105821. /**
  105822. * This function will subdivide the mesh into multiple submeshes
  105823. * @param count defines the expected number of submeshes
  105824. */
  105825. subdivide(count: number): void;
  105826. /**
  105827. * Copy a FloatArray into a specific associated vertex buffer
  105828. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105829. * - VertexBuffer.PositionKind
  105830. * - VertexBuffer.UVKind
  105831. * - VertexBuffer.UV2Kind
  105832. * - VertexBuffer.UV3Kind
  105833. * - VertexBuffer.UV4Kind
  105834. * - VertexBuffer.UV5Kind
  105835. * - VertexBuffer.UV6Kind
  105836. * - VertexBuffer.ColorKind
  105837. * - VertexBuffer.MatricesIndicesKind
  105838. * - VertexBuffer.MatricesIndicesExtraKind
  105839. * - VertexBuffer.MatricesWeightsKind
  105840. * - VertexBuffer.MatricesWeightsExtraKind
  105841. * @param data defines the data source
  105842. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105843. * @param stride defines the data stride size (can be null)
  105844. * @returns the current mesh
  105845. */
  105846. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  105847. /**
  105848. * Delete a vertex buffer associated with this mesh
  105849. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  105850. * - VertexBuffer.PositionKind
  105851. * - VertexBuffer.UVKind
  105852. * - VertexBuffer.UV2Kind
  105853. * - VertexBuffer.UV3Kind
  105854. * - VertexBuffer.UV4Kind
  105855. * - VertexBuffer.UV5Kind
  105856. * - VertexBuffer.UV6Kind
  105857. * - VertexBuffer.ColorKind
  105858. * - VertexBuffer.MatricesIndicesKind
  105859. * - VertexBuffer.MatricesIndicesExtraKind
  105860. * - VertexBuffer.MatricesWeightsKind
  105861. * - VertexBuffer.MatricesWeightsExtraKind
  105862. */
  105863. removeVerticesData(kind: string): void;
  105864. /**
  105865. * Flags an associated vertex buffer as updatable
  105866. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  105867. * - VertexBuffer.PositionKind
  105868. * - VertexBuffer.UVKind
  105869. * - VertexBuffer.UV2Kind
  105870. * - VertexBuffer.UV3Kind
  105871. * - VertexBuffer.UV4Kind
  105872. * - VertexBuffer.UV5Kind
  105873. * - VertexBuffer.UV6Kind
  105874. * - VertexBuffer.ColorKind
  105875. * - VertexBuffer.MatricesIndicesKind
  105876. * - VertexBuffer.MatricesIndicesExtraKind
  105877. * - VertexBuffer.MatricesWeightsKind
  105878. * - VertexBuffer.MatricesWeightsExtraKind
  105879. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105880. */
  105881. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  105882. /**
  105883. * Sets the mesh global Vertex Buffer
  105884. * @param buffer defines the buffer to use
  105885. * @returns the current mesh
  105886. */
  105887. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  105888. /**
  105889. * Update a specific associated vertex buffer
  105890. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105891. * - VertexBuffer.PositionKind
  105892. * - VertexBuffer.UVKind
  105893. * - VertexBuffer.UV2Kind
  105894. * - VertexBuffer.UV3Kind
  105895. * - VertexBuffer.UV4Kind
  105896. * - VertexBuffer.UV5Kind
  105897. * - VertexBuffer.UV6Kind
  105898. * - VertexBuffer.ColorKind
  105899. * - VertexBuffer.MatricesIndicesKind
  105900. * - VertexBuffer.MatricesIndicesExtraKind
  105901. * - VertexBuffer.MatricesWeightsKind
  105902. * - VertexBuffer.MatricesWeightsExtraKind
  105903. * @param data defines the data source
  105904. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105905. * @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)
  105906. * @returns the current mesh
  105907. */
  105908. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  105909. /**
  105910. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  105911. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  105912. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  105913. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  105914. * @returns the current mesh
  105915. */
  105916. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  105917. /**
  105918. * Creates a un-shared specific occurence of the geometry for the mesh.
  105919. * @returns the current mesh
  105920. */
  105921. makeGeometryUnique(): Mesh;
  105922. /**
  105923. * Set the index buffer of this mesh
  105924. * @param indices defines the source data
  105925. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  105926. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  105927. * @returns the current mesh
  105928. */
  105929. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  105930. /**
  105931. * Update the current index buffer
  105932. * @param indices defines the source data
  105933. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105934. * @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)
  105935. * @returns the current mesh
  105936. */
  105937. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105938. /**
  105939. * Invert the geometry to move from a right handed system to a left handed one.
  105940. * @returns the current mesh
  105941. */
  105942. toLeftHanded(): Mesh;
  105943. /** @hidden */
  105944. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  105945. /** @hidden */
  105946. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  105947. /**
  105948. * Registers for this mesh a javascript function called just before the rendering process
  105949. * @param func defines the function to call before rendering this mesh
  105950. * @returns the current mesh
  105951. */
  105952. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105953. /**
  105954. * Disposes a previously registered javascript function called before the rendering
  105955. * @param func defines the function to remove
  105956. * @returns the current mesh
  105957. */
  105958. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105959. /**
  105960. * Registers for this mesh a javascript function called just after the rendering is complete
  105961. * @param func defines the function to call after rendering this mesh
  105962. * @returns the current mesh
  105963. */
  105964. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105965. /**
  105966. * Disposes a previously registered javascript function called after the rendering.
  105967. * @param func defines the function to remove
  105968. * @returns the current mesh
  105969. */
  105970. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105971. /** @hidden */
  105972. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  105973. /** @hidden */
  105974. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  105975. /** @hidden */
  105976. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  105977. /** @hidden */
  105978. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  105979. /** @hidden */
  105980. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  105981. /** @hidden */
  105982. _rebuild(): void;
  105983. /** @hidden */
  105984. _freeze(): void;
  105985. /** @hidden */
  105986. _unFreeze(): void;
  105987. /**
  105988. * 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
  105989. * @param subMesh defines the subMesh to render
  105990. * @param enableAlphaMode defines if alpha mode can be changed
  105991. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  105992. * @returns the current mesh
  105993. */
  105994. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  105995. private _onBeforeDraw;
  105996. /**
  105997. * Renormalize the mesh and patch it up if there are no weights
  105998. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  105999. * However in the case of zero weights then we set just a single influence to 1.
  106000. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  106001. */
  106002. cleanMatrixWeights(): void;
  106003. private normalizeSkinFourWeights;
  106004. private normalizeSkinWeightsAndExtra;
  106005. /**
  106006. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  106007. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  106008. * the user know there was an issue with importing the mesh
  106009. * @returns a validation object with skinned, valid and report string
  106010. */
  106011. validateSkinning(): {
  106012. skinned: boolean;
  106013. valid: boolean;
  106014. report: string;
  106015. };
  106016. /** @hidden */
  106017. _checkDelayState(): Mesh;
  106018. private _queueLoad;
  106019. /**
  106020. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  106021. * A mesh is in the frustum if its bounding box intersects the frustum
  106022. * @param frustumPlanes defines the frustum to test
  106023. * @returns true if the mesh is in the frustum planes
  106024. */
  106025. isInFrustum(frustumPlanes: Plane[]): boolean;
  106026. /**
  106027. * Sets the mesh material by the material or multiMaterial `id` property
  106028. * @param id is a string identifying the material or the multiMaterial
  106029. * @returns the current mesh
  106030. */
  106031. setMaterialByID(id: string): Mesh;
  106032. /**
  106033. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  106034. * @returns an array of IAnimatable
  106035. */
  106036. getAnimatables(): IAnimatable[];
  106037. /**
  106038. * Modifies the mesh geometry according to the passed transformation matrix.
  106039. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  106040. * The mesh normals are modified using the same transformation.
  106041. * Note that, under the hood, this method sets a new VertexBuffer each call.
  106042. * @param transform defines the transform matrix to use
  106043. * @see https://doc.babylonjs.com/resources/baking_transformations
  106044. * @returns the current mesh
  106045. */
  106046. bakeTransformIntoVertices(transform: Matrix): Mesh;
  106047. /**
  106048. * Modifies the mesh geometry according to its own current World Matrix.
  106049. * The mesh World Matrix is then reset.
  106050. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  106051. * Note that, under the hood, this method sets a new VertexBuffer each call.
  106052. * @see https://doc.babylonjs.com/resources/baking_transformations
  106053. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  106054. * @returns the current mesh
  106055. */
  106056. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  106057. /** @hidden */
  106058. get _positions(): Nullable<Vector3[]>;
  106059. /** @hidden */
  106060. _resetPointsArrayCache(): Mesh;
  106061. /** @hidden */
  106062. _generatePointsArray(): boolean;
  106063. /**
  106064. * Returns a new Mesh object generated from the current mesh properties.
  106065. * This method must not get confused with createInstance()
  106066. * @param name is a string, the name given to the new mesh
  106067. * @param newParent can be any Node object (default `null`)
  106068. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  106069. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  106070. * @returns a new mesh
  106071. */
  106072. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  106073. /**
  106074. * Releases resources associated with this mesh.
  106075. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106076. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106077. */
  106078. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106079. /** @hidden */
  106080. _disposeInstanceSpecificData(): void;
  106081. /** @hidden */
  106082. _disposeThinInstanceSpecificData(): void;
  106083. /**
  106084. * Modifies the mesh geometry according to a displacement map.
  106085. * 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.
  106086. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  106087. * @param url is a string, the URL from the image file is to be downloaded.
  106088. * @param minHeight is the lower limit of the displacement.
  106089. * @param maxHeight is the upper limit of the displacement.
  106090. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  106091. * @param uvOffset is an optional vector2 used to offset UV.
  106092. * @param uvScale is an optional vector2 used to scale UV.
  106093. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  106094. * @returns the Mesh.
  106095. */
  106096. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  106097. /**
  106098. * Modifies the mesh geometry according to a displacementMap buffer.
  106099. * 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.
  106100. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  106101. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  106102. * @param heightMapWidth is the width of the buffer image.
  106103. * @param heightMapHeight is the height of the buffer image.
  106104. * @param minHeight is the lower limit of the displacement.
  106105. * @param maxHeight is the upper limit of the displacement.
  106106. * @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.
  106107. * @param uvOffset is an optional vector2 used to offset UV.
  106108. * @param uvScale is an optional vector2 used to scale UV.
  106109. * @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.
  106110. * @returns the Mesh.
  106111. */
  106112. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  106113. /**
  106114. * Modify the mesh to get a flat shading rendering.
  106115. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  106116. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  106117. * @returns current mesh
  106118. */
  106119. convertToFlatShadedMesh(): Mesh;
  106120. /**
  106121. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  106122. * In other words, more vertices, no more indices and a single bigger VBO.
  106123. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  106124. * @returns current mesh
  106125. */
  106126. convertToUnIndexedMesh(): Mesh;
  106127. /**
  106128. * Inverses facet orientations.
  106129. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106130. * @param flipNormals will also inverts the normals
  106131. * @returns current mesh
  106132. */
  106133. flipFaces(flipNormals?: boolean): Mesh;
  106134. /**
  106135. * Increase the number of facets and hence vertices in a mesh
  106136. * Vertex normals are interpolated from existing vertex normals
  106137. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106138. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  106139. */
  106140. increaseVertices(numberPerEdge: number): void;
  106141. /**
  106142. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  106143. * This will undo any application of covertToFlatShadedMesh
  106144. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106145. */
  106146. forceSharedVertices(): void;
  106147. /** @hidden */
  106148. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  106149. /** @hidden */
  106150. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  106151. /**
  106152. * Creates a new InstancedMesh object from the mesh model.
  106153. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  106154. * @param name defines the name of the new instance
  106155. * @returns a new InstancedMesh
  106156. */
  106157. createInstance(name: string): InstancedMesh;
  106158. /**
  106159. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  106160. * After this call, all the mesh instances have the same submeshes than the current mesh.
  106161. * @returns the current mesh
  106162. */
  106163. synchronizeInstances(): Mesh;
  106164. /**
  106165. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  106166. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  106167. * This should be used together with the simplification to avoid disappearing triangles.
  106168. * @param successCallback an optional success callback to be called after the optimization finished.
  106169. * @returns the current mesh
  106170. */
  106171. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  106172. /**
  106173. * Serialize current mesh
  106174. * @param serializationObject defines the object which will receive the serialization data
  106175. */
  106176. serialize(serializationObject: any): void;
  106177. /** @hidden */
  106178. _syncGeometryWithMorphTargetManager(): void;
  106179. /** @hidden */
  106180. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  106181. /**
  106182. * Returns a new Mesh object parsed from the source provided.
  106183. * @param parsedMesh is the source
  106184. * @param scene defines the hosting scene
  106185. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  106186. * @returns a new Mesh
  106187. */
  106188. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  106189. /**
  106190. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  106191. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106192. * @param name defines the name of the mesh to create
  106193. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  106194. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  106195. * @param closePath creates a seam between the first and the last points of each path of the path array
  106196. * @param offset is taken in account only if the `pathArray` is containing a single path
  106197. * @param scene defines the hosting scene
  106198. * @param updatable defines if the mesh must be flagged as updatable
  106199. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106200. * @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)
  106201. * @returns a new Mesh
  106202. */
  106203. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106204. /**
  106205. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  106206. * @param name defines the name of the mesh to create
  106207. * @param radius sets the radius size (float) of the polygon (default 0.5)
  106208. * @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
  106209. * @param scene defines the hosting scene
  106210. * @param updatable defines if the mesh must be flagged as updatable
  106211. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106212. * @returns a new Mesh
  106213. */
  106214. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  106215. /**
  106216. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  106217. * @param name defines the name of the mesh to create
  106218. * @param size sets the size (float) of each box side (default 1)
  106219. * @param scene defines the hosting scene
  106220. * @param updatable defines if the mesh must be flagged as updatable
  106221. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106222. * @returns a new Mesh
  106223. */
  106224. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  106225. /**
  106226. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  106227. * @param name defines the name of the mesh to create
  106228. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  106229. * @param diameter sets the diameter size (float) of the sphere (default 1)
  106230. * @param scene defines the hosting scene
  106231. * @param updatable defines if the mesh must be flagged as updatable
  106232. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106233. * @returns a new Mesh
  106234. */
  106235. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106236. /**
  106237. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  106238. * @param name defines the name of the mesh to create
  106239. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  106240. * @param diameter sets the diameter size (float) of the sphere (default 1)
  106241. * @param scene defines the hosting scene
  106242. * @returns a new Mesh
  106243. */
  106244. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  106245. /**
  106246. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  106247. * @param name defines the name of the mesh to create
  106248. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  106249. * @param diameterTop set the top cap diameter (floats, default 1)
  106250. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  106251. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  106252. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  106253. * @param scene defines the hosting scene
  106254. * @param updatable defines if the mesh must be flagged as updatable
  106255. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106256. * @returns a new Mesh
  106257. */
  106258. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  106259. /**
  106260. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  106261. * @param name defines the name of the mesh to create
  106262. * @param diameter sets the diameter size (float) of the torus (default 1)
  106263. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  106264. * @param tessellation sets the number of torus sides (postive integer, default 16)
  106265. * @param scene defines the hosting scene
  106266. * @param updatable defines if the mesh must be flagged as updatable
  106267. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106268. * @returns a new Mesh
  106269. */
  106270. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106271. /**
  106272. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  106273. * @param name defines the name of the mesh to create
  106274. * @param radius sets the global radius size (float) of the torus knot (default 2)
  106275. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  106276. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  106277. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  106278. * @param p the number of windings on X axis (positive integers, default 2)
  106279. * @param q the number of windings on Y axis (positive integers, default 3)
  106280. * @param scene defines the hosting scene
  106281. * @param updatable defines if the mesh must be flagged as updatable
  106282. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106283. * @returns a new Mesh
  106284. */
  106285. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106286. /**
  106287. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  106288. * @param name defines the name of the mesh to create
  106289. * @param points is an array successive Vector3
  106290. * @param scene defines the hosting scene
  106291. * @param updatable defines if the mesh must be flagged as updatable
  106292. * @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).
  106293. * @returns a new Mesh
  106294. */
  106295. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  106296. /**
  106297. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  106298. * @param name defines the name of the mesh to create
  106299. * @param points is an array successive Vector3
  106300. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  106301. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106302. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  106303. * @param scene defines the hosting scene
  106304. * @param updatable defines if the mesh must be flagged as updatable
  106305. * @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)
  106306. * @returns a new Mesh
  106307. */
  106308. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  106309. /**
  106310. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  106311. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  106312. * 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.
  106313. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106314. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106315. * Remember you can only change the shape positions, not their number when updating a polygon.
  106316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  106317. * @param name defines the name of the mesh to create
  106318. * @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
  106319. * @param scene defines the hosting scene
  106320. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  106321. * @param updatable defines if the mesh must be flagged as updatable
  106322. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106323. * @param earcutInjection can be used to inject your own earcut reference
  106324. * @returns a new Mesh
  106325. */
  106326. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  106327. /**
  106328. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  106329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  106330. * @param name defines the name of the mesh to create
  106331. * @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
  106332. * @param depth defines the height of extrusion
  106333. * @param scene defines the hosting scene
  106334. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  106335. * @param updatable defines if the mesh must be flagged as updatable
  106336. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106337. * @param earcutInjection can be used to inject your own earcut reference
  106338. * @returns a new Mesh
  106339. */
  106340. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  106341. /**
  106342. * Creates an extruded shape mesh.
  106343. * 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
  106344. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106346. * @param name defines the name of the mesh to create
  106347. * @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
  106348. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  106349. * @param scale is the value to scale the shape
  106350. * @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
  106351. * @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
  106352. * @param scene defines the hosting scene
  106353. * @param updatable defines if the mesh must be flagged as updatable
  106354. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106355. * @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)
  106356. * @returns a new Mesh
  106357. */
  106358. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106359. /**
  106360. * Creates an custom extruded shape mesh.
  106361. * The custom extrusion is a parametric shape.
  106362. * It has no predefined shape. Its final shape will depend on the input parameters.
  106363. * Please consider using the same method from the MeshBuilder class instead
  106364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106365. * @param name defines the name of the mesh to create
  106366. * @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
  106367. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  106368. * @param scaleFunction is a custom Javascript function called on each path point
  106369. * @param rotationFunction is a custom Javascript function called on each path point
  106370. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106371. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  106372. * @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
  106373. * @param scene defines the hosting scene
  106374. * @param updatable defines if the mesh must be flagged as updatable
  106375. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106376. * @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)
  106377. * @returns a new Mesh
  106378. */
  106379. 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;
  106380. /**
  106381. * Creates lathe mesh.
  106382. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  106383. * Please consider using the same method from the MeshBuilder class instead
  106384. * @param name defines the name of the mesh to create
  106385. * @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
  106386. * @param radius is the radius value of the lathe
  106387. * @param tessellation is the side number of the lathe.
  106388. * @param scene defines the hosting scene
  106389. * @param updatable defines if the mesh must be flagged as updatable
  106390. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106391. * @returns a new Mesh
  106392. */
  106393. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106394. /**
  106395. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  106396. * @param name defines the name of the mesh to create
  106397. * @param size sets the size (float) of both sides of the plane at once (default 1)
  106398. * @param scene defines the hosting scene
  106399. * @param updatable defines if the mesh must be flagged as updatable
  106400. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106401. * @returns a new Mesh
  106402. */
  106403. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106404. /**
  106405. * Creates a ground mesh.
  106406. * Please consider using the same method from the MeshBuilder class instead
  106407. * @param name defines the name of the mesh to create
  106408. * @param width set the width of the ground
  106409. * @param height set the height of the ground
  106410. * @param subdivisions sets the number of subdivisions per side
  106411. * @param scene defines the hosting scene
  106412. * @param updatable defines if the mesh must be flagged as updatable
  106413. * @returns a new Mesh
  106414. */
  106415. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  106416. /**
  106417. * Creates a tiled ground mesh.
  106418. * Please consider using the same method from the MeshBuilder class instead
  106419. * @param name defines the name of the mesh to create
  106420. * @param xmin set the ground minimum X coordinate
  106421. * @param zmin set the ground minimum Y coordinate
  106422. * @param xmax set the ground maximum X coordinate
  106423. * @param zmax set the ground maximum Z coordinate
  106424. * @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
  106425. * @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
  106426. * @param scene defines the hosting scene
  106427. * @param updatable defines if the mesh must be flagged as updatable
  106428. * @returns a new Mesh
  106429. */
  106430. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  106431. w: number;
  106432. h: number;
  106433. }, precision: {
  106434. w: number;
  106435. h: number;
  106436. }, scene: Scene, updatable?: boolean): Mesh;
  106437. /**
  106438. * Creates a ground mesh from a height map.
  106439. * Please consider using the same method from the MeshBuilder class instead
  106440. * @see https://doc.babylonjs.com/babylon101/height_map
  106441. * @param name defines the name of the mesh to create
  106442. * @param url sets the URL of the height map image resource
  106443. * @param width set the ground width size
  106444. * @param height set the ground height size
  106445. * @param subdivisions sets the number of subdivision per side
  106446. * @param minHeight is the minimum altitude on the ground
  106447. * @param maxHeight is the maximum altitude on the ground
  106448. * @param scene defines the hosting scene
  106449. * @param updatable defines if the mesh must be flagged as updatable
  106450. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  106451. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106452. * @returns a new Mesh
  106453. */
  106454. 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;
  106455. /**
  106456. * Creates a tube mesh.
  106457. * The tube is a parametric shape.
  106458. * It has no predefined shape. Its final shape will depend on the input parameters.
  106459. * Please consider using the same method from the MeshBuilder class instead
  106460. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106461. * @param name defines the name of the mesh to create
  106462. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  106463. * @param radius sets the tube radius size
  106464. * @param tessellation is the number of sides on the tubular surface
  106465. * @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
  106466. * @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
  106467. * @param scene defines the hosting scene
  106468. * @param updatable defines if the mesh must be flagged as updatable
  106469. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106470. * @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)
  106471. * @returns a new Mesh
  106472. */
  106473. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  106474. (i: number, distance: number): number;
  106475. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106476. /**
  106477. * Creates a polyhedron mesh.
  106478. * Please consider using the same method from the MeshBuilder class instead.
  106479. * * 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
  106480. * * The parameter `size` (positive float, default 1) sets the polygon size
  106481. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106482. * * 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`
  106483. * * 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
  106484. * * 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)`)
  106485. * * 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
  106486. * * 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
  106487. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106488. * * 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
  106489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106490. * @param name defines the name of the mesh to create
  106491. * @param options defines the options used to create the mesh
  106492. * @param scene defines the hosting scene
  106493. * @returns a new Mesh
  106494. */
  106495. static CreatePolyhedron(name: string, options: {
  106496. type?: number;
  106497. size?: number;
  106498. sizeX?: number;
  106499. sizeY?: number;
  106500. sizeZ?: number;
  106501. custom?: any;
  106502. faceUV?: Vector4[];
  106503. faceColors?: Color4[];
  106504. updatable?: boolean;
  106505. sideOrientation?: number;
  106506. }, scene: Scene): Mesh;
  106507. /**
  106508. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106509. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106510. * * 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`)
  106511. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106512. * * 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
  106513. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106514. * * 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
  106515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106516. * @param name defines the name of the mesh
  106517. * @param options defines the options used to create the mesh
  106518. * @param scene defines the hosting scene
  106519. * @returns a new Mesh
  106520. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106521. */
  106522. static CreateIcoSphere(name: string, options: {
  106523. radius?: number;
  106524. flat?: boolean;
  106525. subdivisions?: number;
  106526. sideOrientation?: number;
  106527. updatable?: boolean;
  106528. }, scene: Scene): Mesh;
  106529. /**
  106530. * Creates a decal mesh.
  106531. * Please consider using the same method from the MeshBuilder class instead.
  106532. * A decal is a mesh usually applied as a model onto the surface of another mesh
  106533. * @param name defines the name of the mesh
  106534. * @param sourceMesh defines the mesh receiving the decal
  106535. * @param position sets the position of the decal in world coordinates
  106536. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  106537. * @param size sets the decal scaling
  106538. * @param angle sets the angle to rotate the decal
  106539. * @returns a new Mesh
  106540. */
  106541. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  106542. /**
  106543. * Prepare internal position array for software CPU skinning
  106544. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  106545. */
  106546. setPositionsForCPUSkinning(): Float32Array;
  106547. /**
  106548. * Prepare internal normal array for software CPU skinning
  106549. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  106550. */
  106551. setNormalsForCPUSkinning(): Float32Array;
  106552. /**
  106553. * Updates the vertex buffer by applying transformation from the bones
  106554. * @param skeleton defines the skeleton to apply to current mesh
  106555. * @returns the current mesh
  106556. */
  106557. applySkeleton(skeleton: Skeleton): Mesh;
  106558. /**
  106559. * 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
  106560. * @param meshes defines the list of meshes to scan
  106561. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  106562. */
  106563. static MinMax(meshes: AbstractMesh[]): {
  106564. min: Vector3;
  106565. max: Vector3;
  106566. };
  106567. /**
  106568. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  106569. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  106570. * @returns a vector3
  106571. */
  106572. static Center(meshesOrMinMaxVector: {
  106573. min: Vector3;
  106574. max: Vector3;
  106575. } | AbstractMesh[]): Vector3;
  106576. /**
  106577. * Merge the array of meshes into a single mesh for performance reasons.
  106578. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  106579. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  106580. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  106581. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  106582. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  106583. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  106584. * @returns a new mesh
  106585. */
  106586. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  106587. /** @hidden */
  106588. addInstance(instance: InstancedMesh): void;
  106589. /** @hidden */
  106590. removeInstance(instance: InstancedMesh): void;
  106591. }
  106592. }
  106593. declare module BABYLON {
  106594. /**
  106595. * This is the base class of all the camera used in the application.
  106596. * @see https://doc.babylonjs.com/features/cameras
  106597. */
  106598. export class Camera extends Node {
  106599. /** @hidden */
  106600. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  106601. /**
  106602. * This is the default projection mode used by the cameras.
  106603. * It helps recreating a feeling of perspective and better appreciate depth.
  106604. * This is the best way to simulate real life cameras.
  106605. */
  106606. static readonly PERSPECTIVE_CAMERA: number;
  106607. /**
  106608. * This helps creating camera with an orthographic mode.
  106609. * 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.
  106610. */
  106611. static readonly ORTHOGRAPHIC_CAMERA: number;
  106612. /**
  106613. * This is the default FOV mode for perspective cameras.
  106614. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  106615. */
  106616. static readonly FOVMODE_VERTICAL_FIXED: number;
  106617. /**
  106618. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  106619. */
  106620. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  106621. /**
  106622. * This specifies ther is no need for a camera rig.
  106623. * Basically only one eye is rendered corresponding to the camera.
  106624. */
  106625. static readonly RIG_MODE_NONE: number;
  106626. /**
  106627. * Simulates a camera Rig with one blue eye and one red eye.
  106628. * This can be use with 3d blue and red glasses.
  106629. */
  106630. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  106631. /**
  106632. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  106633. */
  106634. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  106635. /**
  106636. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  106637. */
  106638. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  106639. /**
  106640. * Defines that both eyes of the camera will be rendered over under each other.
  106641. */
  106642. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  106643. /**
  106644. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  106645. */
  106646. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  106647. /**
  106648. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  106649. */
  106650. static readonly RIG_MODE_VR: number;
  106651. /**
  106652. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  106653. */
  106654. static readonly RIG_MODE_WEBVR: number;
  106655. /**
  106656. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  106657. */
  106658. static readonly RIG_MODE_CUSTOM: number;
  106659. /**
  106660. * Defines if by default attaching controls should prevent the default javascript event to continue.
  106661. */
  106662. static ForceAttachControlToAlwaysPreventDefault: boolean;
  106663. /**
  106664. * Define the input manager associated with the camera.
  106665. */
  106666. inputs: CameraInputsManager<Camera>;
  106667. /** @hidden */
  106668. _position: Vector3;
  106669. /**
  106670. * Define the current local position of the camera in the scene
  106671. */
  106672. get position(): Vector3;
  106673. set position(newPosition: Vector3);
  106674. /**
  106675. * The vector the camera should consider as up.
  106676. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  106677. */
  106678. upVector: Vector3;
  106679. /**
  106680. * Define the current limit on the left side for an orthographic camera
  106681. * In scene unit
  106682. */
  106683. orthoLeft: Nullable<number>;
  106684. /**
  106685. * Define the current limit on the right side for an orthographic camera
  106686. * In scene unit
  106687. */
  106688. orthoRight: Nullable<number>;
  106689. /**
  106690. * Define the current limit on the bottom side for an orthographic camera
  106691. * In scene unit
  106692. */
  106693. orthoBottom: Nullable<number>;
  106694. /**
  106695. * Define the current limit on the top side for an orthographic camera
  106696. * In scene unit
  106697. */
  106698. orthoTop: Nullable<number>;
  106699. /**
  106700. * Field Of View is set in Radians. (default is 0.8)
  106701. */
  106702. fov: number;
  106703. /**
  106704. * Define the minimum distance the camera can see from.
  106705. * This is important to note that the depth buffer are not infinite and the closer it starts
  106706. * the more your scene might encounter depth fighting issue.
  106707. */
  106708. minZ: number;
  106709. /**
  106710. * Define the maximum distance the camera can see to.
  106711. * This is important to note that the depth buffer are not infinite and the further it end
  106712. * the more your scene might encounter depth fighting issue.
  106713. */
  106714. maxZ: number;
  106715. /**
  106716. * Define the default inertia of the camera.
  106717. * This helps giving a smooth feeling to the camera movement.
  106718. */
  106719. inertia: number;
  106720. /**
  106721. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  106722. */
  106723. mode: number;
  106724. /**
  106725. * Define whether the camera is intermediate.
  106726. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  106727. */
  106728. isIntermediate: boolean;
  106729. /**
  106730. * Define the viewport of the camera.
  106731. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  106732. */
  106733. viewport: Viewport;
  106734. /**
  106735. * Restricts the camera to viewing objects with the same layerMask.
  106736. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  106737. */
  106738. layerMask: number;
  106739. /**
  106740. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  106741. */
  106742. fovMode: number;
  106743. /**
  106744. * Rig mode of the camera.
  106745. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  106746. * This is normally controlled byt the camera themselves as internal use.
  106747. */
  106748. cameraRigMode: number;
  106749. /**
  106750. * Defines the distance between both "eyes" in case of a RIG
  106751. */
  106752. interaxialDistance: number;
  106753. /**
  106754. * Defines if stereoscopic rendering is done side by side or over under.
  106755. */
  106756. isStereoscopicSideBySide: boolean;
  106757. /**
  106758. * 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
  106759. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  106760. * else in the scene. (Eg. security camera)
  106761. *
  106762. * 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)
  106763. */
  106764. customRenderTargets: RenderTargetTexture[];
  106765. /**
  106766. * When set, the camera will render to this render target instead of the default canvas
  106767. *
  106768. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  106769. */
  106770. outputRenderTarget: Nullable<RenderTargetTexture>;
  106771. /**
  106772. * Observable triggered when the camera view matrix has changed.
  106773. */
  106774. onViewMatrixChangedObservable: Observable<Camera>;
  106775. /**
  106776. * Observable triggered when the camera Projection matrix has changed.
  106777. */
  106778. onProjectionMatrixChangedObservable: Observable<Camera>;
  106779. /**
  106780. * Observable triggered when the inputs have been processed.
  106781. */
  106782. onAfterCheckInputsObservable: Observable<Camera>;
  106783. /**
  106784. * Observable triggered when reset has been called and applied to the camera.
  106785. */
  106786. onRestoreStateObservable: Observable<Camera>;
  106787. /**
  106788. * Is this camera a part of a rig system?
  106789. */
  106790. isRigCamera: boolean;
  106791. /**
  106792. * If isRigCamera set to true this will be set with the parent camera.
  106793. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  106794. */
  106795. rigParent?: Camera;
  106796. /** @hidden */
  106797. _cameraRigParams: any;
  106798. /** @hidden */
  106799. _rigCameras: Camera[];
  106800. /** @hidden */
  106801. _rigPostProcess: Nullable<PostProcess>;
  106802. protected _webvrViewMatrix: Matrix;
  106803. /** @hidden */
  106804. _skipRendering: boolean;
  106805. /** @hidden */
  106806. _projectionMatrix: Matrix;
  106807. /** @hidden */
  106808. _postProcesses: Nullable<PostProcess>[];
  106809. /** @hidden */
  106810. _activeMeshes: SmartArray<AbstractMesh>;
  106811. protected _globalPosition: Vector3;
  106812. /** @hidden */
  106813. _computedViewMatrix: Matrix;
  106814. private _doNotComputeProjectionMatrix;
  106815. private _transformMatrix;
  106816. private _frustumPlanes;
  106817. private _refreshFrustumPlanes;
  106818. private _storedFov;
  106819. private _stateStored;
  106820. /**
  106821. * Instantiates a new camera object.
  106822. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  106823. * @see https://doc.babylonjs.com/features/cameras
  106824. * @param name Defines the name of the camera in the scene
  106825. * @param position Defines the position of the camera
  106826. * @param scene Defines the scene the camera belongs too
  106827. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  106828. */
  106829. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106830. /**
  106831. * Store current camera state (fov, position, etc..)
  106832. * @returns the camera
  106833. */
  106834. storeState(): Camera;
  106835. /**
  106836. * Restores the camera state values if it has been stored. You must call storeState() first
  106837. */
  106838. protected _restoreStateValues(): boolean;
  106839. /**
  106840. * Restored camera state. You must call storeState() first.
  106841. * @returns true if restored and false otherwise
  106842. */
  106843. restoreState(): boolean;
  106844. /**
  106845. * Gets the class name of the camera.
  106846. * @returns the class name
  106847. */
  106848. getClassName(): string;
  106849. /** @hidden */
  106850. readonly _isCamera: boolean;
  106851. /**
  106852. * Gets a string representation of the camera useful for debug purpose.
  106853. * @param fullDetails Defines that a more verboe level of logging is required
  106854. * @returns the string representation
  106855. */
  106856. toString(fullDetails?: boolean): string;
  106857. /**
  106858. * Gets the current world space position of the camera.
  106859. */
  106860. get globalPosition(): Vector3;
  106861. /**
  106862. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  106863. * @returns the active meshe list
  106864. */
  106865. getActiveMeshes(): SmartArray<AbstractMesh>;
  106866. /**
  106867. * Check whether a mesh is part of the current active mesh list of the camera
  106868. * @param mesh Defines the mesh to check
  106869. * @returns true if active, false otherwise
  106870. */
  106871. isActiveMesh(mesh: Mesh): boolean;
  106872. /**
  106873. * Is this camera ready to be used/rendered
  106874. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  106875. * @return true if the camera is ready
  106876. */
  106877. isReady(completeCheck?: boolean): boolean;
  106878. /** @hidden */
  106879. _initCache(): void;
  106880. /** @hidden */
  106881. _updateCache(ignoreParentClass?: boolean): void;
  106882. /** @hidden */
  106883. _isSynchronized(): boolean;
  106884. /** @hidden */
  106885. _isSynchronizedViewMatrix(): boolean;
  106886. /** @hidden */
  106887. _isSynchronizedProjectionMatrix(): boolean;
  106888. /**
  106889. * Attach the input controls to a specific dom element to get the input from.
  106890. * @param element Defines the element the controls should be listened from
  106891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106892. */
  106893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106894. /**
  106895. * Detach the current controls from the specified dom element.
  106896. * @param element Defines the element to stop listening the inputs from
  106897. */
  106898. detachControl(element: HTMLElement): void;
  106899. /**
  106900. * Update the camera state according to the different inputs gathered during the frame.
  106901. */
  106902. update(): void;
  106903. /** @hidden */
  106904. _checkInputs(): void;
  106905. /** @hidden */
  106906. get rigCameras(): Camera[];
  106907. /**
  106908. * Gets the post process used by the rig cameras
  106909. */
  106910. get rigPostProcess(): Nullable<PostProcess>;
  106911. /**
  106912. * Internal, gets the first post proces.
  106913. * @returns the first post process to be run on this camera.
  106914. */
  106915. _getFirstPostProcess(): Nullable<PostProcess>;
  106916. private _cascadePostProcessesToRigCams;
  106917. /**
  106918. * Attach a post process to the camera.
  106919. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106920. * @param postProcess The post process to attach to the camera
  106921. * @param insertAt The position of the post process in case several of them are in use in the scene
  106922. * @returns the position the post process has been inserted at
  106923. */
  106924. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  106925. /**
  106926. * Detach a post process to the camera.
  106927. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106928. * @param postProcess The post process to detach from the camera
  106929. */
  106930. detachPostProcess(postProcess: PostProcess): void;
  106931. /**
  106932. * Gets the current world matrix of the camera
  106933. */
  106934. getWorldMatrix(): Matrix;
  106935. /** @hidden */
  106936. _getViewMatrix(): Matrix;
  106937. /**
  106938. * Gets the current view matrix of the camera.
  106939. * @param force forces the camera to recompute the matrix without looking at the cached state
  106940. * @returns the view matrix
  106941. */
  106942. getViewMatrix(force?: boolean): Matrix;
  106943. /**
  106944. * Freeze the projection matrix.
  106945. * It will prevent the cache check of the camera projection compute and can speed up perf
  106946. * if no parameter of the camera are meant to change
  106947. * @param projection Defines manually a projection if necessary
  106948. */
  106949. freezeProjectionMatrix(projection?: Matrix): void;
  106950. /**
  106951. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  106952. */
  106953. unfreezeProjectionMatrix(): void;
  106954. /**
  106955. * Gets the current projection matrix of the camera.
  106956. * @param force forces the camera to recompute the matrix without looking at the cached state
  106957. * @returns the projection matrix
  106958. */
  106959. getProjectionMatrix(force?: boolean): Matrix;
  106960. /**
  106961. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  106962. * @returns a Matrix
  106963. */
  106964. getTransformationMatrix(): Matrix;
  106965. private _updateFrustumPlanes;
  106966. /**
  106967. * Checks if a cullable object (mesh...) is in the camera frustum
  106968. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  106969. * @param target The object to check
  106970. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  106971. * @returns true if the object is in frustum otherwise false
  106972. */
  106973. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  106974. /**
  106975. * Checks if a cullable object (mesh...) is in the camera frustum
  106976. * Unlike isInFrustum this cheks the full bounding box
  106977. * @param target The object to check
  106978. * @returns true if the object is in frustum otherwise false
  106979. */
  106980. isCompletelyInFrustum(target: ICullable): boolean;
  106981. /**
  106982. * Gets a ray in the forward direction from the camera.
  106983. * @param length Defines the length of the ray to create
  106984. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  106985. * @param origin Defines the start point of the ray which defaults to the camera position
  106986. * @returns the forward ray
  106987. */
  106988. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  106989. /**
  106990. * Releases resources associated with this node.
  106991. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106992. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106993. */
  106994. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106995. /** @hidden */
  106996. _isLeftCamera: boolean;
  106997. /**
  106998. * Gets the left camera of a rig setup in case of Rigged Camera
  106999. */
  107000. get isLeftCamera(): boolean;
  107001. /** @hidden */
  107002. _isRightCamera: boolean;
  107003. /**
  107004. * Gets the right camera of a rig setup in case of Rigged Camera
  107005. */
  107006. get isRightCamera(): boolean;
  107007. /**
  107008. * Gets the left camera of a rig setup in case of Rigged Camera
  107009. */
  107010. get leftCamera(): Nullable<FreeCamera>;
  107011. /**
  107012. * Gets the right camera of a rig setup in case of Rigged Camera
  107013. */
  107014. get rightCamera(): Nullable<FreeCamera>;
  107015. /**
  107016. * Gets the left camera target of a rig setup in case of Rigged Camera
  107017. * @returns the target position
  107018. */
  107019. getLeftTarget(): Nullable<Vector3>;
  107020. /**
  107021. * Gets the right camera target of a rig setup in case of Rigged Camera
  107022. * @returns the target position
  107023. */
  107024. getRightTarget(): Nullable<Vector3>;
  107025. /**
  107026. * @hidden
  107027. */
  107028. setCameraRigMode(mode: number, rigParams: any): void;
  107029. /** @hidden */
  107030. static _setStereoscopicRigMode(camera: Camera): void;
  107031. /** @hidden */
  107032. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  107033. /** @hidden */
  107034. static _setVRRigMode(camera: Camera, rigParams: any): void;
  107035. /** @hidden */
  107036. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  107037. /** @hidden */
  107038. _getVRProjectionMatrix(): Matrix;
  107039. protected _updateCameraRotationMatrix(): void;
  107040. protected _updateWebVRCameraRotationMatrix(): void;
  107041. /**
  107042. * This function MUST be overwritten by the different WebVR cameras available.
  107043. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  107044. * @hidden
  107045. */
  107046. _getWebVRProjectionMatrix(): Matrix;
  107047. /**
  107048. * This function MUST be overwritten by the different WebVR cameras available.
  107049. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  107050. * @hidden
  107051. */
  107052. _getWebVRViewMatrix(): Matrix;
  107053. /** @hidden */
  107054. setCameraRigParameter(name: string, value: any): void;
  107055. /**
  107056. * needs to be overridden by children so sub has required properties to be copied
  107057. * @hidden
  107058. */
  107059. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  107060. /**
  107061. * May need to be overridden by children
  107062. * @hidden
  107063. */
  107064. _updateRigCameras(): void;
  107065. /** @hidden */
  107066. _setupInputs(): void;
  107067. /**
  107068. * Serialiaze the camera setup to a json represention
  107069. * @returns the JSON representation
  107070. */
  107071. serialize(): any;
  107072. /**
  107073. * Clones the current camera.
  107074. * @param name The cloned camera name
  107075. * @returns the cloned camera
  107076. */
  107077. clone(name: string): Camera;
  107078. /**
  107079. * Gets the direction of the camera relative to a given local axis.
  107080. * @param localAxis Defines the reference axis to provide a relative direction.
  107081. * @return the direction
  107082. */
  107083. getDirection(localAxis: Vector3): Vector3;
  107084. /**
  107085. * Returns the current camera absolute rotation
  107086. */
  107087. get absoluteRotation(): Quaternion;
  107088. /**
  107089. * Gets the direction of the camera relative to a given local axis into a passed vector.
  107090. * @param localAxis Defines the reference axis to provide a relative direction.
  107091. * @param result Defines the vector to store the result in
  107092. */
  107093. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  107094. /**
  107095. * Gets a camera constructor for a given camera type
  107096. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  107097. * @param name The name of the camera the result will be able to instantiate
  107098. * @param scene The scene the result will construct the camera in
  107099. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  107100. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  107101. * @returns a factory method to construc the camera
  107102. */
  107103. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  107104. /**
  107105. * Compute the world matrix of the camera.
  107106. * @returns the camera world matrix
  107107. */
  107108. computeWorldMatrix(): Matrix;
  107109. /**
  107110. * Parse a JSON and creates the camera from the parsed information
  107111. * @param parsedCamera The JSON to parse
  107112. * @param scene The scene to instantiate the camera in
  107113. * @returns the newly constructed camera
  107114. */
  107115. static Parse(parsedCamera: any, scene: Scene): Camera;
  107116. }
  107117. }
  107118. declare module BABYLON {
  107119. /**
  107120. * Class containing static functions to help procedurally build meshes
  107121. */
  107122. export class DiscBuilder {
  107123. /**
  107124. * Creates a plane polygonal mesh. By default, this is a disc
  107125. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107126. * * 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
  107127. * * 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
  107128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107129. * * 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
  107130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107131. * @param name defines the name of the mesh
  107132. * @param options defines the options used to create the mesh
  107133. * @param scene defines the hosting scene
  107134. * @returns the plane polygonal mesh
  107135. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107136. */
  107137. static CreateDisc(name: string, options: {
  107138. radius?: number;
  107139. tessellation?: number;
  107140. arc?: number;
  107141. updatable?: boolean;
  107142. sideOrientation?: number;
  107143. frontUVs?: Vector4;
  107144. backUVs?: Vector4;
  107145. }, scene?: Nullable<Scene>): Mesh;
  107146. }
  107147. }
  107148. declare module BABYLON {
  107149. /**
  107150. * Options to be used when creating a FresnelParameters.
  107151. */
  107152. export type IFresnelParametersCreationOptions = {
  107153. /**
  107154. * Define the color used on edges (grazing angle)
  107155. */
  107156. leftColor?: Color3;
  107157. /**
  107158. * Define the color used on center
  107159. */
  107160. rightColor?: Color3;
  107161. /**
  107162. * Define bias applied to computed fresnel term
  107163. */
  107164. bias?: number;
  107165. /**
  107166. * Defined the power exponent applied to fresnel term
  107167. */
  107168. power?: number;
  107169. /**
  107170. * Define if the fresnel effect is enable or not.
  107171. */
  107172. isEnabled?: boolean;
  107173. };
  107174. /**
  107175. * Serialized format for FresnelParameters.
  107176. */
  107177. export type IFresnelParametersSerialized = {
  107178. /**
  107179. * Define the color used on edges (grazing angle) [as an array]
  107180. */
  107181. leftColor: number[];
  107182. /**
  107183. * Define the color used on center [as an array]
  107184. */
  107185. rightColor: number[];
  107186. /**
  107187. * Define bias applied to computed fresnel term
  107188. */
  107189. bias: number;
  107190. /**
  107191. * Defined the power exponent applied to fresnel term
  107192. */
  107193. power?: number;
  107194. /**
  107195. * Define if the fresnel effect is enable or not.
  107196. */
  107197. isEnabled: boolean;
  107198. };
  107199. /**
  107200. * This represents all the required information to add a fresnel effect on a material:
  107201. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107202. */
  107203. export class FresnelParameters {
  107204. private _isEnabled;
  107205. /**
  107206. * Define if the fresnel effect is enable or not.
  107207. */
  107208. get isEnabled(): boolean;
  107209. set isEnabled(value: boolean);
  107210. /**
  107211. * Define the color used on edges (grazing angle)
  107212. */
  107213. leftColor: Color3;
  107214. /**
  107215. * Define the color used on center
  107216. */
  107217. rightColor: Color3;
  107218. /**
  107219. * Define bias applied to computed fresnel term
  107220. */
  107221. bias: number;
  107222. /**
  107223. * Defined the power exponent applied to fresnel term
  107224. */
  107225. power: number;
  107226. /**
  107227. * Creates a new FresnelParameters object.
  107228. *
  107229. * @param options provide your own settings to optionally to override defaults
  107230. */
  107231. constructor(options?: IFresnelParametersCreationOptions);
  107232. /**
  107233. * Clones the current fresnel and its valuues
  107234. * @returns a clone fresnel configuration
  107235. */
  107236. clone(): FresnelParameters;
  107237. /**
  107238. * Determines equality between FresnelParameters objects
  107239. * @param otherFresnelParameters defines the second operand
  107240. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  107241. */
  107242. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  107243. /**
  107244. * Serializes the current fresnel parameters to a JSON representation.
  107245. * @return the JSON serialization
  107246. */
  107247. serialize(): IFresnelParametersSerialized;
  107248. /**
  107249. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  107250. * @param parsedFresnelParameters Define the JSON representation
  107251. * @returns the parsed parameters
  107252. */
  107253. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  107254. }
  107255. }
  107256. declare module BABYLON {
  107257. /**
  107258. * This groups all the flags used to control the materials channel.
  107259. */
  107260. export class MaterialFlags {
  107261. private static _DiffuseTextureEnabled;
  107262. /**
  107263. * Are diffuse textures enabled in the application.
  107264. */
  107265. static get DiffuseTextureEnabled(): boolean;
  107266. static set DiffuseTextureEnabled(value: boolean);
  107267. private static _DetailTextureEnabled;
  107268. /**
  107269. * Are detail textures enabled in the application.
  107270. */
  107271. static get DetailTextureEnabled(): boolean;
  107272. static set DetailTextureEnabled(value: boolean);
  107273. private static _AmbientTextureEnabled;
  107274. /**
  107275. * Are ambient textures enabled in the application.
  107276. */
  107277. static get AmbientTextureEnabled(): boolean;
  107278. static set AmbientTextureEnabled(value: boolean);
  107279. private static _OpacityTextureEnabled;
  107280. /**
  107281. * Are opacity textures enabled in the application.
  107282. */
  107283. static get OpacityTextureEnabled(): boolean;
  107284. static set OpacityTextureEnabled(value: boolean);
  107285. private static _ReflectionTextureEnabled;
  107286. /**
  107287. * Are reflection textures enabled in the application.
  107288. */
  107289. static get ReflectionTextureEnabled(): boolean;
  107290. static set ReflectionTextureEnabled(value: boolean);
  107291. private static _EmissiveTextureEnabled;
  107292. /**
  107293. * Are emissive textures enabled in the application.
  107294. */
  107295. static get EmissiveTextureEnabled(): boolean;
  107296. static set EmissiveTextureEnabled(value: boolean);
  107297. private static _SpecularTextureEnabled;
  107298. /**
  107299. * Are specular textures enabled in the application.
  107300. */
  107301. static get SpecularTextureEnabled(): boolean;
  107302. static set SpecularTextureEnabled(value: boolean);
  107303. private static _BumpTextureEnabled;
  107304. /**
  107305. * Are bump textures enabled in the application.
  107306. */
  107307. static get BumpTextureEnabled(): boolean;
  107308. static set BumpTextureEnabled(value: boolean);
  107309. private static _LightmapTextureEnabled;
  107310. /**
  107311. * Are lightmap textures enabled in the application.
  107312. */
  107313. static get LightmapTextureEnabled(): boolean;
  107314. static set LightmapTextureEnabled(value: boolean);
  107315. private static _RefractionTextureEnabled;
  107316. /**
  107317. * Are refraction textures enabled in the application.
  107318. */
  107319. static get RefractionTextureEnabled(): boolean;
  107320. static set RefractionTextureEnabled(value: boolean);
  107321. private static _ColorGradingTextureEnabled;
  107322. /**
  107323. * Are color grading textures enabled in the application.
  107324. */
  107325. static get ColorGradingTextureEnabled(): boolean;
  107326. static set ColorGradingTextureEnabled(value: boolean);
  107327. private static _FresnelEnabled;
  107328. /**
  107329. * Are fresnels enabled in the application.
  107330. */
  107331. static get FresnelEnabled(): boolean;
  107332. static set FresnelEnabled(value: boolean);
  107333. private static _ClearCoatTextureEnabled;
  107334. /**
  107335. * Are clear coat textures enabled in the application.
  107336. */
  107337. static get ClearCoatTextureEnabled(): boolean;
  107338. static set ClearCoatTextureEnabled(value: boolean);
  107339. private static _ClearCoatBumpTextureEnabled;
  107340. /**
  107341. * Are clear coat bump textures enabled in the application.
  107342. */
  107343. static get ClearCoatBumpTextureEnabled(): boolean;
  107344. static set ClearCoatBumpTextureEnabled(value: boolean);
  107345. private static _ClearCoatTintTextureEnabled;
  107346. /**
  107347. * Are clear coat tint textures enabled in the application.
  107348. */
  107349. static get ClearCoatTintTextureEnabled(): boolean;
  107350. static set ClearCoatTintTextureEnabled(value: boolean);
  107351. private static _SheenTextureEnabled;
  107352. /**
  107353. * Are sheen textures enabled in the application.
  107354. */
  107355. static get SheenTextureEnabled(): boolean;
  107356. static set SheenTextureEnabled(value: boolean);
  107357. private static _AnisotropicTextureEnabled;
  107358. /**
  107359. * Are anisotropic textures enabled in the application.
  107360. */
  107361. static get AnisotropicTextureEnabled(): boolean;
  107362. static set AnisotropicTextureEnabled(value: boolean);
  107363. private static _ThicknessTextureEnabled;
  107364. /**
  107365. * Are thickness textures enabled in the application.
  107366. */
  107367. static get ThicknessTextureEnabled(): boolean;
  107368. static set ThicknessTextureEnabled(value: boolean);
  107369. }
  107370. }
  107371. declare module BABYLON {
  107372. /** @hidden */
  107373. export var defaultFragmentDeclaration: {
  107374. name: string;
  107375. shader: string;
  107376. };
  107377. }
  107378. declare module BABYLON {
  107379. /** @hidden */
  107380. export var defaultUboDeclaration: {
  107381. name: string;
  107382. shader: string;
  107383. };
  107384. }
  107385. declare module BABYLON {
  107386. /** @hidden */
  107387. export var lightFragmentDeclaration: {
  107388. name: string;
  107389. shader: string;
  107390. };
  107391. }
  107392. declare module BABYLON {
  107393. /** @hidden */
  107394. export var lightUboDeclaration: {
  107395. name: string;
  107396. shader: string;
  107397. };
  107398. }
  107399. declare module BABYLON {
  107400. /** @hidden */
  107401. export var lightsFragmentFunctions: {
  107402. name: string;
  107403. shader: string;
  107404. };
  107405. }
  107406. declare module BABYLON {
  107407. /** @hidden */
  107408. export var shadowsFragmentFunctions: {
  107409. name: string;
  107410. shader: string;
  107411. };
  107412. }
  107413. declare module BABYLON {
  107414. /** @hidden */
  107415. export var fresnelFunction: {
  107416. name: string;
  107417. shader: string;
  107418. };
  107419. }
  107420. declare module BABYLON {
  107421. /** @hidden */
  107422. export var bumpFragmentMainFunctions: {
  107423. name: string;
  107424. shader: string;
  107425. };
  107426. }
  107427. declare module BABYLON {
  107428. /** @hidden */
  107429. export var bumpFragmentFunctions: {
  107430. name: string;
  107431. shader: string;
  107432. };
  107433. }
  107434. declare module BABYLON {
  107435. /** @hidden */
  107436. export var logDepthDeclaration: {
  107437. name: string;
  107438. shader: string;
  107439. };
  107440. }
  107441. declare module BABYLON {
  107442. /** @hidden */
  107443. export var bumpFragment: {
  107444. name: string;
  107445. shader: string;
  107446. };
  107447. }
  107448. declare module BABYLON {
  107449. /** @hidden */
  107450. export var depthPrePass: {
  107451. name: string;
  107452. shader: string;
  107453. };
  107454. }
  107455. declare module BABYLON {
  107456. /** @hidden */
  107457. export var lightFragment: {
  107458. name: string;
  107459. shader: string;
  107460. };
  107461. }
  107462. declare module BABYLON {
  107463. /** @hidden */
  107464. export var logDepthFragment: {
  107465. name: string;
  107466. shader: string;
  107467. };
  107468. }
  107469. declare module BABYLON {
  107470. /** @hidden */
  107471. export var defaultPixelShader: {
  107472. name: string;
  107473. shader: string;
  107474. };
  107475. }
  107476. declare module BABYLON {
  107477. /** @hidden */
  107478. export var defaultVertexDeclaration: {
  107479. name: string;
  107480. shader: string;
  107481. };
  107482. }
  107483. declare module BABYLON {
  107484. /** @hidden */
  107485. export var bumpVertexDeclaration: {
  107486. name: string;
  107487. shader: string;
  107488. };
  107489. }
  107490. declare module BABYLON {
  107491. /** @hidden */
  107492. export var bumpVertex: {
  107493. name: string;
  107494. shader: string;
  107495. };
  107496. }
  107497. declare module BABYLON {
  107498. /** @hidden */
  107499. export var fogVertex: {
  107500. name: string;
  107501. shader: string;
  107502. };
  107503. }
  107504. declare module BABYLON {
  107505. /** @hidden */
  107506. export var shadowsVertex: {
  107507. name: string;
  107508. shader: string;
  107509. };
  107510. }
  107511. declare module BABYLON {
  107512. /** @hidden */
  107513. export var pointCloudVertex: {
  107514. name: string;
  107515. shader: string;
  107516. };
  107517. }
  107518. declare module BABYLON {
  107519. /** @hidden */
  107520. export var logDepthVertex: {
  107521. name: string;
  107522. shader: string;
  107523. };
  107524. }
  107525. declare module BABYLON {
  107526. /** @hidden */
  107527. export var defaultVertexShader: {
  107528. name: string;
  107529. shader: string;
  107530. };
  107531. }
  107532. declare module BABYLON {
  107533. /**
  107534. * @hidden
  107535. */
  107536. export interface IMaterialDetailMapDefines {
  107537. DETAIL: boolean;
  107538. DETAILDIRECTUV: number;
  107539. DETAIL_NORMALBLENDMETHOD: number;
  107540. /** @hidden */
  107541. _areTexturesDirty: boolean;
  107542. }
  107543. /**
  107544. * Define the code related to the detail map parameters of a material
  107545. *
  107546. * Inspired from:
  107547. * 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
  107548. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  107549. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  107550. */
  107551. export class DetailMapConfiguration {
  107552. private _texture;
  107553. /**
  107554. * The detail texture of the material.
  107555. */
  107556. texture: Nullable<BaseTexture>;
  107557. /**
  107558. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  107559. * Bigger values mean stronger blending
  107560. */
  107561. diffuseBlendLevel: number;
  107562. /**
  107563. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  107564. * Bigger values mean stronger blending. Only used with PBR materials
  107565. */
  107566. roughnessBlendLevel: number;
  107567. /**
  107568. * Defines how strong the bump effect from the detail map is
  107569. * Bigger values mean stronger effect
  107570. */
  107571. bumpLevel: number;
  107572. private _normalBlendMethod;
  107573. /**
  107574. * The method used to blend the bump and detail normals together
  107575. */
  107576. normalBlendMethod: number;
  107577. private _isEnabled;
  107578. /**
  107579. * Enable or disable the detail map on this material
  107580. */
  107581. isEnabled: boolean;
  107582. /** @hidden */
  107583. private _internalMarkAllSubMeshesAsTexturesDirty;
  107584. /** @hidden */
  107585. _markAllSubMeshesAsTexturesDirty(): void;
  107586. /**
  107587. * Instantiate a new detail map
  107588. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107589. */
  107590. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107591. /**
  107592. * Gets whether the submesh is ready to be used or not.
  107593. * @param defines the list of "defines" to update.
  107594. * @param scene defines the scene the material belongs to.
  107595. * @returns - boolean indicating that the submesh is ready or not.
  107596. */
  107597. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  107598. /**
  107599. * Update the defines for detail map usage
  107600. * @param defines the list of "defines" to update.
  107601. * @param scene defines the scene the material belongs to.
  107602. */
  107603. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  107604. /**
  107605. * Binds the material data.
  107606. * @param uniformBuffer defines the Uniform buffer to fill in.
  107607. * @param scene defines the scene the material belongs to.
  107608. * @param isFrozen defines whether the material is frozen or not.
  107609. */
  107610. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107611. /**
  107612. * Checks to see if a texture is used in the material.
  107613. * @param texture - Base texture to use.
  107614. * @returns - Boolean specifying if a texture is used in the material.
  107615. */
  107616. hasTexture(texture: BaseTexture): boolean;
  107617. /**
  107618. * Returns an array of the actively used textures.
  107619. * @param activeTextures Array of BaseTextures
  107620. */
  107621. getActiveTextures(activeTextures: BaseTexture[]): void;
  107622. /**
  107623. * Returns the animatable textures.
  107624. * @param animatables Array of animatable textures.
  107625. */
  107626. getAnimatables(animatables: IAnimatable[]): void;
  107627. /**
  107628. * Disposes the resources of the material.
  107629. * @param forceDisposeTextures - Forces the disposal of all textures.
  107630. */
  107631. dispose(forceDisposeTextures?: boolean): void;
  107632. /**
  107633. * Get the current class name useful for serialization or dynamic coding.
  107634. * @returns "DetailMap"
  107635. */
  107636. getClassName(): string;
  107637. /**
  107638. * Add the required uniforms to the current list.
  107639. * @param uniforms defines the current uniform list.
  107640. */
  107641. static AddUniforms(uniforms: string[]): void;
  107642. /**
  107643. * Add the required samplers to the current list.
  107644. * @param samplers defines the current sampler list.
  107645. */
  107646. static AddSamplers(samplers: string[]): void;
  107647. /**
  107648. * Add the required uniforms to the current buffer.
  107649. * @param uniformBuffer defines the current uniform buffer.
  107650. */
  107651. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107652. /**
  107653. * Makes a duplicate of the current instance into another one.
  107654. * @param detailMap define the instance where to copy the info
  107655. */
  107656. copyTo(detailMap: DetailMapConfiguration): void;
  107657. /**
  107658. * Serializes this detail map instance
  107659. * @returns - An object with the serialized instance.
  107660. */
  107661. serialize(): any;
  107662. /**
  107663. * Parses a detail map setting from a serialized object.
  107664. * @param source - Serialized object.
  107665. * @param scene Defines the scene we are parsing for
  107666. * @param rootUrl Defines the rootUrl to load from
  107667. */
  107668. parse(source: any, scene: Scene, rootUrl: string): void;
  107669. }
  107670. }
  107671. declare module BABYLON {
  107672. /** @hidden */
  107673. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  107674. MAINUV1: boolean;
  107675. MAINUV2: boolean;
  107676. DIFFUSE: boolean;
  107677. DIFFUSEDIRECTUV: number;
  107678. DETAIL: boolean;
  107679. DETAILDIRECTUV: number;
  107680. DETAIL_NORMALBLENDMETHOD: number;
  107681. AMBIENT: boolean;
  107682. AMBIENTDIRECTUV: number;
  107683. OPACITY: boolean;
  107684. OPACITYDIRECTUV: number;
  107685. OPACITYRGB: boolean;
  107686. REFLECTION: boolean;
  107687. EMISSIVE: boolean;
  107688. EMISSIVEDIRECTUV: number;
  107689. SPECULAR: boolean;
  107690. SPECULARDIRECTUV: number;
  107691. BUMP: boolean;
  107692. BUMPDIRECTUV: number;
  107693. PARALLAX: boolean;
  107694. PARALLAXOCCLUSION: boolean;
  107695. SPECULAROVERALPHA: boolean;
  107696. CLIPPLANE: boolean;
  107697. CLIPPLANE2: boolean;
  107698. CLIPPLANE3: boolean;
  107699. CLIPPLANE4: boolean;
  107700. CLIPPLANE5: boolean;
  107701. CLIPPLANE6: boolean;
  107702. ALPHATEST: boolean;
  107703. DEPTHPREPASS: boolean;
  107704. ALPHAFROMDIFFUSE: boolean;
  107705. POINTSIZE: boolean;
  107706. FOG: boolean;
  107707. SPECULARTERM: boolean;
  107708. DIFFUSEFRESNEL: boolean;
  107709. OPACITYFRESNEL: boolean;
  107710. REFLECTIONFRESNEL: boolean;
  107711. REFRACTIONFRESNEL: boolean;
  107712. EMISSIVEFRESNEL: boolean;
  107713. FRESNEL: boolean;
  107714. NORMAL: boolean;
  107715. UV1: boolean;
  107716. UV2: boolean;
  107717. VERTEXCOLOR: boolean;
  107718. VERTEXALPHA: boolean;
  107719. NUM_BONE_INFLUENCERS: number;
  107720. BonesPerMesh: number;
  107721. BONETEXTURE: boolean;
  107722. INSTANCES: boolean;
  107723. THIN_INSTANCES: boolean;
  107724. GLOSSINESS: boolean;
  107725. ROUGHNESS: boolean;
  107726. EMISSIVEASILLUMINATION: boolean;
  107727. LINKEMISSIVEWITHDIFFUSE: boolean;
  107728. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107729. LIGHTMAP: boolean;
  107730. LIGHTMAPDIRECTUV: number;
  107731. OBJECTSPACE_NORMALMAP: boolean;
  107732. USELIGHTMAPASSHADOWMAP: boolean;
  107733. REFLECTIONMAP_3D: boolean;
  107734. REFLECTIONMAP_SPHERICAL: boolean;
  107735. REFLECTIONMAP_PLANAR: boolean;
  107736. REFLECTIONMAP_CUBIC: boolean;
  107737. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107738. REFLECTIONMAP_PROJECTION: boolean;
  107739. REFLECTIONMAP_SKYBOX: boolean;
  107740. REFLECTIONMAP_EXPLICIT: boolean;
  107741. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107742. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107743. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107744. INVERTCUBICMAP: boolean;
  107745. LOGARITHMICDEPTH: boolean;
  107746. REFRACTION: boolean;
  107747. REFRACTIONMAP_3D: boolean;
  107748. REFLECTIONOVERALPHA: boolean;
  107749. TWOSIDEDLIGHTING: boolean;
  107750. SHADOWFLOAT: boolean;
  107751. MORPHTARGETS: boolean;
  107752. MORPHTARGETS_NORMAL: boolean;
  107753. MORPHTARGETS_TANGENT: boolean;
  107754. MORPHTARGETS_UV: boolean;
  107755. NUM_MORPH_INFLUENCERS: number;
  107756. NONUNIFORMSCALING: boolean;
  107757. PREMULTIPLYALPHA: boolean;
  107758. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  107759. ALPHABLEND: boolean;
  107760. PREPASS: boolean;
  107761. SCENE_MRT_COUNT: number;
  107762. RGBDLIGHTMAP: boolean;
  107763. RGBDREFLECTION: boolean;
  107764. RGBDREFRACTION: boolean;
  107765. IMAGEPROCESSING: boolean;
  107766. VIGNETTE: boolean;
  107767. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107768. VIGNETTEBLENDMODEOPAQUE: boolean;
  107769. TONEMAPPING: boolean;
  107770. TONEMAPPING_ACES: boolean;
  107771. CONTRAST: boolean;
  107772. COLORCURVES: boolean;
  107773. COLORGRADING: boolean;
  107774. COLORGRADING3D: boolean;
  107775. SAMPLER3DGREENDEPTH: boolean;
  107776. SAMPLER3DBGRMAP: boolean;
  107777. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107778. MULTIVIEW: boolean;
  107779. /**
  107780. * If the reflection texture on this material is in linear color space
  107781. * @hidden
  107782. */
  107783. IS_REFLECTION_LINEAR: boolean;
  107784. /**
  107785. * If the refraction texture on this material is in linear color space
  107786. * @hidden
  107787. */
  107788. IS_REFRACTION_LINEAR: boolean;
  107789. EXPOSURE: boolean;
  107790. constructor();
  107791. setReflectionMode(modeToEnable: string): void;
  107792. }
  107793. /**
  107794. * This is the default material used in Babylon. It is the best trade off between quality
  107795. * and performances.
  107796. * @see https://doc.babylonjs.com/babylon101/materials
  107797. */
  107798. export class StandardMaterial extends PushMaterial {
  107799. private _diffuseTexture;
  107800. /**
  107801. * The basic texture of the material as viewed under a light.
  107802. */
  107803. diffuseTexture: Nullable<BaseTexture>;
  107804. private _ambientTexture;
  107805. /**
  107806. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107807. */
  107808. ambientTexture: Nullable<BaseTexture>;
  107809. private _opacityTexture;
  107810. /**
  107811. * Define the transparency of the material from a texture.
  107812. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107813. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107814. */
  107815. opacityTexture: Nullable<BaseTexture>;
  107816. private _reflectionTexture;
  107817. /**
  107818. * Define the texture used to display the reflection.
  107819. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107820. */
  107821. reflectionTexture: Nullable<BaseTexture>;
  107822. private _emissiveTexture;
  107823. /**
  107824. * Define texture of the material as if self lit.
  107825. * This will be mixed in the final result even in the absence of light.
  107826. */
  107827. emissiveTexture: Nullable<BaseTexture>;
  107828. private _specularTexture;
  107829. /**
  107830. * Define how the color and intensity of the highlight given by the light in the material.
  107831. */
  107832. specularTexture: Nullable<BaseTexture>;
  107833. private _bumpTexture;
  107834. /**
  107835. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107836. * 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.
  107837. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  107838. */
  107839. bumpTexture: Nullable<BaseTexture>;
  107840. private _lightmapTexture;
  107841. /**
  107842. * Complex lighting can be computationally expensive to compute at runtime.
  107843. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107844. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  107845. */
  107846. lightmapTexture: Nullable<BaseTexture>;
  107847. private _refractionTexture;
  107848. /**
  107849. * Define the texture used to display the refraction.
  107850. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107851. */
  107852. refractionTexture: Nullable<BaseTexture>;
  107853. /**
  107854. * The color of the material lit by the environmental background lighting.
  107855. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107856. */
  107857. ambientColor: Color3;
  107858. /**
  107859. * The basic color of the material as viewed under a light.
  107860. */
  107861. diffuseColor: Color3;
  107862. /**
  107863. * Define how the color and intensity of the highlight given by the light in the material.
  107864. */
  107865. specularColor: Color3;
  107866. /**
  107867. * Define the color of the material as if self lit.
  107868. * This will be mixed in the final result even in the absence of light.
  107869. */
  107870. emissiveColor: Color3;
  107871. /**
  107872. * Defines how sharp are the highlights in the material.
  107873. * The bigger the value the sharper giving a more glossy feeling to the result.
  107874. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107875. */
  107876. specularPower: number;
  107877. private _useAlphaFromDiffuseTexture;
  107878. /**
  107879. * Does the transparency come from the diffuse texture alpha channel.
  107880. */
  107881. useAlphaFromDiffuseTexture: boolean;
  107882. private _useEmissiveAsIllumination;
  107883. /**
  107884. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107885. */
  107886. useEmissiveAsIllumination: boolean;
  107887. private _linkEmissiveWithDiffuse;
  107888. /**
  107889. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107890. * the emissive level when the final color is close to one.
  107891. */
  107892. linkEmissiveWithDiffuse: boolean;
  107893. private _useSpecularOverAlpha;
  107894. /**
  107895. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107896. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107897. */
  107898. useSpecularOverAlpha: boolean;
  107899. private _useReflectionOverAlpha;
  107900. /**
  107901. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107902. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107903. */
  107904. useReflectionOverAlpha: boolean;
  107905. private _disableLighting;
  107906. /**
  107907. * Does lights from the scene impacts this material.
  107908. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107909. */
  107910. disableLighting: boolean;
  107911. private _useObjectSpaceNormalMap;
  107912. /**
  107913. * Allows using an object space normal map (instead of tangent space).
  107914. */
  107915. useObjectSpaceNormalMap: boolean;
  107916. private _useParallax;
  107917. /**
  107918. * Is parallax enabled or not.
  107919. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  107920. */
  107921. useParallax: boolean;
  107922. private _useParallaxOcclusion;
  107923. /**
  107924. * Is parallax occlusion enabled or not.
  107925. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107926. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  107927. */
  107928. useParallaxOcclusion: boolean;
  107929. /**
  107930. * 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.
  107931. */
  107932. parallaxScaleBias: number;
  107933. private _roughness;
  107934. /**
  107935. * Helps to define how blurry the reflections should appears in the material.
  107936. */
  107937. roughness: number;
  107938. /**
  107939. * In case of refraction, define the value of the index of refraction.
  107940. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107941. */
  107942. indexOfRefraction: number;
  107943. /**
  107944. * Invert the refraction texture alongside the y axis.
  107945. * It can be useful with procedural textures or probe for instance.
  107946. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107947. */
  107948. invertRefractionY: boolean;
  107949. /**
  107950. * Defines the alpha limits in alpha test mode.
  107951. */
  107952. alphaCutOff: number;
  107953. private _useLightmapAsShadowmap;
  107954. /**
  107955. * In case of light mapping, define whether the map contains light or shadow informations.
  107956. */
  107957. useLightmapAsShadowmap: boolean;
  107958. private _diffuseFresnelParameters;
  107959. /**
  107960. * Define the diffuse fresnel parameters of the material.
  107961. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107962. */
  107963. diffuseFresnelParameters: FresnelParameters;
  107964. private _opacityFresnelParameters;
  107965. /**
  107966. * Define the opacity fresnel parameters of the material.
  107967. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107968. */
  107969. opacityFresnelParameters: FresnelParameters;
  107970. private _reflectionFresnelParameters;
  107971. /**
  107972. * Define the reflection fresnel parameters of the material.
  107973. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107974. */
  107975. reflectionFresnelParameters: FresnelParameters;
  107976. private _refractionFresnelParameters;
  107977. /**
  107978. * Define the refraction fresnel parameters of the material.
  107979. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107980. */
  107981. refractionFresnelParameters: FresnelParameters;
  107982. private _emissiveFresnelParameters;
  107983. /**
  107984. * Define the emissive fresnel parameters of the material.
  107985. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107986. */
  107987. emissiveFresnelParameters: FresnelParameters;
  107988. private _useReflectionFresnelFromSpecular;
  107989. /**
  107990. * If true automatically deducts the fresnels values from the material specularity.
  107991. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107992. */
  107993. useReflectionFresnelFromSpecular: boolean;
  107994. private _useGlossinessFromSpecularMapAlpha;
  107995. /**
  107996. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107997. */
  107998. useGlossinessFromSpecularMapAlpha: boolean;
  107999. private _maxSimultaneousLights;
  108000. /**
  108001. * Defines the maximum number of lights that can be used in the material
  108002. */
  108003. maxSimultaneousLights: number;
  108004. private _invertNormalMapX;
  108005. /**
  108006. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108007. */
  108008. invertNormalMapX: boolean;
  108009. private _invertNormalMapY;
  108010. /**
  108011. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108012. */
  108013. invertNormalMapY: boolean;
  108014. private _twoSidedLighting;
  108015. /**
  108016. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108017. */
  108018. twoSidedLighting: boolean;
  108019. /**
  108020. * Default configuration related to image processing available in the standard Material.
  108021. */
  108022. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108023. /**
  108024. * Gets the image processing configuration used either in this material.
  108025. */
  108026. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108027. /**
  108028. * Sets the Default image processing configuration used either in the this material.
  108029. *
  108030. * If sets to null, the scene one is in use.
  108031. */
  108032. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  108033. /**
  108034. * Keep track of the image processing observer to allow dispose and replace.
  108035. */
  108036. private _imageProcessingObserver;
  108037. /**
  108038. * Attaches a new image processing configuration to the Standard Material.
  108039. * @param configuration
  108040. */
  108041. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108042. /**
  108043. * Gets wether the color curves effect is enabled.
  108044. */
  108045. get cameraColorCurvesEnabled(): boolean;
  108046. /**
  108047. * Sets wether the color curves effect is enabled.
  108048. */
  108049. set cameraColorCurvesEnabled(value: boolean);
  108050. /**
  108051. * Gets wether the color grading effect is enabled.
  108052. */
  108053. get cameraColorGradingEnabled(): boolean;
  108054. /**
  108055. * Gets wether the color grading effect is enabled.
  108056. */
  108057. set cameraColorGradingEnabled(value: boolean);
  108058. /**
  108059. * Gets wether tonemapping is enabled or not.
  108060. */
  108061. get cameraToneMappingEnabled(): boolean;
  108062. /**
  108063. * Sets wether tonemapping is enabled or not
  108064. */
  108065. set cameraToneMappingEnabled(value: boolean);
  108066. /**
  108067. * The camera exposure used on this material.
  108068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108069. * This corresponds to a photographic exposure.
  108070. */
  108071. get cameraExposure(): number;
  108072. /**
  108073. * The camera exposure used on this material.
  108074. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108075. * This corresponds to a photographic exposure.
  108076. */
  108077. set cameraExposure(value: number);
  108078. /**
  108079. * Gets The camera contrast used on this material.
  108080. */
  108081. get cameraContrast(): number;
  108082. /**
  108083. * Sets The camera contrast used on this material.
  108084. */
  108085. set cameraContrast(value: number);
  108086. /**
  108087. * Gets the Color Grading 2D Lookup Texture.
  108088. */
  108089. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  108090. /**
  108091. * Sets the Color Grading 2D Lookup Texture.
  108092. */
  108093. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  108094. /**
  108095. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108096. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108097. * 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;
  108098. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108099. */
  108100. get cameraColorCurves(): Nullable<ColorCurves>;
  108101. /**
  108102. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108103. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108104. * 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;
  108105. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108106. */
  108107. set cameraColorCurves(value: Nullable<ColorCurves>);
  108108. /**
  108109. * Defines the detail map parameters for the material.
  108110. */
  108111. readonly detailMap: DetailMapConfiguration;
  108112. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108113. protected _worldViewProjectionMatrix: Matrix;
  108114. protected _globalAmbientColor: Color3;
  108115. protected _useLogarithmicDepth: boolean;
  108116. protected _rebuildInParallel: boolean;
  108117. /**
  108118. * Instantiates a new standard material.
  108119. * This is the default material used in Babylon. It is the best trade off between quality
  108120. * and performances.
  108121. * @see https://doc.babylonjs.com/babylon101/materials
  108122. * @param name Define the name of the material in the scene
  108123. * @param scene Define the scene the material belong to
  108124. */
  108125. constructor(name: string, scene: Scene);
  108126. /**
  108127. * Gets a boolean indicating that current material needs to register RTT
  108128. */
  108129. get hasRenderTargetTextures(): boolean;
  108130. /**
  108131. * Gets the current class name of the material e.g. "StandardMaterial"
  108132. * Mainly use in serialization.
  108133. * @returns the class name
  108134. */
  108135. getClassName(): string;
  108136. /**
  108137. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108138. * You can try switching to logarithmic depth.
  108139. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108140. */
  108141. get useLogarithmicDepth(): boolean;
  108142. set useLogarithmicDepth(value: boolean);
  108143. /**
  108144. * Specifies if the material will require alpha blending
  108145. * @returns a boolean specifying if alpha blending is needed
  108146. */
  108147. needAlphaBlending(): boolean;
  108148. /**
  108149. * Specifies if this material should be rendered in alpha test mode
  108150. * @returns a boolean specifying if an alpha test is needed.
  108151. */
  108152. needAlphaTesting(): boolean;
  108153. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108154. /**
  108155. * Get the texture used for alpha test purpose.
  108156. * @returns the diffuse texture in case of the standard material.
  108157. */
  108158. getAlphaTestTexture(): Nullable<BaseTexture>;
  108159. /**
  108160. * Get if the submesh is ready to be used and all its information available.
  108161. * Child classes can use it to update shaders
  108162. * @param mesh defines the mesh to check
  108163. * @param subMesh defines which submesh to check
  108164. * @param useInstances specifies that instances should be used
  108165. * @returns a boolean indicating that the submesh is ready or not
  108166. */
  108167. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108168. /**
  108169. * Builds the material UBO layouts.
  108170. * Used internally during the effect preparation.
  108171. */
  108172. buildUniformLayout(): void;
  108173. /**
  108174. * Unbinds the material from the mesh
  108175. */
  108176. unbind(): void;
  108177. /**
  108178. * Binds the submesh to this material by preparing the effect and shader to draw
  108179. * @param world defines the world transformation matrix
  108180. * @param mesh defines the mesh containing the submesh
  108181. * @param subMesh defines the submesh to bind the material to
  108182. */
  108183. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108184. /**
  108185. * Get the list of animatables in the material.
  108186. * @returns the list of animatables object used in the material
  108187. */
  108188. getAnimatables(): IAnimatable[];
  108189. /**
  108190. * Gets the active textures from the material
  108191. * @returns an array of textures
  108192. */
  108193. getActiveTextures(): BaseTexture[];
  108194. /**
  108195. * Specifies if the material uses a texture
  108196. * @param texture defines the texture to check against the material
  108197. * @returns a boolean specifying if the material uses the texture
  108198. */
  108199. hasTexture(texture: BaseTexture): boolean;
  108200. /**
  108201. * Disposes the material
  108202. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108203. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108204. */
  108205. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108206. /**
  108207. * Makes a duplicate of the material, and gives it a new name
  108208. * @param name defines the new name for the duplicated material
  108209. * @returns the cloned material
  108210. */
  108211. clone(name: string): StandardMaterial;
  108212. /**
  108213. * Serializes this material in a JSON representation
  108214. * @returns the serialized material object
  108215. */
  108216. serialize(): any;
  108217. /**
  108218. * Creates a standard material from parsed material data
  108219. * @param source defines the JSON representation of the material
  108220. * @param scene defines the hosting scene
  108221. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108222. * @returns a new standard material
  108223. */
  108224. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108225. /**
  108226. * Are diffuse textures enabled in the application.
  108227. */
  108228. static get DiffuseTextureEnabled(): boolean;
  108229. static set DiffuseTextureEnabled(value: boolean);
  108230. /**
  108231. * Are detail textures enabled in the application.
  108232. */
  108233. static get DetailTextureEnabled(): boolean;
  108234. static set DetailTextureEnabled(value: boolean);
  108235. /**
  108236. * Are ambient textures enabled in the application.
  108237. */
  108238. static get AmbientTextureEnabled(): boolean;
  108239. static set AmbientTextureEnabled(value: boolean);
  108240. /**
  108241. * Are opacity textures enabled in the application.
  108242. */
  108243. static get OpacityTextureEnabled(): boolean;
  108244. static set OpacityTextureEnabled(value: boolean);
  108245. /**
  108246. * Are reflection textures enabled in the application.
  108247. */
  108248. static get ReflectionTextureEnabled(): boolean;
  108249. static set ReflectionTextureEnabled(value: boolean);
  108250. /**
  108251. * Are emissive textures enabled in the application.
  108252. */
  108253. static get EmissiveTextureEnabled(): boolean;
  108254. static set EmissiveTextureEnabled(value: boolean);
  108255. /**
  108256. * Are specular textures enabled in the application.
  108257. */
  108258. static get SpecularTextureEnabled(): boolean;
  108259. static set SpecularTextureEnabled(value: boolean);
  108260. /**
  108261. * Are bump textures enabled in the application.
  108262. */
  108263. static get BumpTextureEnabled(): boolean;
  108264. static set BumpTextureEnabled(value: boolean);
  108265. /**
  108266. * Are lightmap textures enabled in the application.
  108267. */
  108268. static get LightmapTextureEnabled(): boolean;
  108269. static set LightmapTextureEnabled(value: boolean);
  108270. /**
  108271. * Are refraction textures enabled in the application.
  108272. */
  108273. static get RefractionTextureEnabled(): boolean;
  108274. static set RefractionTextureEnabled(value: boolean);
  108275. /**
  108276. * Are color grading textures enabled in the application.
  108277. */
  108278. static get ColorGradingTextureEnabled(): boolean;
  108279. static set ColorGradingTextureEnabled(value: boolean);
  108280. /**
  108281. * Are fresnels enabled in the application.
  108282. */
  108283. static get FresnelEnabled(): boolean;
  108284. static set FresnelEnabled(value: boolean);
  108285. }
  108286. }
  108287. declare module BABYLON {
  108288. /**
  108289. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  108290. *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.
  108291. * The SPS is also a particle system. It provides some methods to manage the particles.
  108292. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  108293. *
  108294. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  108295. */
  108296. export class SolidParticleSystem implements IDisposable {
  108297. /**
  108298. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  108299. * Example : var p = SPS.particles[i];
  108300. */
  108301. particles: SolidParticle[];
  108302. /**
  108303. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  108304. */
  108305. nbParticles: number;
  108306. /**
  108307. * If the particles must ever face the camera (default false). Useful for planar particles.
  108308. */
  108309. billboard: boolean;
  108310. /**
  108311. * Recompute normals when adding a shape
  108312. */
  108313. recomputeNormals: boolean;
  108314. /**
  108315. * This a counter ofr your own usage. It's not set by any SPS functions.
  108316. */
  108317. counter: number;
  108318. /**
  108319. * The SPS name. This name is also given to the underlying mesh.
  108320. */
  108321. name: string;
  108322. /**
  108323. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  108324. */
  108325. mesh: Mesh;
  108326. /**
  108327. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  108328. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  108329. */
  108330. vars: any;
  108331. /**
  108332. * This array is populated when the SPS is set as 'pickable'.
  108333. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  108334. * Each element of this array is an object `{idx: int, faceId: int}`.
  108335. * `idx` is the picked particle index in the `SPS.particles` array
  108336. * `faceId` is the picked face index counted within this particle.
  108337. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  108338. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  108339. * Use the method SPS.pickedParticle(pickingInfo) instead.
  108340. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  108341. */
  108342. pickedParticles: {
  108343. idx: number;
  108344. faceId: number;
  108345. }[];
  108346. /**
  108347. * This array is populated when the SPS is set as 'pickable'
  108348. * Each key of this array is a submesh index.
  108349. * Each element of this array is a second array defined like this :
  108350. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  108351. * Each element of this second array is an object `{idx: int, faceId: int}`.
  108352. * `idx` is the picked particle index in the `SPS.particles` array
  108353. * `faceId` is the picked face index counted within this particle.
  108354. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  108355. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  108356. */
  108357. pickedBySubMesh: {
  108358. idx: number;
  108359. faceId: number;
  108360. }[][];
  108361. /**
  108362. * This array is populated when `enableDepthSort` is set to true.
  108363. * Each element of this array is an instance of the class DepthSortedParticle.
  108364. */
  108365. depthSortedParticles: DepthSortedParticle[];
  108366. /**
  108367. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  108368. * @hidden
  108369. */
  108370. _bSphereOnly: boolean;
  108371. /**
  108372. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  108373. * @hidden
  108374. */
  108375. _bSphereRadiusFactor: number;
  108376. private _scene;
  108377. private _positions;
  108378. private _indices;
  108379. private _normals;
  108380. private _colors;
  108381. private _uvs;
  108382. private _indices32;
  108383. private _positions32;
  108384. private _normals32;
  108385. private _fixedNormal32;
  108386. private _colors32;
  108387. private _uvs32;
  108388. private _index;
  108389. private _updatable;
  108390. private _pickable;
  108391. private _isVisibilityBoxLocked;
  108392. private _alwaysVisible;
  108393. private _depthSort;
  108394. private _expandable;
  108395. private _shapeCounter;
  108396. private _copy;
  108397. private _color;
  108398. private _computeParticleColor;
  108399. private _computeParticleTexture;
  108400. private _computeParticleRotation;
  108401. private _computeParticleVertex;
  108402. private _computeBoundingBox;
  108403. private _depthSortParticles;
  108404. private _camera;
  108405. private _mustUnrotateFixedNormals;
  108406. private _particlesIntersect;
  108407. private _needs32Bits;
  108408. private _isNotBuilt;
  108409. private _lastParticleId;
  108410. private _idxOfId;
  108411. private _multimaterialEnabled;
  108412. private _useModelMaterial;
  108413. private _indicesByMaterial;
  108414. private _materialIndexes;
  108415. private _depthSortFunction;
  108416. private _materialSortFunction;
  108417. private _materials;
  108418. private _multimaterial;
  108419. private _materialIndexesById;
  108420. private _defaultMaterial;
  108421. private _autoUpdateSubMeshes;
  108422. private _tmpVertex;
  108423. /**
  108424. * Creates a SPS (Solid Particle System) object.
  108425. * @param name (String) is the SPS name, this will be the underlying mesh name.
  108426. * @param scene (Scene) is the scene in which the SPS is added.
  108427. * @param options defines the options of the sps e.g.
  108428. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  108429. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  108430. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  108431. * * 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.
  108432. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  108433. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  108434. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  108435. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  108436. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  108437. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  108438. */
  108439. constructor(name: string, scene: Scene, options?: {
  108440. updatable?: boolean;
  108441. isPickable?: boolean;
  108442. enableDepthSort?: boolean;
  108443. particleIntersection?: boolean;
  108444. boundingSphereOnly?: boolean;
  108445. bSphereRadiusFactor?: number;
  108446. expandable?: boolean;
  108447. useModelMaterial?: boolean;
  108448. enableMultiMaterial?: boolean;
  108449. });
  108450. /**
  108451. * Builds the SPS underlying mesh. Returns a standard Mesh.
  108452. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  108453. * @returns the created mesh
  108454. */
  108455. buildMesh(): Mesh;
  108456. /**
  108457. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108458. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108459. * Thus the particles generated from `digest()` have their property `position` set yet.
  108460. * @param mesh ( Mesh ) is the mesh to be digested
  108461. * @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
  108462. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108463. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108464. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108465. * @returns the current SPS
  108466. */
  108467. digest(mesh: Mesh, options?: {
  108468. facetNb?: number;
  108469. number?: number;
  108470. delta?: number;
  108471. storage?: [];
  108472. }): SolidParticleSystem;
  108473. /**
  108474. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108475. * @hidden
  108476. */
  108477. private _unrotateFixedNormals;
  108478. /**
  108479. * Resets the temporary working copy particle
  108480. * @hidden
  108481. */
  108482. private _resetCopy;
  108483. /**
  108484. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  108485. * @param p the current index in the positions array to be updated
  108486. * @param ind the current index in the indices array
  108487. * @param shape a Vector3 array, the shape geometry
  108488. * @param positions the positions array to be updated
  108489. * @param meshInd the shape indices array
  108490. * @param indices the indices array to be updated
  108491. * @param meshUV the shape uv array
  108492. * @param uvs the uv array to be updated
  108493. * @param meshCol the shape color array
  108494. * @param colors the color array to be updated
  108495. * @param meshNor the shape normals array
  108496. * @param normals the normals array to be updated
  108497. * @param idx the particle index
  108498. * @param idxInShape the particle index in its shape
  108499. * @param options the addShape() method passed options
  108500. * @model the particle model
  108501. * @hidden
  108502. */
  108503. private _meshBuilder;
  108504. /**
  108505. * Returns a shape Vector3 array from positions float array
  108506. * @param positions float array
  108507. * @returns a vector3 array
  108508. * @hidden
  108509. */
  108510. private _posToShape;
  108511. /**
  108512. * Returns a shapeUV array from a float uvs (array deep copy)
  108513. * @param uvs as a float array
  108514. * @returns a shapeUV array
  108515. * @hidden
  108516. */
  108517. private _uvsToShapeUV;
  108518. /**
  108519. * Adds a new particle object in the particles array
  108520. * @param idx particle index in particles array
  108521. * @param id particle id
  108522. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  108523. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  108524. * @param model particle ModelShape object
  108525. * @param shapeId model shape identifier
  108526. * @param idxInShape index of the particle in the current model
  108527. * @param bInfo model bounding info object
  108528. * @param storage target storage array, if any
  108529. * @hidden
  108530. */
  108531. private _addParticle;
  108532. /**
  108533. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108534. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  108535. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108536. * @param nb (positive integer) the number of particles to be created from this model
  108537. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108538. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108539. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108540. * @returns the number of shapes in the system
  108541. */
  108542. addShape(mesh: Mesh, nb: number, options?: {
  108543. positionFunction?: any;
  108544. vertexFunction?: any;
  108545. storage?: [];
  108546. }): number;
  108547. /**
  108548. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108549. * @hidden
  108550. */
  108551. private _rebuildParticle;
  108552. /**
  108553. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108554. * @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.
  108555. * @returns the SPS.
  108556. */
  108557. rebuildMesh(reset?: boolean): SolidParticleSystem;
  108558. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  108559. * Returns an array with the removed particles.
  108560. * 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.
  108561. * The SPS can't be empty so at least one particle needs to remain in place.
  108562. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  108563. * @param start index of the first particle to remove
  108564. * @param end index of the last particle to remove (included)
  108565. * @returns an array populated with the removed particles
  108566. */
  108567. removeParticles(start: number, end: number): SolidParticle[];
  108568. /**
  108569. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  108570. * @param solidParticleArray an array populated with Solid Particles objects
  108571. * @returns the SPS
  108572. */
  108573. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  108574. /**
  108575. * Creates a new particle and modifies the SPS mesh geometry :
  108576. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  108577. * - calls _addParticle() to populate the particle array
  108578. * factorized code from addShape() and insertParticlesFromArray()
  108579. * @param idx particle index in the particles array
  108580. * @param i particle index in its shape
  108581. * @param modelShape particle ModelShape object
  108582. * @param shape shape vertex array
  108583. * @param meshInd shape indices array
  108584. * @param meshUV shape uv array
  108585. * @param meshCol shape color array
  108586. * @param meshNor shape normals array
  108587. * @param bbInfo shape bounding info
  108588. * @param storage target particle storage
  108589. * @options addShape() passed options
  108590. * @hidden
  108591. */
  108592. private _insertNewParticle;
  108593. /**
  108594. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108595. * This method calls `updateParticle()` for each particle of the SPS.
  108596. * For an animated SPS, it is usually called within the render loop.
  108597. * 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.
  108598. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108599. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108600. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108601. * @returns the SPS.
  108602. */
  108603. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  108604. /**
  108605. * Disposes the SPS.
  108606. */
  108607. dispose(): void;
  108608. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  108609. * idx is the particle index in the SPS
  108610. * faceId is the picked face index counted within this particle.
  108611. * Returns null if the pickInfo can't identify a picked particle.
  108612. * @param pickingInfo (PickingInfo object)
  108613. * @returns {idx: number, faceId: number} or null
  108614. */
  108615. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  108616. idx: number;
  108617. faceId: number;
  108618. }>;
  108619. /**
  108620. * Returns a SolidParticle object from its identifier : particle.id
  108621. * @param id (integer) the particle Id
  108622. * @returns the searched particle or null if not found in the SPS.
  108623. */
  108624. getParticleById(id: number): Nullable<SolidParticle>;
  108625. /**
  108626. * Returns a new array populated with the particles having the passed shapeId.
  108627. * @param shapeId (integer) the shape identifier
  108628. * @returns a new solid particle array
  108629. */
  108630. getParticlesByShapeId(shapeId: number): SolidParticle[];
  108631. /**
  108632. * Populates the passed array "ref" with the particles having the passed shapeId.
  108633. * @param shapeId the shape identifier
  108634. * @returns the SPS
  108635. * @param ref
  108636. */
  108637. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  108638. /**
  108639. * Computes the required SubMeshes according the materials assigned to the particles.
  108640. * @returns the solid particle system.
  108641. * Does nothing if called before the SPS mesh is built.
  108642. */
  108643. computeSubMeshes(): SolidParticleSystem;
  108644. /**
  108645. * Sorts the solid particles by material when MultiMaterial is enabled.
  108646. * Updates the indices32 array.
  108647. * Updates the indicesByMaterial array.
  108648. * Updates the mesh indices array.
  108649. * @returns the SPS
  108650. * @hidden
  108651. */
  108652. private _sortParticlesByMaterial;
  108653. /**
  108654. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  108655. * @hidden
  108656. */
  108657. private _setMaterialIndexesById;
  108658. /**
  108659. * Returns an array with unique values of Materials from the passed array
  108660. * @param array the material array to be checked and filtered
  108661. * @hidden
  108662. */
  108663. private _filterUniqueMaterialId;
  108664. /**
  108665. * Sets a new Standard Material as _defaultMaterial if not already set.
  108666. * @hidden
  108667. */
  108668. private _setDefaultMaterial;
  108669. /**
  108670. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108671. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108672. * @returns the SPS.
  108673. */
  108674. refreshVisibleSize(): SolidParticleSystem;
  108675. /**
  108676. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108677. * @param size the size (float) of the visibility box
  108678. * note : this doesn't lock the SPS mesh bounding box.
  108679. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108680. */
  108681. setVisibilityBox(size: number): void;
  108682. /**
  108683. * Gets whether the SPS as always visible or not
  108684. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108685. */
  108686. get isAlwaysVisible(): boolean;
  108687. /**
  108688. * Sets the SPS as always visible or not
  108689. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108690. */
  108691. set isAlwaysVisible(val: boolean);
  108692. /**
  108693. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108694. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108695. */
  108696. set isVisibilityBoxLocked(val: boolean);
  108697. /**
  108698. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108699. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108700. */
  108701. get isVisibilityBoxLocked(): boolean;
  108702. /**
  108703. * Tells to `setParticles()` to compute the particle rotations or not.
  108704. * Default value : true. The SPS is faster when it's set to false.
  108705. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108706. */
  108707. set computeParticleRotation(val: boolean);
  108708. /**
  108709. * Tells to `setParticles()` to compute the particle colors or not.
  108710. * Default value : true. The SPS is faster when it's set to false.
  108711. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108712. */
  108713. set computeParticleColor(val: boolean);
  108714. set computeParticleTexture(val: boolean);
  108715. /**
  108716. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108717. * Default value : false. The SPS is faster when it's set to false.
  108718. * Note : the particle custom vertex positions aren't stored values.
  108719. */
  108720. set computeParticleVertex(val: boolean);
  108721. /**
  108722. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108723. */
  108724. set computeBoundingBox(val: boolean);
  108725. /**
  108726. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108727. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108728. * Default : `true`
  108729. */
  108730. set depthSortParticles(val: boolean);
  108731. /**
  108732. * Gets if `setParticles()` computes the particle rotations or not.
  108733. * Default value : true. The SPS is faster when it's set to false.
  108734. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108735. */
  108736. get computeParticleRotation(): boolean;
  108737. /**
  108738. * Gets if `setParticles()` computes the particle colors or not.
  108739. * Default value : true. The SPS is faster when it's set to false.
  108740. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108741. */
  108742. get computeParticleColor(): boolean;
  108743. /**
  108744. * Gets if `setParticles()` computes the particle textures or not.
  108745. * Default value : true. The SPS is faster when it's set to false.
  108746. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108747. */
  108748. get computeParticleTexture(): boolean;
  108749. /**
  108750. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108751. * Default value : false. The SPS is faster when it's set to false.
  108752. * Note : the particle custom vertex positions aren't stored values.
  108753. */
  108754. get computeParticleVertex(): boolean;
  108755. /**
  108756. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108757. */
  108758. get computeBoundingBox(): boolean;
  108759. /**
  108760. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108761. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108762. * Default : `true`
  108763. */
  108764. get depthSortParticles(): boolean;
  108765. /**
  108766. * Gets if the SPS is created as expandable at construction time.
  108767. * Default : `false`
  108768. */
  108769. get expandable(): boolean;
  108770. /**
  108771. * Gets if the SPS supports the Multi Materials
  108772. */
  108773. get multimaterialEnabled(): boolean;
  108774. /**
  108775. * Gets if the SPS uses the model materials for its own multimaterial.
  108776. */
  108777. get useModelMaterial(): boolean;
  108778. /**
  108779. * The SPS used material array.
  108780. */
  108781. get materials(): Material[];
  108782. /**
  108783. * Sets the SPS MultiMaterial from the passed materials.
  108784. * Note : the passed array is internally copied and not used then by reference.
  108785. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  108786. */
  108787. setMultiMaterial(materials: Material[]): void;
  108788. /**
  108789. * The SPS computed multimaterial object
  108790. */
  108791. get multimaterial(): MultiMaterial;
  108792. set multimaterial(mm: MultiMaterial);
  108793. /**
  108794. * If the subMeshes must be updated on the next call to setParticles()
  108795. */
  108796. get autoUpdateSubMeshes(): boolean;
  108797. set autoUpdateSubMeshes(val: boolean);
  108798. /**
  108799. * This function does nothing. It may be overwritten to set all the particle first values.
  108800. * The SPS doesn't call this function, you may have to call it by your own.
  108801. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108802. */
  108803. initParticles(): void;
  108804. /**
  108805. * This function does nothing. It may be overwritten to recycle a particle.
  108806. * The SPS doesn't call this function, you may have to call it by your own.
  108807. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108808. * @param particle The particle to recycle
  108809. * @returns the recycled particle
  108810. */
  108811. recycleParticle(particle: SolidParticle): SolidParticle;
  108812. /**
  108813. * Updates a particle : this function should be overwritten by the user.
  108814. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108815. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108816. * @example : just set a particle position or velocity and recycle conditions
  108817. * @param particle The particle to update
  108818. * @returns the updated particle
  108819. */
  108820. updateParticle(particle: SolidParticle): SolidParticle;
  108821. /**
  108822. * Updates a vertex of a particle : it can be overwritten by the user.
  108823. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108824. * @param particle the current particle
  108825. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  108826. * @param pt the index of the current vertex in the particle shape
  108827. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  108828. * @example : just set a vertex particle position or color
  108829. * @returns the sps
  108830. */
  108831. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  108832. /**
  108833. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108834. * This does nothing and may be overwritten by the user.
  108835. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108836. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108837. * @param update the boolean update value actually passed to setParticles()
  108838. */
  108839. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108840. /**
  108841. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108842. * This will be passed three parameters.
  108843. * This does nothing and may be overwritten by the user.
  108844. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108845. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108846. * @param update the boolean update value actually passed to setParticles()
  108847. */
  108848. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108849. }
  108850. }
  108851. declare module BABYLON {
  108852. /**
  108853. * Represents one particle of a solid particle system.
  108854. */
  108855. export class SolidParticle {
  108856. /**
  108857. * particle global index
  108858. */
  108859. idx: number;
  108860. /**
  108861. * particle identifier
  108862. */
  108863. id: number;
  108864. /**
  108865. * The color of the particle
  108866. */
  108867. color: Nullable<Color4>;
  108868. /**
  108869. * The world space position of the particle.
  108870. */
  108871. position: Vector3;
  108872. /**
  108873. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  108874. */
  108875. rotation: Vector3;
  108876. /**
  108877. * The world space rotation quaternion of the particle.
  108878. */
  108879. rotationQuaternion: Nullable<Quaternion>;
  108880. /**
  108881. * The scaling of the particle.
  108882. */
  108883. scaling: Vector3;
  108884. /**
  108885. * The uvs of the particle.
  108886. */
  108887. uvs: Vector4;
  108888. /**
  108889. * The current speed of the particle.
  108890. */
  108891. velocity: Vector3;
  108892. /**
  108893. * The pivot point in the particle local space.
  108894. */
  108895. pivot: Vector3;
  108896. /**
  108897. * Must the particle be translated from its pivot point in its local space ?
  108898. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  108899. * Default : false
  108900. */
  108901. translateFromPivot: boolean;
  108902. /**
  108903. * Is the particle active or not ?
  108904. */
  108905. alive: boolean;
  108906. /**
  108907. * Is the particle visible or not ?
  108908. */
  108909. isVisible: boolean;
  108910. /**
  108911. * Index of this particle in the global "positions" array (Internal use)
  108912. * @hidden
  108913. */
  108914. _pos: number;
  108915. /**
  108916. * @hidden Index of this particle in the global "indices" array (Internal use)
  108917. */
  108918. _ind: number;
  108919. /**
  108920. * @hidden ModelShape of this particle (Internal use)
  108921. */
  108922. _model: ModelShape;
  108923. /**
  108924. * ModelShape id of this particle
  108925. */
  108926. shapeId: number;
  108927. /**
  108928. * Index of the particle in its shape id
  108929. */
  108930. idxInShape: number;
  108931. /**
  108932. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  108933. */
  108934. _modelBoundingInfo: BoundingInfo;
  108935. /**
  108936. * @hidden Particle BoundingInfo object (Internal use)
  108937. */
  108938. _boundingInfo: BoundingInfo;
  108939. /**
  108940. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  108941. */
  108942. _sps: SolidParticleSystem;
  108943. /**
  108944. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  108945. */
  108946. _stillInvisible: boolean;
  108947. /**
  108948. * @hidden Last computed particle rotation matrix
  108949. */
  108950. _rotationMatrix: number[];
  108951. /**
  108952. * Parent particle Id, if any.
  108953. * Default null.
  108954. */
  108955. parentId: Nullable<number>;
  108956. /**
  108957. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  108958. */
  108959. materialIndex: Nullable<number>;
  108960. /**
  108961. * Custom object or properties.
  108962. */
  108963. props: Nullable<any>;
  108964. /**
  108965. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  108966. * The possible values are :
  108967. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108968. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108969. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108970. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108971. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108972. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  108973. * */
  108974. cullingStrategy: number;
  108975. /**
  108976. * @hidden Internal global position in the SPS.
  108977. */
  108978. _globalPosition: Vector3;
  108979. /**
  108980. * Creates a Solid Particle object.
  108981. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  108982. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  108983. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  108984. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  108985. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  108986. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  108987. * @param shapeId (integer) is the model shape identifier in the SPS.
  108988. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  108989. * @param sps defines the sps it is associated to
  108990. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  108991. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  108992. */
  108993. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  108994. /**
  108995. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  108996. * @param target the particle target
  108997. * @returns the current particle
  108998. */
  108999. copyToRef(target: SolidParticle): SolidParticle;
  109000. /**
  109001. * Legacy support, changed scale to scaling
  109002. */
  109003. get scale(): Vector3;
  109004. /**
  109005. * Legacy support, changed scale to scaling
  109006. */
  109007. set scale(scale: Vector3);
  109008. /**
  109009. * Legacy support, changed quaternion to rotationQuaternion
  109010. */
  109011. get quaternion(): Nullable<Quaternion>;
  109012. /**
  109013. * Legacy support, changed quaternion to rotationQuaternion
  109014. */
  109015. set quaternion(q: Nullable<Quaternion>);
  109016. /**
  109017. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  109018. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  109019. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  109020. * @returns true if it intersects
  109021. */
  109022. intersectsMesh(target: Mesh | SolidParticle): boolean;
  109023. /**
  109024. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  109025. * A particle is in the frustum if its bounding box intersects the frustum
  109026. * @param frustumPlanes defines the frustum to test
  109027. * @returns true if the particle is in the frustum planes
  109028. */
  109029. isInFrustum(frustumPlanes: Plane[]): boolean;
  109030. /**
  109031. * get the rotation matrix of the particle
  109032. * @hidden
  109033. */
  109034. getRotationMatrix(m: Matrix): void;
  109035. }
  109036. /**
  109037. * Represents the shape of the model used by one particle of a solid particle system.
  109038. * SPS internal tool, don't use it manually.
  109039. */
  109040. export class ModelShape {
  109041. /**
  109042. * The shape id
  109043. * @hidden
  109044. */
  109045. shapeID: number;
  109046. /**
  109047. * flat array of model positions (internal use)
  109048. * @hidden
  109049. */
  109050. _shape: Vector3[];
  109051. /**
  109052. * flat array of model UVs (internal use)
  109053. * @hidden
  109054. */
  109055. _shapeUV: number[];
  109056. /**
  109057. * color array of the model
  109058. * @hidden
  109059. */
  109060. _shapeColors: number[];
  109061. /**
  109062. * indices array of the model
  109063. * @hidden
  109064. */
  109065. _indices: number[];
  109066. /**
  109067. * normals array of the model
  109068. * @hidden
  109069. */
  109070. _normals: number[];
  109071. /**
  109072. * length of the shape in the model indices array (internal use)
  109073. * @hidden
  109074. */
  109075. _indicesLength: number;
  109076. /**
  109077. * Custom position function (internal use)
  109078. * @hidden
  109079. */
  109080. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  109081. /**
  109082. * Custom vertex function (internal use)
  109083. * @hidden
  109084. */
  109085. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  109086. /**
  109087. * Model material (internal use)
  109088. * @hidden
  109089. */
  109090. _material: Nullable<Material>;
  109091. /**
  109092. * 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.
  109093. * SPS internal tool, don't use it manually.
  109094. * @hidden
  109095. */
  109096. 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>);
  109097. }
  109098. /**
  109099. * Represents a Depth Sorted Particle in the solid particle system.
  109100. * @hidden
  109101. */
  109102. export class DepthSortedParticle {
  109103. /**
  109104. * Particle index
  109105. */
  109106. idx: number;
  109107. /**
  109108. * Index of the particle in the "indices" array
  109109. */
  109110. ind: number;
  109111. /**
  109112. * Length of the particle shape in the "indices" array
  109113. */
  109114. indicesLength: number;
  109115. /**
  109116. * Squared distance from the particle to the camera
  109117. */
  109118. sqDistance: number;
  109119. /**
  109120. * Material index when used with MultiMaterials
  109121. */
  109122. materialIndex: number;
  109123. /**
  109124. * Creates a new sorted particle
  109125. * @param materialIndex
  109126. */
  109127. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  109128. }
  109129. /**
  109130. * Represents a solid particle vertex
  109131. */
  109132. export class SolidParticleVertex {
  109133. /**
  109134. * Vertex position
  109135. */
  109136. position: Vector3;
  109137. /**
  109138. * Vertex color
  109139. */
  109140. color: Color4;
  109141. /**
  109142. * Vertex UV
  109143. */
  109144. uv: Vector2;
  109145. /**
  109146. * Creates a new solid particle vertex
  109147. */
  109148. constructor();
  109149. /** Vertex x coordinate */
  109150. get x(): number;
  109151. set x(val: number);
  109152. /** Vertex y coordinate */
  109153. get y(): number;
  109154. set y(val: number);
  109155. /** Vertex z coordinate */
  109156. get z(): number;
  109157. set z(val: number);
  109158. }
  109159. }
  109160. declare module BABYLON {
  109161. /**
  109162. * @hidden
  109163. */
  109164. export class _MeshCollisionData {
  109165. _checkCollisions: boolean;
  109166. _collisionMask: number;
  109167. _collisionGroup: number;
  109168. _surroundingMeshes: Nullable<AbstractMesh[]>;
  109169. _collider: Nullable<Collider>;
  109170. _oldPositionForCollisions: Vector3;
  109171. _diffPositionForCollisions: Vector3;
  109172. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  109173. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  109174. }
  109175. }
  109176. declare module BABYLON {
  109177. /** @hidden */
  109178. class _FacetDataStorage {
  109179. facetPositions: Vector3[];
  109180. facetNormals: Vector3[];
  109181. facetPartitioning: number[][];
  109182. facetNb: number;
  109183. partitioningSubdivisions: number;
  109184. partitioningBBoxRatio: number;
  109185. facetDataEnabled: boolean;
  109186. facetParameters: any;
  109187. bbSize: Vector3;
  109188. subDiv: {
  109189. max: number;
  109190. X: number;
  109191. Y: number;
  109192. Z: number;
  109193. };
  109194. facetDepthSort: boolean;
  109195. facetDepthSortEnabled: boolean;
  109196. depthSortedIndices: IndicesArray;
  109197. depthSortedFacets: {
  109198. ind: number;
  109199. sqDistance: number;
  109200. }[];
  109201. facetDepthSortFunction: (f1: {
  109202. ind: number;
  109203. sqDistance: number;
  109204. }, f2: {
  109205. ind: number;
  109206. sqDistance: number;
  109207. }) => number;
  109208. facetDepthSortFrom: Vector3;
  109209. facetDepthSortOrigin: Vector3;
  109210. invertedMatrix: Matrix;
  109211. }
  109212. /**
  109213. * @hidden
  109214. **/
  109215. class _InternalAbstractMeshDataInfo {
  109216. _hasVertexAlpha: boolean;
  109217. _useVertexColors: boolean;
  109218. _numBoneInfluencers: number;
  109219. _applyFog: boolean;
  109220. _receiveShadows: boolean;
  109221. _facetData: _FacetDataStorage;
  109222. _visibility: number;
  109223. _skeleton: Nullable<Skeleton>;
  109224. _layerMask: number;
  109225. _computeBonesUsingShaders: boolean;
  109226. _isActive: boolean;
  109227. _onlyForInstances: boolean;
  109228. _isActiveIntermediate: boolean;
  109229. _onlyForInstancesIntermediate: boolean;
  109230. _actAsRegularMesh: boolean;
  109231. }
  109232. /**
  109233. * Class used to store all common mesh properties
  109234. */
  109235. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  109236. /** No occlusion */
  109237. static OCCLUSION_TYPE_NONE: number;
  109238. /** Occlusion set to optimisitic */
  109239. static OCCLUSION_TYPE_OPTIMISTIC: number;
  109240. /** Occlusion set to strict */
  109241. static OCCLUSION_TYPE_STRICT: number;
  109242. /** Use an accurante occlusion algorithm */
  109243. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  109244. /** Use a conservative occlusion algorithm */
  109245. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  109246. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  109247. * Test order :
  109248. * Is the bounding sphere outside the frustum ?
  109249. * If not, are the bounding box vertices outside the frustum ?
  109250. * It not, then the cullable object is in the frustum.
  109251. */
  109252. static readonly CULLINGSTRATEGY_STANDARD: number;
  109253. /** Culling strategy : Bounding Sphere Only.
  109254. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  109255. * It's also less accurate than the standard because some not visible objects can still be selected.
  109256. * Test : is the bounding sphere outside the frustum ?
  109257. * If not, then the cullable object is in the frustum.
  109258. */
  109259. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  109260. /** Culling strategy : Optimistic Inclusion.
  109261. * This in an inclusion test first, then the standard exclusion test.
  109262. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  109263. * 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.
  109264. * Anyway, it's as accurate as the standard strategy.
  109265. * Test :
  109266. * Is the cullable object bounding sphere center in the frustum ?
  109267. * If not, apply the default culling strategy.
  109268. */
  109269. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  109270. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  109271. * This in an inclusion test first, then the bounding sphere only exclusion test.
  109272. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  109273. * 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.
  109274. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  109275. * Test :
  109276. * Is the cullable object bounding sphere center in the frustum ?
  109277. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  109278. */
  109279. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  109280. /**
  109281. * No billboard
  109282. */
  109283. static get BILLBOARDMODE_NONE(): number;
  109284. /** Billboard on X axis */
  109285. static get BILLBOARDMODE_X(): number;
  109286. /** Billboard on Y axis */
  109287. static get BILLBOARDMODE_Y(): number;
  109288. /** Billboard on Z axis */
  109289. static get BILLBOARDMODE_Z(): number;
  109290. /** Billboard on all axes */
  109291. static get BILLBOARDMODE_ALL(): number;
  109292. /** Billboard on using position instead of orientation */
  109293. static get BILLBOARDMODE_USE_POSITION(): number;
  109294. /** @hidden */
  109295. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  109296. /**
  109297. * The culling strategy to use to check whether the mesh must be rendered or not.
  109298. * This value can be changed at any time and will be used on the next render mesh selection.
  109299. * The possible values are :
  109300. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  109301. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109302. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  109303. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  109304. * Please read each static variable documentation to get details about the culling process.
  109305. * */
  109306. cullingStrategy: number;
  109307. /**
  109308. * Gets the number of facets in the mesh
  109309. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  109310. */
  109311. get facetNb(): number;
  109312. /**
  109313. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  109314. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  109315. */
  109316. get partitioningSubdivisions(): number;
  109317. set partitioningSubdivisions(nb: number);
  109318. /**
  109319. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  109320. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  109321. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  109322. */
  109323. get partitioningBBoxRatio(): number;
  109324. set partitioningBBoxRatio(ratio: number);
  109325. /**
  109326. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  109327. * Works only for updatable meshes.
  109328. * Doesn't work with multi-materials
  109329. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  109330. */
  109331. get mustDepthSortFacets(): boolean;
  109332. set mustDepthSortFacets(sort: boolean);
  109333. /**
  109334. * The location (Vector3) where the facet depth sort must be computed from.
  109335. * By default, the active camera position.
  109336. * Used only when facet depth sort is enabled
  109337. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  109338. */
  109339. get facetDepthSortFrom(): Vector3;
  109340. set facetDepthSortFrom(location: Vector3);
  109341. /**
  109342. * gets a boolean indicating if facetData is enabled
  109343. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  109344. */
  109345. get isFacetDataEnabled(): boolean;
  109346. /** @hidden */
  109347. _updateNonUniformScalingState(value: boolean): boolean;
  109348. /**
  109349. * An event triggered when this mesh collides with another one
  109350. */
  109351. onCollideObservable: Observable<AbstractMesh>;
  109352. /** Set a function to call when this mesh collides with another one */
  109353. set onCollide(callback: () => void);
  109354. /**
  109355. * An event triggered when the collision's position changes
  109356. */
  109357. onCollisionPositionChangeObservable: Observable<Vector3>;
  109358. /** Set a function to call when the collision's position changes */
  109359. set onCollisionPositionChange(callback: () => void);
  109360. /**
  109361. * An event triggered when material is changed
  109362. */
  109363. onMaterialChangedObservable: Observable<AbstractMesh>;
  109364. /**
  109365. * Gets or sets the orientation for POV movement & rotation
  109366. */
  109367. definedFacingForward: boolean;
  109368. /** @hidden */
  109369. _occlusionQuery: Nullable<WebGLQuery>;
  109370. /** @hidden */
  109371. _renderingGroup: Nullable<RenderingGroup>;
  109372. /**
  109373. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  109374. */
  109375. get visibility(): number;
  109376. /**
  109377. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  109378. */
  109379. set visibility(value: number);
  109380. /** Gets or sets the alpha index used to sort transparent meshes
  109381. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  109382. */
  109383. alphaIndex: number;
  109384. /**
  109385. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  109386. */
  109387. isVisible: boolean;
  109388. /**
  109389. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  109390. */
  109391. isPickable: boolean;
  109392. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  109393. showSubMeshesBoundingBox: boolean;
  109394. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  109395. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  109396. */
  109397. isBlocker: boolean;
  109398. /**
  109399. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  109400. */
  109401. enablePointerMoveEvents: boolean;
  109402. /**
  109403. * Specifies the rendering group id for this mesh (0 by default)
  109404. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  109405. */
  109406. renderingGroupId: number;
  109407. private _material;
  109408. /** Gets or sets current material */
  109409. get material(): Nullable<Material>;
  109410. set material(value: Nullable<Material>);
  109411. /**
  109412. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  109413. * @see https://doc.babylonjs.com/babylon101/shadows
  109414. */
  109415. get receiveShadows(): boolean;
  109416. set receiveShadows(value: boolean);
  109417. /** Defines color to use when rendering outline */
  109418. outlineColor: Color3;
  109419. /** Define width to use when rendering outline */
  109420. outlineWidth: number;
  109421. /** Defines color to use when rendering overlay */
  109422. overlayColor: Color3;
  109423. /** Defines alpha to use when rendering overlay */
  109424. overlayAlpha: number;
  109425. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  109426. get hasVertexAlpha(): boolean;
  109427. set hasVertexAlpha(value: boolean);
  109428. /** 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) */
  109429. get useVertexColors(): boolean;
  109430. set useVertexColors(value: boolean);
  109431. /**
  109432. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  109433. */
  109434. get computeBonesUsingShaders(): boolean;
  109435. set computeBonesUsingShaders(value: boolean);
  109436. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  109437. get numBoneInfluencers(): number;
  109438. set numBoneInfluencers(value: number);
  109439. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  109440. get applyFog(): boolean;
  109441. set applyFog(value: boolean);
  109442. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  109443. useOctreeForRenderingSelection: boolean;
  109444. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  109445. useOctreeForPicking: boolean;
  109446. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  109447. useOctreeForCollisions: boolean;
  109448. /**
  109449. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  109450. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  109451. */
  109452. get layerMask(): number;
  109453. set layerMask(value: number);
  109454. /**
  109455. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  109456. */
  109457. alwaysSelectAsActiveMesh: boolean;
  109458. /**
  109459. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  109460. */
  109461. doNotSyncBoundingInfo: boolean;
  109462. /**
  109463. * Gets or sets the current action manager
  109464. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  109465. */
  109466. actionManager: Nullable<AbstractActionManager>;
  109467. private _meshCollisionData;
  109468. /**
  109469. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  109470. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109471. */
  109472. ellipsoid: Vector3;
  109473. /**
  109474. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  109475. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109476. */
  109477. ellipsoidOffset: Vector3;
  109478. /**
  109479. * Gets or sets a collision mask used to mask collisions (default is -1).
  109480. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109481. */
  109482. get collisionMask(): number;
  109483. set collisionMask(mask: number);
  109484. /**
  109485. * Gets or sets the current collision group mask (-1 by default).
  109486. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109487. */
  109488. get collisionGroup(): number;
  109489. set collisionGroup(mask: number);
  109490. /**
  109491. * Gets or sets current surrounding meshes (null by default).
  109492. *
  109493. * By default collision detection is tested against every mesh in the scene.
  109494. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  109495. * meshes will be tested for the collision.
  109496. *
  109497. * Note: if set to an empty array no collision will happen when this mesh is moved.
  109498. */
  109499. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  109500. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  109501. /**
  109502. * Defines edge width used when edgesRenderer is enabled
  109503. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109504. */
  109505. edgesWidth: number;
  109506. /**
  109507. * Defines edge color used when edgesRenderer is enabled
  109508. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109509. */
  109510. edgesColor: Color4;
  109511. /** @hidden */
  109512. _edgesRenderer: Nullable<IEdgesRenderer>;
  109513. /** @hidden */
  109514. _masterMesh: Nullable<AbstractMesh>;
  109515. /** @hidden */
  109516. _boundingInfo: Nullable<BoundingInfo>;
  109517. /** @hidden */
  109518. _renderId: number;
  109519. /**
  109520. * Gets or sets the list of subMeshes
  109521. * @see https://doc.babylonjs.com/how_to/multi_materials
  109522. */
  109523. subMeshes: SubMesh[];
  109524. /** @hidden */
  109525. _intersectionsInProgress: AbstractMesh[];
  109526. /** @hidden */
  109527. _unIndexed: boolean;
  109528. /** @hidden */
  109529. _lightSources: Light[];
  109530. /** Gets the list of lights affecting that mesh */
  109531. get lightSources(): Light[];
  109532. /** @hidden */
  109533. get _positions(): Nullable<Vector3[]>;
  109534. /** @hidden */
  109535. _waitingData: {
  109536. lods: Nullable<any>;
  109537. actions: Nullable<any>;
  109538. freezeWorldMatrix: Nullable<boolean>;
  109539. };
  109540. /** @hidden */
  109541. _bonesTransformMatrices: Nullable<Float32Array>;
  109542. /** @hidden */
  109543. _transformMatrixTexture: Nullable<RawTexture>;
  109544. /**
  109545. * Gets or sets a skeleton to apply skining transformations
  109546. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109547. */
  109548. set skeleton(value: Nullable<Skeleton>);
  109549. get skeleton(): Nullable<Skeleton>;
  109550. /**
  109551. * An event triggered when the mesh is rebuilt.
  109552. */
  109553. onRebuildObservable: Observable<AbstractMesh>;
  109554. /**
  109555. * Creates a new AbstractMesh
  109556. * @param name defines the name of the mesh
  109557. * @param scene defines the hosting scene
  109558. */
  109559. constructor(name: string, scene?: Nullable<Scene>);
  109560. /**
  109561. * Returns the string "AbstractMesh"
  109562. * @returns "AbstractMesh"
  109563. */
  109564. getClassName(): string;
  109565. /**
  109566. * Gets a string representation of the current mesh
  109567. * @param fullDetails defines a boolean indicating if full details must be included
  109568. * @returns a string representation of the current mesh
  109569. */
  109570. toString(fullDetails?: boolean): string;
  109571. /**
  109572. * @hidden
  109573. */
  109574. protected _getEffectiveParent(): Nullable<Node>;
  109575. /** @hidden */
  109576. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109577. /** @hidden */
  109578. _rebuild(): void;
  109579. /** @hidden */
  109580. _resyncLightSources(): void;
  109581. /** @hidden */
  109582. _resyncLightSource(light: Light): void;
  109583. /** @hidden */
  109584. _unBindEffect(): void;
  109585. /** @hidden */
  109586. _removeLightSource(light: Light, dispose: boolean): void;
  109587. private _markSubMeshesAsDirty;
  109588. /** @hidden */
  109589. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  109590. /** @hidden */
  109591. _markSubMeshesAsAttributesDirty(): void;
  109592. /** @hidden */
  109593. _markSubMeshesAsMiscDirty(): void;
  109594. /**
  109595. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  109596. */
  109597. get scaling(): Vector3;
  109598. set scaling(newScaling: Vector3);
  109599. /**
  109600. * Returns true if the mesh is blocked. Implemented by child classes
  109601. */
  109602. get isBlocked(): boolean;
  109603. /**
  109604. * Returns the mesh itself by default. Implemented by child classes
  109605. * @param camera defines the camera to use to pick the right LOD level
  109606. * @returns the currentAbstractMesh
  109607. */
  109608. getLOD(camera: Camera): Nullable<AbstractMesh>;
  109609. /**
  109610. * Returns 0 by default. Implemented by child classes
  109611. * @returns an integer
  109612. */
  109613. getTotalVertices(): number;
  109614. /**
  109615. * Returns a positive integer : the total number of indices in this mesh geometry.
  109616. * @returns the numner of indices or zero if the mesh has no geometry.
  109617. */
  109618. getTotalIndices(): number;
  109619. /**
  109620. * Returns null by default. Implemented by child classes
  109621. * @returns null
  109622. */
  109623. getIndices(): Nullable<IndicesArray>;
  109624. /**
  109625. * Returns the array of the requested vertex data kind. Implemented by child classes
  109626. * @param kind defines the vertex data kind to use
  109627. * @returns null
  109628. */
  109629. getVerticesData(kind: string): Nullable<FloatArray>;
  109630. /**
  109631. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109632. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109633. * Note that a new underlying VertexBuffer object is created each call.
  109634. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109635. * @param kind defines vertex data kind:
  109636. * * VertexBuffer.PositionKind
  109637. * * VertexBuffer.UVKind
  109638. * * VertexBuffer.UV2Kind
  109639. * * VertexBuffer.UV3Kind
  109640. * * VertexBuffer.UV4Kind
  109641. * * VertexBuffer.UV5Kind
  109642. * * VertexBuffer.UV6Kind
  109643. * * VertexBuffer.ColorKind
  109644. * * VertexBuffer.MatricesIndicesKind
  109645. * * VertexBuffer.MatricesIndicesExtraKind
  109646. * * VertexBuffer.MatricesWeightsKind
  109647. * * VertexBuffer.MatricesWeightsExtraKind
  109648. * @param data defines the data source
  109649. * @param updatable defines if the data must be flagged as updatable (or static)
  109650. * @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
  109651. * @returns the current mesh
  109652. */
  109653. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109654. /**
  109655. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109656. * If the mesh has no geometry, it is simply returned as it is.
  109657. * @param kind defines vertex data kind:
  109658. * * VertexBuffer.PositionKind
  109659. * * VertexBuffer.UVKind
  109660. * * VertexBuffer.UV2Kind
  109661. * * VertexBuffer.UV3Kind
  109662. * * VertexBuffer.UV4Kind
  109663. * * VertexBuffer.UV5Kind
  109664. * * VertexBuffer.UV6Kind
  109665. * * VertexBuffer.ColorKind
  109666. * * VertexBuffer.MatricesIndicesKind
  109667. * * VertexBuffer.MatricesIndicesExtraKind
  109668. * * VertexBuffer.MatricesWeightsKind
  109669. * * VertexBuffer.MatricesWeightsExtraKind
  109670. * @param data defines the data source
  109671. * @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
  109672. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  109673. * @returns the current mesh
  109674. */
  109675. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109676. /**
  109677. * Sets the mesh indices,
  109678. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109679. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  109680. * @param totalVertices Defines the total number of vertices
  109681. * @returns the current mesh
  109682. */
  109683. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  109684. /**
  109685. * Gets a boolean indicating if specific vertex data is present
  109686. * @param kind defines the vertex data kind to use
  109687. * @returns true is data kind is present
  109688. */
  109689. isVerticesDataPresent(kind: string): boolean;
  109690. /**
  109691. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  109692. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  109693. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  109694. * @returns a BoundingInfo
  109695. */
  109696. getBoundingInfo(): BoundingInfo;
  109697. /**
  109698. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  109699. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  109700. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  109701. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  109702. * @returns the current mesh
  109703. */
  109704. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  109705. /**
  109706. * Overwrite the current bounding info
  109707. * @param boundingInfo defines the new bounding info
  109708. * @returns the current mesh
  109709. */
  109710. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  109711. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  109712. get useBones(): boolean;
  109713. /** @hidden */
  109714. _preActivate(): void;
  109715. /** @hidden */
  109716. _preActivateForIntermediateRendering(renderId: number): void;
  109717. /** @hidden */
  109718. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109719. /** @hidden */
  109720. _postActivate(): void;
  109721. /** @hidden */
  109722. _freeze(): void;
  109723. /** @hidden */
  109724. _unFreeze(): void;
  109725. /**
  109726. * Gets the current world matrix
  109727. * @returns a Matrix
  109728. */
  109729. getWorldMatrix(): Matrix;
  109730. /** @hidden */
  109731. _getWorldMatrixDeterminant(): number;
  109732. /**
  109733. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  109734. */
  109735. get isAnInstance(): boolean;
  109736. /**
  109737. * Gets a boolean indicating if this mesh has instances
  109738. */
  109739. get hasInstances(): boolean;
  109740. /**
  109741. * Gets a boolean indicating if this mesh has thin instances
  109742. */
  109743. get hasThinInstances(): boolean;
  109744. /**
  109745. * Perform relative position change from the point of view of behind the front of the mesh.
  109746. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109747. * Supports definition of mesh facing forward or backward
  109748. * @param amountRight defines the distance on the right axis
  109749. * @param amountUp defines the distance on the up axis
  109750. * @param amountForward defines the distance on the forward axis
  109751. * @returns the current mesh
  109752. */
  109753. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  109754. /**
  109755. * Calculate relative position change from the point of view of behind the front of the mesh.
  109756. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109757. * Supports definition of mesh facing forward or backward
  109758. * @param amountRight defines the distance on the right axis
  109759. * @param amountUp defines the distance on the up axis
  109760. * @param amountForward defines the distance on the forward axis
  109761. * @returns the new displacement vector
  109762. */
  109763. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  109764. /**
  109765. * Perform relative rotation change from the point of view of behind the front of the mesh.
  109766. * Supports definition of mesh facing forward or backward
  109767. * @param flipBack defines the flip
  109768. * @param twirlClockwise defines the twirl
  109769. * @param tiltRight defines the tilt
  109770. * @returns the current mesh
  109771. */
  109772. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  109773. /**
  109774. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  109775. * Supports definition of mesh facing forward or backward.
  109776. * @param flipBack defines the flip
  109777. * @param twirlClockwise defines the twirl
  109778. * @param tiltRight defines the tilt
  109779. * @returns the new rotation vector
  109780. */
  109781. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  109782. /**
  109783. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109784. * This means the mesh underlying bounding box and sphere are recomputed.
  109785. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109786. * @returns the current mesh
  109787. */
  109788. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  109789. /** @hidden */
  109790. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  109791. /** @hidden */
  109792. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  109793. /** @hidden */
  109794. _updateBoundingInfo(): AbstractMesh;
  109795. /** @hidden */
  109796. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  109797. /** @hidden */
  109798. protected _afterComputeWorldMatrix(): void;
  109799. /** @hidden */
  109800. get _effectiveMesh(): AbstractMesh;
  109801. /**
  109802. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109803. * A mesh is in the frustum if its bounding box intersects the frustum
  109804. * @param frustumPlanes defines the frustum to test
  109805. * @returns true if the mesh is in the frustum planes
  109806. */
  109807. isInFrustum(frustumPlanes: Plane[]): boolean;
  109808. /**
  109809. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  109810. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  109811. * @param frustumPlanes defines the frustum to test
  109812. * @returns true if the mesh is completely in the frustum planes
  109813. */
  109814. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  109815. /**
  109816. * True if the mesh intersects another mesh or a SolidParticle object
  109817. * @param mesh defines a target mesh or SolidParticle to test
  109818. * @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)
  109819. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  109820. * @returns true if there is an intersection
  109821. */
  109822. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  109823. /**
  109824. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  109825. * @param point defines the point to test
  109826. * @returns true if there is an intersection
  109827. */
  109828. intersectsPoint(point: Vector3): boolean;
  109829. /**
  109830. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  109831. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109832. */
  109833. get checkCollisions(): boolean;
  109834. set checkCollisions(collisionEnabled: boolean);
  109835. /**
  109836. * Gets Collider object used to compute collisions (not physics)
  109837. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109838. */
  109839. get collider(): Nullable<Collider>;
  109840. /**
  109841. * Move the mesh using collision engine
  109842. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109843. * @param displacement defines the requested displacement vector
  109844. * @returns the current mesh
  109845. */
  109846. moveWithCollisions(displacement: Vector3): AbstractMesh;
  109847. private _onCollisionPositionChange;
  109848. /** @hidden */
  109849. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  109850. /** @hidden */
  109851. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  109852. /** @hidden */
  109853. _checkCollision(collider: Collider): AbstractMesh;
  109854. /** @hidden */
  109855. _generatePointsArray(): boolean;
  109856. /**
  109857. * Checks if the passed Ray intersects with the mesh
  109858. * @param ray defines the ray to use
  109859. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  109860. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109861. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  109862. * @returns the picking info
  109863. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  109864. */
  109865. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  109866. /**
  109867. * Clones the current mesh
  109868. * @param name defines the mesh name
  109869. * @param newParent defines the new mesh parent
  109870. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  109871. * @returns the new mesh
  109872. */
  109873. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  109874. /**
  109875. * Disposes all the submeshes of the current meshnp
  109876. * @returns the current mesh
  109877. */
  109878. releaseSubMeshes(): AbstractMesh;
  109879. /**
  109880. * Releases resources associated with this abstract mesh.
  109881. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109882. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109883. */
  109884. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109885. /**
  109886. * Adds the passed mesh as a child to the current mesh
  109887. * @param mesh defines the child mesh
  109888. * @returns the current mesh
  109889. */
  109890. addChild(mesh: AbstractMesh): AbstractMesh;
  109891. /**
  109892. * Removes the passed mesh from the current mesh children list
  109893. * @param mesh defines the child mesh
  109894. * @returns the current mesh
  109895. */
  109896. removeChild(mesh: AbstractMesh): AbstractMesh;
  109897. /** @hidden */
  109898. private _initFacetData;
  109899. /**
  109900. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  109901. * This method can be called within the render loop.
  109902. * 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
  109903. * @returns the current mesh
  109904. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109905. */
  109906. updateFacetData(): AbstractMesh;
  109907. /**
  109908. * Returns the facetLocalNormals array.
  109909. * The normals are expressed in the mesh local spac
  109910. * @returns an array of Vector3
  109911. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109912. */
  109913. getFacetLocalNormals(): Vector3[];
  109914. /**
  109915. * Returns the facetLocalPositions array.
  109916. * The facet positions are expressed in the mesh local space
  109917. * @returns an array of Vector3
  109918. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109919. */
  109920. getFacetLocalPositions(): Vector3[];
  109921. /**
  109922. * Returns the facetLocalPartioning array
  109923. * @returns an array of array of numbers
  109924. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109925. */
  109926. getFacetLocalPartitioning(): number[][];
  109927. /**
  109928. * Returns the i-th facet position in the world system.
  109929. * This method allocates a new Vector3 per call
  109930. * @param i defines the facet index
  109931. * @returns a new Vector3
  109932. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109933. */
  109934. getFacetPosition(i: number): Vector3;
  109935. /**
  109936. * Sets the reference Vector3 with the i-th facet position in the world system
  109937. * @param i defines the facet index
  109938. * @param ref defines the target vector
  109939. * @returns the current mesh
  109940. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109941. */
  109942. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  109943. /**
  109944. * Returns the i-th facet normal in the world system.
  109945. * This method allocates a new Vector3 per call
  109946. * @param i defines the facet index
  109947. * @returns a new Vector3
  109948. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109949. */
  109950. getFacetNormal(i: number): Vector3;
  109951. /**
  109952. * Sets the reference Vector3 with the i-th facet normal in the world system
  109953. * @param i defines the facet index
  109954. * @param ref defines the target vector
  109955. * @returns the current mesh
  109956. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109957. */
  109958. getFacetNormalToRef(i: number, ref: Vector3): this;
  109959. /**
  109960. * 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)
  109961. * @param x defines x coordinate
  109962. * @param y defines y coordinate
  109963. * @param z defines z coordinate
  109964. * @returns the array of facet indexes
  109965. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109966. */
  109967. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  109968. /**
  109969. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  109970. * @param projected sets as the (x,y,z) world projection on the facet
  109971. * @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
  109972. * @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
  109973. * @param x defines x coordinate
  109974. * @param y defines y coordinate
  109975. * @param z defines z coordinate
  109976. * @returns the face index if found (or null instead)
  109977. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109978. */
  109979. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109980. /**
  109981. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  109982. * @param projected sets as the (x,y,z) local projection on the facet
  109983. * @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
  109984. * @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
  109985. * @param x defines x coordinate
  109986. * @param y defines y coordinate
  109987. * @param z defines z coordinate
  109988. * @returns the face index if found (or null instead)
  109989. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109990. */
  109991. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109992. /**
  109993. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  109994. * @returns the parameters
  109995. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109996. */
  109997. getFacetDataParameters(): any;
  109998. /**
  109999. * Disables the feature FacetData and frees the related memory
  110000. * @returns the current mesh
  110001. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110002. */
  110003. disableFacetData(): AbstractMesh;
  110004. /**
  110005. * Updates the AbstractMesh indices array
  110006. * @param indices defines the data source
  110007. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  110008. * @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)
  110009. * @returns the current mesh
  110010. */
  110011. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  110012. /**
  110013. * Creates new normals data for the mesh
  110014. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  110015. * @returns the current mesh
  110016. */
  110017. createNormals(updatable: boolean): AbstractMesh;
  110018. /**
  110019. * Align the mesh with a normal
  110020. * @param normal defines the normal to use
  110021. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  110022. * @returns the current mesh
  110023. */
  110024. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  110025. /** @hidden */
  110026. _checkOcclusionQuery(): boolean;
  110027. /**
  110028. * Disables the mesh edge rendering mode
  110029. * @returns the currentAbstractMesh
  110030. */
  110031. disableEdgesRendering(): AbstractMesh;
  110032. /**
  110033. * Enables the edge rendering mode on the mesh.
  110034. * This mode makes the mesh edges visible
  110035. * @param epsilon defines the maximal distance between two angles to detect a face
  110036. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  110037. * @returns the currentAbstractMesh
  110038. * @see https://www.babylonjs-playground.com/#19O9TU#0
  110039. */
  110040. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  110041. /**
  110042. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  110043. * @returns an array of particle systems in the scene that use the mesh as an emitter
  110044. */
  110045. getConnectedParticleSystems(): IParticleSystem[];
  110046. }
  110047. }
  110048. declare module BABYLON {
  110049. /**
  110050. * Interface used to define ActionEvent
  110051. */
  110052. export interface IActionEvent {
  110053. /** The mesh or sprite that triggered the action */
  110054. source: any;
  110055. /** The X mouse cursor position at the time of the event */
  110056. pointerX: number;
  110057. /** The Y mouse cursor position at the time of the event */
  110058. pointerY: number;
  110059. /** The mesh that is currently pointed at (can be null) */
  110060. meshUnderPointer: Nullable<AbstractMesh>;
  110061. /** the original (browser) event that triggered the ActionEvent */
  110062. sourceEvent?: any;
  110063. /** additional data for the event */
  110064. additionalData?: any;
  110065. }
  110066. /**
  110067. * ActionEvent is the event being sent when an action is triggered.
  110068. */
  110069. export class ActionEvent implements IActionEvent {
  110070. /** The mesh or sprite that triggered the action */
  110071. source: any;
  110072. /** The X mouse cursor position at the time of the event */
  110073. pointerX: number;
  110074. /** The Y mouse cursor position at the time of the event */
  110075. pointerY: number;
  110076. /** The mesh that is currently pointed at (can be null) */
  110077. meshUnderPointer: Nullable<AbstractMesh>;
  110078. /** the original (browser) event that triggered the ActionEvent */
  110079. sourceEvent?: any;
  110080. /** additional data for the event */
  110081. additionalData?: any;
  110082. /**
  110083. * Creates a new ActionEvent
  110084. * @param source The mesh or sprite that triggered the action
  110085. * @param pointerX The X mouse cursor position at the time of the event
  110086. * @param pointerY The Y mouse cursor position at the time of the event
  110087. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  110088. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  110089. * @param additionalData additional data for the event
  110090. */
  110091. constructor(
  110092. /** The mesh or sprite that triggered the action */
  110093. source: any,
  110094. /** The X mouse cursor position at the time of the event */
  110095. pointerX: number,
  110096. /** The Y mouse cursor position at the time of the event */
  110097. pointerY: number,
  110098. /** The mesh that is currently pointed at (can be null) */
  110099. meshUnderPointer: Nullable<AbstractMesh>,
  110100. /** the original (browser) event that triggered the ActionEvent */
  110101. sourceEvent?: any,
  110102. /** additional data for the event */
  110103. additionalData?: any);
  110104. /**
  110105. * Helper function to auto-create an ActionEvent from a source mesh.
  110106. * @param source The source mesh that triggered the event
  110107. * @param evt The original (browser) event
  110108. * @param additionalData additional data for the event
  110109. * @returns the new ActionEvent
  110110. */
  110111. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  110112. /**
  110113. * Helper function to auto-create an ActionEvent from a source sprite
  110114. * @param source The source sprite that triggered the event
  110115. * @param scene Scene associated with the sprite
  110116. * @param evt The original (browser) event
  110117. * @param additionalData additional data for the event
  110118. * @returns the new ActionEvent
  110119. */
  110120. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  110121. /**
  110122. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  110123. * @param scene the scene where the event occurred
  110124. * @param evt The original (browser) event
  110125. * @returns the new ActionEvent
  110126. */
  110127. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  110128. /**
  110129. * Helper function to auto-create an ActionEvent from a primitive
  110130. * @param prim defines the target primitive
  110131. * @param pointerPos defines the pointer position
  110132. * @param evt The original (browser) event
  110133. * @param additionalData additional data for the event
  110134. * @returns the new ActionEvent
  110135. */
  110136. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  110137. }
  110138. }
  110139. declare module BABYLON {
  110140. /**
  110141. * Abstract class used to decouple action Manager from scene and meshes.
  110142. * Do not instantiate.
  110143. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  110144. */
  110145. export abstract class AbstractActionManager implements IDisposable {
  110146. /** Gets the list of active triggers */
  110147. static Triggers: {
  110148. [key: string]: number;
  110149. };
  110150. /** Gets the cursor to use when hovering items */
  110151. hoverCursor: string;
  110152. /** Gets the list of actions */
  110153. actions: IAction[];
  110154. /**
  110155. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  110156. */
  110157. isRecursive: boolean;
  110158. /**
  110159. * Releases all associated resources
  110160. */
  110161. abstract dispose(): void;
  110162. /**
  110163. * Does this action manager has pointer triggers
  110164. */
  110165. abstract get hasPointerTriggers(): boolean;
  110166. /**
  110167. * Does this action manager has pick triggers
  110168. */
  110169. abstract get hasPickTriggers(): boolean;
  110170. /**
  110171. * Process a specific trigger
  110172. * @param trigger defines the trigger to process
  110173. * @param evt defines the event details to be processed
  110174. */
  110175. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  110176. /**
  110177. * Does this action manager handles actions of any of the given triggers
  110178. * @param triggers defines the triggers to be tested
  110179. * @return a boolean indicating whether one (or more) of the triggers is handled
  110180. */
  110181. abstract hasSpecificTriggers(triggers: number[]): boolean;
  110182. /**
  110183. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  110184. * speed.
  110185. * @param triggerA defines the trigger to be tested
  110186. * @param triggerB defines the trigger to be tested
  110187. * @return a boolean indicating whether one (or more) of the triggers is handled
  110188. */
  110189. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  110190. /**
  110191. * Does this action manager handles actions of a given trigger
  110192. * @param trigger defines the trigger to be tested
  110193. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  110194. * @return whether the trigger is handled
  110195. */
  110196. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  110197. /**
  110198. * Serialize this manager to a JSON object
  110199. * @param name defines the property name to store this manager
  110200. * @returns a JSON representation of this manager
  110201. */
  110202. abstract serialize(name: string): any;
  110203. /**
  110204. * Registers an action to this action manager
  110205. * @param action defines the action to be registered
  110206. * @return the action amended (prepared) after registration
  110207. */
  110208. abstract registerAction(action: IAction): Nullable<IAction>;
  110209. /**
  110210. * Unregisters an action to this action manager
  110211. * @param action defines the action to be unregistered
  110212. * @return a boolean indicating whether the action has been unregistered
  110213. */
  110214. abstract unregisterAction(action: IAction): Boolean;
  110215. /**
  110216. * Does exist one action manager with at least one trigger
  110217. **/
  110218. static get HasTriggers(): boolean;
  110219. /**
  110220. * Does exist one action manager with at least one pick trigger
  110221. **/
  110222. static get HasPickTriggers(): boolean;
  110223. /**
  110224. * Does exist one action manager that handles actions of a given trigger
  110225. * @param trigger defines the trigger to be tested
  110226. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  110227. **/
  110228. static HasSpecificTrigger(trigger: number): boolean;
  110229. }
  110230. }
  110231. declare module BABYLON {
  110232. /**
  110233. * Defines how a node can be built from a string name.
  110234. */
  110235. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  110236. /**
  110237. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  110238. */
  110239. export class Node implements IBehaviorAware<Node> {
  110240. /** @hidden */
  110241. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  110242. private static _NodeConstructors;
  110243. /**
  110244. * Add a new node constructor
  110245. * @param type defines the type name of the node to construct
  110246. * @param constructorFunc defines the constructor function
  110247. */
  110248. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  110249. /**
  110250. * Returns a node constructor based on type name
  110251. * @param type defines the type name
  110252. * @param name defines the new node name
  110253. * @param scene defines the hosting scene
  110254. * @param options defines optional options to transmit to constructors
  110255. * @returns the new constructor or null
  110256. */
  110257. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  110258. /**
  110259. * Gets or sets the name of the node
  110260. */
  110261. name: string;
  110262. /**
  110263. * Gets or sets the id of the node
  110264. */
  110265. id: string;
  110266. /**
  110267. * Gets or sets the unique id of the node
  110268. */
  110269. uniqueId: number;
  110270. /**
  110271. * Gets or sets a string used to store user defined state for the node
  110272. */
  110273. state: string;
  110274. /**
  110275. * Gets or sets an object used to store user defined information for the node
  110276. */
  110277. metadata: any;
  110278. /**
  110279. * For internal use only. Please do not use.
  110280. */
  110281. reservedDataStore: any;
  110282. /**
  110283. * List of inspectable custom properties (used by the Inspector)
  110284. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110285. */
  110286. inspectableCustomProperties: IInspectable[];
  110287. private _doNotSerialize;
  110288. /**
  110289. * Gets or sets a boolean used to define if the node must be serialized
  110290. */
  110291. get doNotSerialize(): boolean;
  110292. set doNotSerialize(value: boolean);
  110293. /** @hidden */
  110294. _isDisposed: boolean;
  110295. /**
  110296. * Gets a list of Animations associated with the node
  110297. */
  110298. animations: Animation[];
  110299. protected _ranges: {
  110300. [name: string]: Nullable<AnimationRange>;
  110301. };
  110302. /**
  110303. * Callback raised when the node is ready to be used
  110304. */
  110305. onReady: Nullable<(node: Node) => void>;
  110306. private _isEnabled;
  110307. private _isParentEnabled;
  110308. private _isReady;
  110309. /** @hidden */
  110310. _currentRenderId: number;
  110311. private _parentUpdateId;
  110312. /** @hidden */
  110313. _childUpdateId: number;
  110314. /** @hidden */
  110315. _waitingParentId: Nullable<string>;
  110316. /** @hidden */
  110317. _scene: Scene;
  110318. /** @hidden */
  110319. _cache: any;
  110320. private _parentNode;
  110321. private _children;
  110322. /** @hidden */
  110323. _worldMatrix: Matrix;
  110324. /** @hidden */
  110325. _worldMatrixDeterminant: number;
  110326. /** @hidden */
  110327. _worldMatrixDeterminantIsDirty: boolean;
  110328. /** @hidden */
  110329. private _sceneRootNodesIndex;
  110330. /**
  110331. * Gets a boolean indicating if the node has been disposed
  110332. * @returns true if the node was disposed
  110333. */
  110334. isDisposed(): boolean;
  110335. /**
  110336. * Gets or sets the parent of the node (without keeping the current position in the scene)
  110337. * @see https://doc.babylonjs.com/how_to/parenting
  110338. */
  110339. set parent(parent: Nullable<Node>);
  110340. get parent(): Nullable<Node>;
  110341. /** @hidden */
  110342. _addToSceneRootNodes(): void;
  110343. /** @hidden */
  110344. _removeFromSceneRootNodes(): void;
  110345. private _animationPropertiesOverride;
  110346. /**
  110347. * Gets or sets the animation properties override
  110348. */
  110349. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  110350. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  110351. /**
  110352. * Gets a string idenfifying the name of the class
  110353. * @returns "Node" string
  110354. */
  110355. getClassName(): string;
  110356. /** @hidden */
  110357. readonly _isNode: boolean;
  110358. /**
  110359. * An event triggered when the mesh is disposed
  110360. */
  110361. onDisposeObservable: Observable<Node>;
  110362. private _onDisposeObserver;
  110363. /**
  110364. * Sets a callback that will be raised when the node will be disposed
  110365. */
  110366. set onDispose(callback: () => void);
  110367. /**
  110368. * Creates a new Node
  110369. * @param name the name and id to be given to this node
  110370. * @param scene the scene this node will be added to
  110371. */
  110372. constructor(name: string, scene?: Nullable<Scene>);
  110373. /**
  110374. * Gets the scene of the node
  110375. * @returns a scene
  110376. */
  110377. getScene(): Scene;
  110378. /**
  110379. * Gets the engine of the node
  110380. * @returns a Engine
  110381. */
  110382. getEngine(): Engine;
  110383. private _behaviors;
  110384. /**
  110385. * Attach a behavior to the node
  110386. * @see https://doc.babylonjs.com/features/behaviour
  110387. * @param behavior defines the behavior to attach
  110388. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  110389. * @returns the current Node
  110390. */
  110391. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  110392. /**
  110393. * Remove an attached behavior
  110394. * @see https://doc.babylonjs.com/features/behaviour
  110395. * @param behavior defines the behavior to attach
  110396. * @returns the current Node
  110397. */
  110398. removeBehavior(behavior: Behavior<Node>): Node;
  110399. /**
  110400. * Gets the list of attached behaviors
  110401. * @see https://doc.babylonjs.com/features/behaviour
  110402. */
  110403. get behaviors(): Behavior<Node>[];
  110404. /**
  110405. * Gets an attached behavior by name
  110406. * @param name defines the name of the behavior to look for
  110407. * @see https://doc.babylonjs.com/features/behaviour
  110408. * @returns null if behavior was not found else the requested behavior
  110409. */
  110410. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  110411. /**
  110412. * Returns the latest update of the World matrix
  110413. * @returns a Matrix
  110414. */
  110415. getWorldMatrix(): Matrix;
  110416. /** @hidden */
  110417. _getWorldMatrixDeterminant(): number;
  110418. /**
  110419. * Returns directly the latest state of the mesh World matrix.
  110420. * A Matrix is returned.
  110421. */
  110422. get worldMatrixFromCache(): Matrix;
  110423. /** @hidden */
  110424. _initCache(): void;
  110425. /** @hidden */
  110426. updateCache(force?: boolean): void;
  110427. /** @hidden */
  110428. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  110429. /** @hidden */
  110430. _updateCache(ignoreParentClass?: boolean): void;
  110431. /** @hidden */
  110432. _isSynchronized(): boolean;
  110433. /** @hidden */
  110434. _markSyncedWithParent(): void;
  110435. /** @hidden */
  110436. isSynchronizedWithParent(): boolean;
  110437. /** @hidden */
  110438. isSynchronized(): boolean;
  110439. /**
  110440. * Is this node ready to be used/rendered
  110441. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  110442. * @return true if the node is ready
  110443. */
  110444. isReady(completeCheck?: boolean): boolean;
  110445. /**
  110446. * Is this node enabled?
  110447. * 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
  110448. * @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
  110449. * @return whether this node (and its parent) is enabled
  110450. */
  110451. isEnabled(checkAncestors?: boolean): boolean;
  110452. /** @hidden */
  110453. protected _syncParentEnabledState(): void;
  110454. /**
  110455. * Set the enabled state of this node
  110456. * @param value defines the new enabled state
  110457. */
  110458. setEnabled(value: boolean): void;
  110459. /**
  110460. * Is this node a descendant of the given node?
  110461. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  110462. * @param ancestor defines the parent node to inspect
  110463. * @returns a boolean indicating if this node is a descendant of the given node
  110464. */
  110465. isDescendantOf(ancestor: Node): boolean;
  110466. /** @hidden */
  110467. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  110468. /**
  110469. * Will return all nodes that have this node as ascendant
  110470. * @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
  110471. * @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
  110472. * @return all children nodes of all types
  110473. */
  110474. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  110475. /**
  110476. * Get all child-meshes of this node
  110477. * @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)
  110478. * @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
  110479. * @returns an array of AbstractMesh
  110480. */
  110481. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  110482. /**
  110483. * Get all direct children of this node
  110484. * @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
  110485. * @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)
  110486. * @returns an array of Node
  110487. */
  110488. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  110489. /** @hidden */
  110490. _setReady(state: boolean): void;
  110491. /**
  110492. * Get an animation by name
  110493. * @param name defines the name of the animation to look for
  110494. * @returns null if not found else the requested animation
  110495. */
  110496. getAnimationByName(name: string): Nullable<Animation>;
  110497. /**
  110498. * Creates an animation range for this node
  110499. * @param name defines the name of the range
  110500. * @param from defines the starting key
  110501. * @param to defines the end key
  110502. */
  110503. createAnimationRange(name: string, from: number, to: number): void;
  110504. /**
  110505. * Delete a specific animation range
  110506. * @param name defines the name of the range to delete
  110507. * @param deleteFrames defines if animation frames from the range must be deleted as well
  110508. */
  110509. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  110510. /**
  110511. * Get an animation range by name
  110512. * @param name defines the name of the animation range to look for
  110513. * @returns null if not found else the requested animation range
  110514. */
  110515. getAnimationRange(name: string): Nullable<AnimationRange>;
  110516. /**
  110517. * Gets the list of all animation ranges defined on this node
  110518. * @returns an array
  110519. */
  110520. getAnimationRanges(): Nullable<AnimationRange>[];
  110521. /**
  110522. * Will start the animation sequence
  110523. * @param name defines the range frames for animation sequence
  110524. * @param loop defines if the animation should loop (false by default)
  110525. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  110526. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  110527. * @returns the object created for this animation. If range does not exist, it will return null
  110528. */
  110529. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  110530. /**
  110531. * Serialize animation ranges into a JSON compatible object
  110532. * @returns serialization object
  110533. */
  110534. serializeAnimationRanges(): any;
  110535. /**
  110536. * Computes the world matrix of the node
  110537. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  110538. * @returns the world matrix
  110539. */
  110540. computeWorldMatrix(force?: boolean): Matrix;
  110541. /**
  110542. * Releases resources associated with this node.
  110543. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110544. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110545. */
  110546. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110547. /**
  110548. * Parse animation range data from a serialization object and store them into a given node
  110549. * @param node defines where to store the animation ranges
  110550. * @param parsedNode defines the serialization object to read data from
  110551. * @param scene defines the hosting scene
  110552. */
  110553. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  110554. /**
  110555. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  110556. * @param includeDescendants Include bounding info from descendants as well (true by default)
  110557. * @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
  110558. * @returns the new bounding vectors
  110559. */
  110560. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  110561. min: Vector3;
  110562. max: Vector3;
  110563. };
  110564. }
  110565. }
  110566. declare module BABYLON {
  110567. /**
  110568. * @hidden
  110569. */
  110570. export class _IAnimationState {
  110571. key: number;
  110572. repeatCount: number;
  110573. workValue?: any;
  110574. loopMode?: number;
  110575. offsetValue?: any;
  110576. highLimitValue?: any;
  110577. }
  110578. /**
  110579. * Class used to store any kind of animation
  110580. */
  110581. export class Animation {
  110582. /**Name of the animation */
  110583. name: string;
  110584. /**Property to animate */
  110585. targetProperty: string;
  110586. /**The frames per second of the animation */
  110587. framePerSecond: number;
  110588. /**The data type of the animation */
  110589. dataType: number;
  110590. /**The loop mode of the animation */
  110591. loopMode?: number | undefined;
  110592. /**Specifies if blending should be enabled */
  110593. enableBlending?: boolean | undefined;
  110594. /**
  110595. * Use matrix interpolation instead of using direct key value when animating matrices
  110596. */
  110597. static AllowMatricesInterpolation: boolean;
  110598. /**
  110599. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  110600. */
  110601. static AllowMatrixDecomposeForInterpolation: boolean;
  110602. /** Define the Url to load snippets */
  110603. static SnippetUrl: string;
  110604. /** Snippet ID if the animation was created from the snippet server */
  110605. snippetId: string;
  110606. /**
  110607. * Stores the key frames of the animation
  110608. */
  110609. private _keys;
  110610. /**
  110611. * Stores the easing function of the animation
  110612. */
  110613. private _easingFunction;
  110614. /**
  110615. * @hidden Internal use only
  110616. */
  110617. _runtimeAnimations: RuntimeAnimation[];
  110618. /**
  110619. * The set of event that will be linked to this animation
  110620. */
  110621. private _events;
  110622. /**
  110623. * Stores an array of target property paths
  110624. */
  110625. targetPropertyPath: string[];
  110626. /**
  110627. * Stores the blending speed of the animation
  110628. */
  110629. blendingSpeed: number;
  110630. /**
  110631. * Stores the animation ranges for the animation
  110632. */
  110633. private _ranges;
  110634. /**
  110635. * @hidden Internal use
  110636. */
  110637. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  110638. /**
  110639. * Sets up an animation
  110640. * @param property The property to animate
  110641. * @param animationType The animation type to apply
  110642. * @param framePerSecond The frames per second of the animation
  110643. * @param easingFunction The easing function used in the animation
  110644. * @returns The created animation
  110645. */
  110646. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  110647. /**
  110648. * Create and start an animation on a node
  110649. * @param name defines the name of the global animation that will be run on all nodes
  110650. * @param node defines the root node where the animation will take place
  110651. * @param targetProperty defines property to animate
  110652. * @param framePerSecond defines the number of frame per second yo use
  110653. * @param totalFrame defines the number of frames in total
  110654. * @param from defines the initial value
  110655. * @param to defines the final value
  110656. * @param loopMode defines which loop mode you want to use (off by default)
  110657. * @param easingFunction defines the easing function to use (linear by default)
  110658. * @param onAnimationEnd defines the callback to call when animation end
  110659. * @returns the animatable created for this animation
  110660. */
  110661. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110662. /**
  110663. * Create and start an animation on a node and its descendants
  110664. * @param name defines the name of the global animation that will be run on all nodes
  110665. * @param node defines the root node where the animation will take place
  110666. * @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
  110667. * @param targetProperty defines property to animate
  110668. * @param framePerSecond defines the number of frame per second to use
  110669. * @param totalFrame defines the number of frames in total
  110670. * @param from defines the initial value
  110671. * @param to defines the final value
  110672. * @param loopMode defines which loop mode you want to use (off by default)
  110673. * @param easingFunction defines the easing function to use (linear by default)
  110674. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110675. * @returns the list of animatables created for all nodes
  110676. * @example https://www.babylonjs-playground.com/#MH0VLI
  110677. */
  110678. 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[]>;
  110679. /**
  110680. * Creates a new animation, merges it with the existing animations and starts it
  110681. * @param name Name of the animation
  110682. * @param node Node which contains the scene that begins the animations
  110683. * @param targetProperty Specifies which property to animate
  110684. * @param framePerSecond The frames per second of the animation
  110685. * @param totalFrame The total number of frames
  110686. * @param from The frame at the beginning of the animation
  110687. * @param to The frame at the end of the animation
  110688. * @param loopMode Specifies the loop mode of the animation
  110689. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  110690. * @param onAnimationEnd Callback to run once the animation is complete
  110691. * @returns Nullable animation
  110692. */
  110693. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110694. /**
  110695. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  110696. * @param sourceAnimation defines the Animation containing keyframes to convert
  110697. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110698. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  110699. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  110700. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  110701. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  110702. */
  110703. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  110704. /**
  110705. * Transition property of an host to the target Value
  110706. * @param property The property to transition
  110707. * @param targetValue The target Value of the property
  110708. * @param host The object where the property to animate belongs
  110709. * @param scene Scene used to run the animation
  110710. * @param frameRate Framerate (in frame/s) to use
  110711. * @param transition The transition type we want to use
  110712. * @param duration The duration of the animation, in milliseconds
  110713. * @param onAnimationEnd Callback trigger at the end of the animation
  110714. * @returns Nullable animation
  110715. */
  110716. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  110717. /**
  110718. * Return the array of runtime animations currently using this animation
  110719. */
  110720. get runtimeAnimations(): RuntimeAnimation[];
  110721. /**
  110722. * Specifies if any of the runtime animations are currently running
  110723. */
  110724. get hasRunningRuntimeAnimations(): boolean;
  110725. /**
  110726. * Initializes the animation
  110727. * @param name Name of the animation
  110728. * @param targetProperty Property to animate
  110729. * @param framePerSecond The frames per second of the animation
  110730. * @param dataType The data type of the animation
  110731. * @param loopMode The loop mode of the animation
  110732. * @param enableBlending Specifies if blending should be enabled
  110733. */
  110734. constructor(
  110735. /**Name of the animation */
  110736. name: string,
  110737. /**Property to animate */
  110738. targetProperty: string,
  110739. /**The frames per second of the animation */
  110740. framePerSecond: number,
  110741. /**The data type of the animation */
  110742. dataType: number,
  110743. /**The loop mode of the animation */
  110744. loopMode?: number | undefined,
  110745. /**Specifies if blending should be enabled */
  110746. enableBlending?: boolean | undefined);
  110747. /**
  110748. * Converts the animation to a string
  110749. * @param fullDetails support for multiple levels of logging within scene loading
  110750. * @returns String form of the animation
  110751. */
  110752. toString(fullDetails?: boolean): string;
  110753. /**
  110754. * Add an event to this animation
  110755. * @param event Event to add
  110756. */
  110757. addEvent(event: AnimationEvent): void;
  110758. /**
  110759. * Remove all events found at the given frame
  110760. * @param frame The frame to remove events from
  110761. */
  110762. removeEvents(frame: number): void;
  110763. /**
  110764. * Retrieves all the events from the animation
  110765. * @returns Events from the animation
  110766. */
  110767. getEvents(): AnimationEvent[];
  110768. /**
  110769. * Creates an animation range
  110770. * @param name Name of the animation range
  110771. * @param from Starting frame of the animation range
  110772. * @param to Ending frame of the animation
  110773. */
  110774. createRange(name: string, from: number, to: number): void;
  110775. /**
  110776. * Deletes an animation range by name
  110777. * @param name Name of the animation range to delete
  110778. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  110779. */
  110780. deleteRange(name: string, deleteFrames?: boolean): void;
  110781. /**
  110782. * Gets the animation range by name, or null if not defined
  110783. * @param name Name of the animation range
  110784. * @returns Nullable animation range
  110785. */
  110786. getRange(name: string): Nullable<AnimationRange>;
  110787. /**
  110788. * Gets the key frames from the animation
  110789. * @returns The key frames of the animation
  110790. */
  110791. getKeys(): Array<IAnimationKey>;
  110792. /**
  110793. * Gets the highest frame rate of the animation
  110794. * @returns Highest frame rate of the animation
  110795. */
  110796. getHighestFrame(): number;
  110797. /**
  110798. * Gets the easing function of the animation
  110799. * @returns Easing function of the animation
  110800. */
  110801. getEasingFunction(): IEasingFunction;
  110802. /**
  110803. * Sets the easing function of the animation
  110804. * @param easingFunction A custom mathematical formula for animation
  110805. */
  110806. setEasingFunction(easingFunction: EasingFunction): void;
  110807. /**
  110808. * Interpolates a scalar linearly
  110809. * @param startValue Start value of the animation curve
  110810. * @param endValue End value of the animation curve
  110811. * @param gradient Scalar amount to interpolate
  110812. * @returns Interpolated scalar value
  110813. */
  110814. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  110815. /**
  110816. * Interpolates a scalar cubically
  110817. * @param startValue Start value of the animation curve
  110818. * @param outTangent End tangent of the animation
  110819. * @param endValue End value of the animation curve
  110820. * @param inTangent Start tangent of the animation curve
  110821. * @param gradient Scalar amount to interpolate
  110822. * @returns Interpolated scalar value
  110823. */
  110824. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  110825. /**
  110826. * Interpolates a quaternion using a spherical linear interpolation
  110827. * @param startValue Start value of the animation curve
  110828. * @param endValue End value of the animation curve
  110829. * @param gradient Scalar amount to interpolate
  110830. * @returns Interpolated quaternion value
  110831. */
  110832. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  110833. /**
  110834. * Interpolates a quaternion cubically
  110835. * @param startValue Start value of the animation curve
  110836. * @param outTangent End tangent of the animation curve
  110837. * @param endValue End value of the animation curve
  110838. * @param inTangent Start tangent of the animation curve
  110839. * @param gradient Scalar amount to interpolate
  110840. * @returns Interpolated quaternion value
  110841. */
  110842. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  110843. /**
  110844. * Interpolates a Vector3 linearl
  110845. * @param startValue Start value of the animation curve
  110846. * @param endValue End value of the animation curve
  110847. * @param gradient Scalar amount to interpolate
  110848. * @returns Interpolated scalar value
  110849. */
  110850. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  110851. /**
  110852. * Interpolates a Vector3 cubically
  110853. * @param startValue Start value of the animation curve
  110854. * @param outTangent End tangent of the animation
  110855. * @param endValue End value of the animation curve
  110856. * @param inTangent Start tangent of the animation curve
  110857. * @param gradient Scalar amount to interpolate
  110858. * @returns InterpolatedVector3 value
  110859. */
  110860. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  110861. /**
  110862. * Interpolates a Vector2 linearly
  110863. * @param startValue Start value of the animation curve
  110864. * @param endValue End value of the animation curve
  110865. * @param gradient Scalar amount to interpolate
  110866. * @returns Interpolated Vector2 value
  110867. */
  110868. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  110869. /**
  110870. * Interpolates a Vector2 cubically
  110871. * @param startValue Start value of the animation curve
  110872. * @param outTangent End tangent of the animation
  110873. * @param endValue End value of the animation curve
  110874. * @param inTangent Start tangent of the animation curve
  110875. * @param gradient Scalar amount to interpolate
  110876. * @returns Interpolated Vector2 value
  110877. */
  110878. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  110879. /**
  110880. * Interpolates a size linearly
  110881. * @param startValue Start value of the animation curve
  110882. * @param endValue End value of the animation curve
  110883. * @param gradient Scalar amount to interpolate
  110884. * @returns Interpolated Size value
  110885. */
  110886. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  110887. /**
  110888. * Interpolates a Color3 linearly
  110889. * @param startValue Start value of the animation curve
  110890. * @param endValue End value of the animation curve
  110891. * @param gradient Scalar amount to interpolate
  110892. * @returns Interpolated Color3 value
  110893. */
  110894. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  110895. /**
  110896. * Interpolates a Color4 linearly
  110897. * @param startValue Start value of the animation curve
  110898. * @param endValue End value of the animation curve
  110899. * @param gradient Scalar amount to interpolate
  110900. * @returns Interpolated Color3 value
  110901. */
  110902. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  110903. /**
  110904. * @hidden Internal use only
  110905. */
  110906. _getKeyValue(value: any): any;
  110907. /**
  110908. * @hidden Internal use only
  110909. */
  110910. _interpolate(currentFrame: number, state: _IAnimationState): any;
  110911. /**
  110912. * Defines the function to use to interpolate matrices
  110913. * @param startValue defines the start matrix
  110914. * @param endValue defines the end matrix
  110915. * @param gradient defines the gradient between both matrices
  110916. * @param result defines an optional target matrix where to store the interpolation
  110917. * @returns the interpolated matrix
  110918. */
  110919. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  110920. /**
  110921. * Makes a copy of the animation
  110922. * @returns Cloned animation
  110923. */
  110924. clone(): Animation;
  110925. /**
  110926. * Sets the key frames of the animation
  110927. * @param values The animation key frames to set
  110928. */
  110929. setKeys(values: Array<IAnimationKey>): void;
  110930. /**
  110931. * Serializes the animation to an object
  110932. * @returns Serialized object
  110933. */
  110934. serialize(): any;
  110935. /**
  110936. * Float animation type
  110937. */
  110938. static readonly ANIMATIONTYPE_FLOAT: number;
  110939. /**
  110940. * Vector3 animation type
  110941. */
  110942. static readonly ANIMATIONTYPE_VECTOR3: number;
  110943. /**
  110944. * Quaternion animation type
  110945. */
  110946. static readonly ANIMATIONTYPE_QUATERNION: number;
  110947. /**
  110948. * Matrix animation type
  110949. */
  110950. static readonly ANIMATIONTYPE_MATRIX: number;
  110951. /**
  110952. * Color3 animation type
  110953. */
  110954. static readonly ANIMATIONTYPE_COLOR3: number;
  110955. /**
  110956. * Color3 animation type
  110957. */
  110958. static readonly ANIMATIONTYPE_COLOR4: number;
  110959. /**
  110960. * Vector2 animation type
  110961. */
  110962. static readonly ANIMATIONTYPE_VECTOR2: number;
  110963. /**
  110964. * Size animation type
  110965. */
  110966. static readonly ANIMATIONTYPE_SIZE: number;
  110967. /**
  110968. * Relative Loop Mode
  110969. */
  110970. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  110971. /**
  110972. * Cycle Loop Mode
  110973. */
  110974. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  110975. /**
  110976. * Constant Loop Mode
  110977. */
  110978. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  110979. /** @hidden */
  110980. static _UniversalLerp(left: any, right: any, amount: number): any;
  110981. /**
  110982. * Parses an animation object and creates an animation
  110983. * @param parsedAnimation Parsed animation object
  110984. * @returns Animation object
  110985. */
  110986. static Parse(parsedAnimation: any): Animation;
  110987. /**
  110988. * Appends the serialized animations from the source animations
  110989. * @param source Source containing the animations
  110990. * @param destination Target to store the animations
  110991. */
  110992. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110993. /**
  110994. * Creates a new animation or an array of animations from a snippet saved in a remote file
  110995. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  110996. * @param url defines the url to load from
  110997. * @returns a promise that will resolve to the new animation or an array of animations
  110998. */
  110999. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  111000. /**
  111001. * Creates an animation or an array of animations from a snippet saved by the Inspector
  111002. * @param snippetId defines the snippet to load
  111003. * @returns a promise that will resolve to the new animation or a new array of animations
  111004. */
  111005. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  111006. }
  111007. }
  111008. declare module BABYLON {
  111009. /**
  111010. * Interface containing an array of animations
  111011. */
  111012. export interface IAnimatable {
  111013. /**
  111014. * Array of animations
  111015. */
  111016. animations: Nullable<Array<Animation>>;
  111017. }
  111018. }
  111019. declare module BABYLON {
  111020. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  111021. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111022. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111023. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111024. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111025. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111026. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111027. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111028. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111029. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111030. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111031. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111032. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111033. /**
  111034. * Decorator used to define property that can be serialized as reference to a camera
  111035. * @param sourceName defines the name of the property to decorate
  111036. */
  111037. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111038. /**
  111039. * Class used to help serialization objects
  111040. */
  111041. export class SerializationHelper {
  111042. /** @hidden */
  111043. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  111044. /** @hidden */
  111045. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  111046. /** @hidden */
  111047. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  111048. /** @hidden */
  111049. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  111050. /**
  111051. * Appends the serialized animations from the source animations
  111052. * @param source Source containing the animations
  111053. * @param destination Target to store the animations
  111054. */
  111055. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  111056. /**
  111057. * Static function used to serialized a specific entity
  111058. * @param entity defines the entity to serialize
  111059. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  111060. * @returns a JSON compatible object representing the serialization of the entity
  111061. */
  111062. static Serialize<T>(entity: T, serializationObject?: any): any;
  111063. /**
  111064. * Creates a new entity from a serialization data object
  111065. * @param creationFunction defines a function used to instanciated the new entity
  111066. * @param source defines the source serialization data
  111067. * @param scene defines the hosting scene
  111068. * @param rootUrl defines the root url for resources
  111069. * @returns a new entity
  111070. */
  111071. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  111072. /**
  111073. * Clones an object
  111074. * @param creationFunction defines the function used to instanciate the new object
  111075. * @param source defines the source object
  111076. * @returns the cloned object
  111077. */
  111078. static Clone<T>(creationFunction: () => T, source: T): T;
  111079. /**
  111080. * Instanciates a new object based on a source one (some data will be shared between both object)
  111081. * @param creationFunction defines the function used to instanciate the new object
  111082. * @param source defines the source object
  111083. * @returns the new object
  111084. */
  111085. static Instanciate<T>(creationFunction: () => T, source: T): T;
  111086. }
  111087. }
  111088. declare module BABYLON {
  111089. /**
  111090. * Base class of all the textures in babylon.
  111091. * It groups all the common properties the materials, post process, lights... might need
  111092. * in order to make a correct use of the texture.
  111093. */
  111094. export class BaseTexture implements IAnimatable {
  111095. /**
  111096. * Default anisotropic filtering level for the application.
  111097. * It is set to 4 as a good tradeoff between perf and quality.
  111098. */
  111099. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  111100. /**
  111101. * Gets or sets the unique id of the texture
  111102. */
  111103. uniqueId: number;
  111104. /**
  111105. * Define the name of the texture.
  111106. */
  111107. name: string;
  111108. /**
  111109. * Gets or sets an object used to store user defined information.
  111110. */
  111111. metadata: any;
  111112. /**
  111113. * For internal use only. Please do not use.
  111114. */
  111115. reservedDataStore: any;
  111116. private _hasAlpha;
  111117. /**
  111118. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  111119. */
  111120. set hasAlpha(value: boolean);
  111121. get hasAlpha(): boolean;
  111122. /**
  111123. * Defines if the alpha value should be determined via the rgb values.
  111124. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  111125. */
  111126. getAlphaFromRGB: boolean;
  111127. /**
  111128. * Intensity or strength of the texture.
  111129. * It is commonly used by materials to fine tune the intensity of the texture
  111130. */
  111131. level: number;
  111132. /**
  111133. * Define the UV chanel to use starting from 0 and defaulting to 0.
  111134. * This is part of the texture as textures usually maps to one uv set.
  111135. */
  111136. coordinatesIndex: number;
  111137. private _coordinatesMode;
  111138. /**
  111139. * How a texture is mapped.
  111140. *
  111141. * | Value | Type | Description |
  111142. * | ----- | ----------------------------------- | ----------- |
  111143. * | 0 | EXPLICIT_MODE | |
  111144. * | 1 | SPHERICAL_MODE | |
  111145. * | 2 | PLANAR_MODE | |
  111146. * | 3 | CUBIC_MODE | |
  111147. * | 4 | PROJECTION_MODE | |
  111148. * | 5 | SKYBOX_MODE | |
  111149. * | 6 | INVCUBIC_MODE | |
  111150. * | 7 | EQUIRECTANGULAR_MODE | |
  111151. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  111152. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  111153. */
  111154. set coordinatesMode(value: number);
  111155. get coordinatesMode(): number;
  111156. /**
  111157. * | Value | Type | Description |
  111158. * | ----- | ------------------ | ----------- |
  111159. * | 0 | CLAMP_ADDRESSMODE | |
  111160. * | 1 | WRAP_ADDRESSMODE | |
  111161. * | 2 | MIRROR_ADDRESSMODE | |
  111162. */
  111163. wrapU: number;
  111164. /**
  111165. * | Value | Type | Description |
  111166. * | ----- | ------------------ | ----------- |
  111167. * | 0 | CLAMP_ADDRESSMODE | |
  111168. * | 1 | WRAP_ADDRESSMODE | |
  111169. * | 2 | MIRROR_ADDRESSMODE | |
  111170. */
  111171. wrapV: number;
  111172. /**
  111173. * | Value | Type | Description |
  111174. * | ----- | ------------------ | ----------- |
  111175. * | 0 | CLAMP_ADDRESSMODE | |
  111176. * | 1 | WRAP_ADDRESSMODE | |
  111177. * | 2 | MIRROR_ADDRESSMODE | |
  111178. */
  111179. wrapR: number;
  111180. /**
  111181. * With compliant hardware and browser (supporting anisotropic filtering)
  111182. * this defines the level of anisotropic filtering in the texture.
  111183. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  111184. */
  111185. anisotropicFilteringLevel: number;
  111186. /**
  111187. * Define if the texture is a cube texture or if false a 2d texture.
  111188. */
  111189. get isCube(): boolean;
  111190. set isCube(value: boolean);
  111191. /**
  111192. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  111193. */
  111194. get is3D(): boolean;
  111195. set is3D(value: boolean);
  111196. /**
  111197. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  111198. */
  111199. get is2DArray(): boolean;
  111200. set is2DArray(value: boolean);
  111201. /**
  111202. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  111203. * HDR texture are usually stored in linear space.
  111204. * This only impacts the PBR and Background materials
  111205. */
  111206. gammaSpace: boolean;
  111207. /**
  111208. * Gets or sets whether or not the texture contains RGBD data.
  111209. */
  111210. get isRGBD(): boolean;
  111211. set isRGBD(value: boolean);
  111212. /**
  111213. * Is Z inverted in the texture (useful in a cube texture).
  111214. */
  111215. invertZ: boolean;
  111216. /**
  111217. * Are mip maps generated for this texture or not.
  111218. */
  111219. get noMipmap(): boolean;
  111220. /**
  111221. * @hidden
  111222. */
  111223. lodLevelInAlpha: boolean;
  111224. /**
  111225. * With prefiltered texture, defined the offset used during the prefiltering steps.
  111226. */
  111227. get lodGenerationOffset(): number;
  111228. set lodGenerationOffset(value: number);
  111229. /**
  111230. * With prefiltered texture, defined the scale used during the prefiltering steps.
  111231. */
  111232. get lodGenerationScale(): number;
  111233. set lodGenerationScale(value: number);
  111234. /**
  111235. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  111236. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  111237. * average roughness values.
  111238. */
  111239. get linearSpecularLOD(): boolean;
  111240. set linearSpecularLOD(value: boolean);
  111241. /**
  111242. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  111243. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  111244. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  111245. */
  111246. get irradianceTexture(): Nullable<BaseTexture>;
  111247. set irradianceTexture(value: Nullable<BaseTexture>);
  111248. /**
  111249. * Define if the texture is a render target.
  111250. */
  111251. isRenderTarget: boolean;
  111252. /**
  111253. * Define the unique id of the texture in the scene.
  111254. */
  111255. get uid(): string;
  111256. /** @hidden */
  111257. _prefiltered: boolean;
  111258. /**
  111259. * Return a string representation of the texture.
  111260. * @returns the texture as a string
  111261. */
  111262. toString(): string;
  111263. /**
  111264. * Get the class name of the texture.
  111265. * @returns "BaseTexture"
  111266. */
  111267. getClassName(): string;
  111268. /**
  111269. * Define the list of animation attached to the texture.
  111270. */
  111271. animations: Animation[];
  111272. /**
  111273. * An event triggered when the texture is disposed.
  111274. */
  111275. onDisposeObservable: Observable<BaseTexture>;
  111276. private _onDisposeObserver;
  111277. /**
  111278. * Callback triggered when the texture has been disposed.
  111279. * Kept for back compatibility, you can use the onDisposeObservable instead.
  111280. */
  111281. set onDispose(callback: () => void);
  111282. /**
  111283. * Define the current state of the loading sequence when in delayed load mode.
  111284. */
  111285. delayLoadState: number;
  111286. private _scene;
  111287. private _engine;
  111288. /** @hidden */
  111289. _texture: Nullable<InternalTexture>;
  111290. private _uid;
  111291. /**
  111292. * Define if the texture is preventinga material to render or not.
  111293. * If not and the texture is not ready, the engine will use a default black texture instead.
  111294. */
  111295. get isBlocking(): boolean;
  111296. /**
  111297. * Instantiates a new BaseTexture.
  111298. * Base class of all the textures in babylon.
  111299. * It groups all the common properties the materials, post process, lights... might need
  111300. * in order to make a correct use of the texture.
  111301. * @param sceneOrEngine Define the scene or engine the texture blongs to
  111302. */
  111303. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  111304. /**
  111305. * Get the scene the texture belongs to.
  111306. * @returns the scene or null if undefined
  111307. */
  111308. getScene(): Nullable<Scene>;
  111309. /** @hidden */
  111310. protected _getEngine(): Nullable<ThinEngine>;
  111311. /**
  111312. * Get the texture transform matrix used to offset tile the texture for istance.
  111313. * @returns the transformation matrix
  111314. */
  111315. getTextureMatrix(): Matrix;
  111316. /**
  111317. * Get the texture reflection matrix used to rotate/transform the reflection.
  111318. * @returns the reflection matrix
  111319. */
  111320. getReflectionTextureMatrix(): Matrix;
  111321. /**
  111322. * Get the underlying lower level texture from Babylon.
  111323. * @returns the insternal texture
  111324. */
  111325. getInternalTexture(): Nullable<InternalTexture>;
  111326. /**
  111327. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  111328. * @returns true if ready or not blocking
  111329. */
  111330. isReadyOrNotBlocking(): boolean;
  111331. /**
  111332. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  111333. * @returns true if fully ready
  111334. */
  111335. isReady(): boolean;
  111336. private _cachedSize;
  111337. /**
  111338. * Get the size of the texture.
  111339. * @returns the texture size.
  111340. */
  111341. getSize(): ISize;
  111342. /**
  111343. * Get the base size of the texture.
  111344. * It can be different from the size if the texture has been resized for POT for instance
  111345. * @returns the base size
  111346. */
  111347. getBaseSize(): ISize;
  111348. /**
  111349. * Update the sampling mode of the texture.
  111350. * Default is Trilinear mode.
  111351. *
  111352. * | Value | Type | Description |
  111353. * | ----- | ------------------ | ----------- |
  111354. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  111355. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  111356. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  111357. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  111358. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  111359. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  111360. * | 7 | NEAREST_LINEAR | |
  111361. * | 8 | NEAREST_NEAREST | |
  111362. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  111363. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  111364. * | 11 | LINEAR_LINEAR | |
  111365. * | 12 | LINEAR_NEAREST | |
  111366. *
  111367. * > _mag_: magnification filter (close to the viewer)
  111368. * > _min_: minification filter (far from the viewer)
  111369. * > _mip_: filter used between mip map levels
  111370. *@param samplingMode Define the new sampling mode of the texture
  111371. */
  111372. updateSamplingMode(samplingMode: number): void;
  111373. /**
  111374. * Scales the texture if is `canRescale()`
  111375. * @param ratio the resize factor we want to use to rescale
  111376. */
  111377. scale(ratio: number): void;
  111378. /**
  111379. * Get if the texture can rescale.
  111380. */
  111381. get canRescale(): boolean;
  111382. /** @hidden */
  111383. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  111384. /** @hidden */
  111385. _rebuild(): void;
  111386. /**
  111387. * Triggers the load sequence in delayed load mode.
  111388. */
  111389. delayLoad(): void;
  111390. /**
  111391. * Clones the texture.
  111392. * @returns the cloned texture
  111393. */
  111394. clone(): Nullable<BaseTexture>;
  111395. /**
  111396. * Get the texture underlying type (INT, FLOAT...)
  111397. */
  111398. get textureType(): number;
  111399. /**
  111400. * Get the texture underlying format (RGB, RGBA...)
  111401. */
  111402. get textureFormat(): number;
  111403. /**
  111404. * Indicates that textures need to be re-calculated for all materials
  111405. */
  111406. protected _markAllSubMeshesAsTexturesDirty(): void;
  111407. /**
  111408. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  111409. * This will returns an RGBA array buffer containing either in values (0-255) or
  111410. * float values (0-1) depending of the underlying buffer type.
  111411. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  111412. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  111413. * @param buffer defines a user defined buffer to fill with data (can be null)
  111414. * @returns The Array buffer containing the pixels data.
  111415. */
  111416. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  111417. /**
  111418. * Release and destroy the underlying lower level texture aka internalTexture.
  111419. */
  111420. releaseInternalTexture(): void;
  111421. /** @hidden */
  111422. get _lodTextureHigh(): Nullable<BaseTexture>;
  111423. /** @hidden */
  111424. get _lodTextureMid(): Nullable<BaseTexture>;
  111425. /** @hidden */
  111426. get _lodTextureLow(): Nullable<BaseTexture>;
  111427. /**
  111428. * Dispose the texture and release its associated resources.
  111429. */
  111430. dispose(): void;
  111431. /**
  111432. * Serialize the texture into a JSON representation that can be parsed later on.
  111433. * @returns the JSON representation of the texture
  111434. */
  111435. serialize(): any;
  111436. /**
  111437. * Helper function to be called back once a list of texture contains only ready textures.
  111438. * @param textures Define the list of textures to wait for
  111439. * @param callback Define the callback triggered once the entire list will be ready
  111440. */
  111441. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  111442. private static _isScene;
  111443. }
  111444. }
  111445. declare module BABYLON {
  111446. /**
  111447. * Options to be used when creating an effect.
  111448. */
  111449. export interface IEffectCreationOptions {
  111450. /**
  111451. * Atrributes that will be used in the shader.
  111452. */
  111453. attributes: string[];
  111454. /**
  111455. * Uniform varible names that will be set in the shader.
  111456. */
  111457. uniformsNames: string[];
  111458. /**
  111459. * Uniform buffer variable names that will be set in the shader.
  111460. */
  111461. uniformBuffersNames: string[];
  111462. /**
  111463. * Sampler texture variable names that will be set in the shader.
  111464. */
  111465. samplers: string[];
  111466. /**
  111467. * Define statements that will be set in the shader.
  111468. */
  111469. defines: any;
  111470. /**
  111471. * Possible fallbacks for this effect to improve performance when needed.
  111472. */
  111473. fallbacks: Nullable<IEffectFallbacks>;
  111474. /**
  111475. * Callback that will be called when the shader is compiled.
  111476. */
  111477. onCompiled: Nullable<(effect: Effect) => void>;
  111478. /**
  111479. * Callback that will be called if an error occurs during shader compilation.
  111480. */
  111481. onError: Nullable<(effect: Effect, errors: string) => void>;
  111482. /**
  111483. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111484. */
  111485. indexParameters?: any;
  111486. /**
  111487. * Max number of lights that can be used in the shader.
  111488. */
  111489. maxSimultaneousLights?: number;
  111490. /**
  111491. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  111492. */
  111493. transformFeedbackVaryings?: Nullable<string[]>;
  111494. /**
  111495. * 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
  111496. */
  111497. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  111498. /**
  111499. * Is this effect rendering to several color attachments ?
  111500. */
  111501. multiTarget?: boolean;
  111502. }
  111503. /**
  111504. * Effect containing vertex and fragment shader that can be executed on an object.
  111505. */
  111506. export class Effect implements IDisposable {
  111507. /**
  111508. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111509. */
  111510. static ShadersRepository: string;
  111511. /**
  111512. * Enable logging of the shader code when a compilation error occurs
  111513. */
  111514. static LogShaderCodeOnCompilationError: boolean;
  111515. /**
  111516. * Name of the effect.
  111517. */
  111518. name: any;
  111519. /**
  111520. * String container all the define statements that should be set on the shader.
  111521. */
  111522. defines: string;
  111523. /**
  111524. * Callback that will be called when the shader is compiled.
  111525. */
  111526. onCompiled: Nullable<(effect: Effect) => void>;
  111527. /**
  111528. * Callback that will be called if an error occurs during shader compilation.
  111529. */
  111530. onError: Nullable<(effect: Effect, errors: string) => void>;
  111531. /**
  111532. * Callback that will be called when effect is bound.
  111533. */
  111534. onBind: Nullable<(effect: Effect) => void>;
  111535. /**
  111536. * Unique ID of the effect.
  111537. */
  111538. uniqueId: number;
  111539. /**
  111540. * Observable that will be called when the shader is compiled.
  111541. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  111542. */
  111543. onCompileObservable: Observable<Effect>;
  111544. /**
  111545. * Observable that will be called if an error occurs during shader compilation.
  111546. */
  111547. onErrorObservable: Observable<Effect>;
  111548. /** @hidden */
  111549. _onBindObservable: Nullable<Observable<Effect>>;
  111550. /**
  111551. * @hidden
  111552. * Specifies if the effect was previously ready
  111553. */
  111554. _wasPreviouslyReady: boolean;
  111555. /**
  111556. * Observable that will be called when effect is bound.
  111557. */
  111558. get onBindObservable(): Observable<Effect>;
  111559. /** @hidden */
  111560. _bonesComputationForcedToCPU: boolean;
  111561. /** @hidden */
  111562. _multiTarget: boolean;
  111563. private static _uniqueIdSeed;
  111564. private _engine;
  111565. private _uniformBuffersNames;
  111566. private _uniformBuffersNamesList;
  111567. private _uniformsNames;
  111568. private _samplerList;
  111569. private _samplers;
  111570. private _isReady;
  111571. private _compilationError;
  111572. private _allFallbacksProcessed;
  111573. private _attributesNames;
  111574. private _attributes;
  111575. private _attributeLocationByName;
  111576. private _uniforms;
  111577. /**
  111578. * Key for the effect.
  111579. * @hidden
  111580. */
  111581. _key: string;
  111582. private _indexParameters;
  111583. private _fallbacks;
  111584. private _vertexSourceCode;
  111585. private _fragmentSourceCode;
  111586. private _vertexSourceCodeOverride;
  111587. private _fragmentSourceCodeOverride;
  111588. private _transformFeedbackVaryings;
  111589. /**
  111590. * Compiled shader to webGL program.
  111591. * @hidden
  111592. */
  111593. _pipelineContext: Nullable<IPipelineContext>;
  111594. private _valueCache;
  111595. private static _baseCache;
  111596. /**
  111597. * Instantiates an effect.
  111598. * An effect can be used to create/manage/execute vertex and fragment shaders.
  111599. * @param baseName Name of the effect.
  111600. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  111601. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  111602. * @param samplers List of sampler variables that will be passed to the shader.
  111603. * @param engine Engine to be used to render the effect
  111604. * @param defines Define statements to be added to the shader.
  111605. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  111606. * @param onCompiled Callback that will be called when the shader is compiled.
  111607. * @param onError Callback that will be called if an error occurs during shader compilation.
  111608. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111609. */
  111610. 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);
  111611. private _useFinalCode;
  111612. /**
  111613. * Unique key for this effect
  111614. */
  111615. get key(): string;
  111616. /**
  111617. * If the effect has been compiled and prepared.
  111618. * @returns if the effect is compiled and prepared.
  111619. */
  111620. isReady(): boolean;
  111621. private _isReadyInternal;
  111622. /**
  111623. * The engine the effect was initialized with.
  111624. * @returns the engine.
  111625. */
  111626. getEngine(): Engine;
  111627. /**
  111628. * The pipeline context for this effect
  111629. * @returns the associated pipeline context
  111630. */
  111631. getPipelineContext(): Nullable<IPipelineContext>;
  111632. /**
  111633. * The set of names of attribute variables for the shader.
  111634. * @returns An array of attribute names.
  111635. */
  111636. getAttributesNames(): string[];
  111637. /**
  111638. * Returns the attribute at the given index.
  111639. * @param index The index of the attribute.
  111640. * @returns The location of the attribute.
  111641. */
  111642. getAttributeLocation(index: number): number;
  111643. /**
  111644. * Returns the attribute based on the name of the variable.
  111645. * @param name of the attribute to look up.
  111646. * @returns the attribute location.
  111647. */
  111648. getAttributeLocationByName(name: string): number;
  111649. /**
  111650. * The number of attributes.
  111651. * @returns the numnber of attributes.
  111652. */
  111653. getAttributesCount(): number;
  111654. /**
  111655. * Gets the index of a uniform variable.
  111656. * @param uniformName of the uniform to look up.
  111657. * @returns the index.
  111658. */
  111659. getUniformIndex(uniformName: string): number;
  111660. /**
  111661. * Returns the attribute based on the name of the variable.
  111662. * @param uniformName of the uniform to look up.
  111663. * @returns the location of the uniform.
  111664. */
  111665. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  111666. /**
  111667. * Returns an array of sampler variable names
  111668. * @returns The array of sampler variable names.
  111669. */
  111670. getSamplers(): string[];
  111671. /**
  111672. * Returns an array of uniform variable names
  111673. * @returns The array of uniform variable names.
  111674. */
  111675. getUniformNames(): string[];
  111676. /**
  111677. * Returns an array of uniform buffer variable names
  111678. * @returns The array of uniform buffer variable names.
  111679. */
  111680. getUniformBuffersNames(): string[];
  111681. /**
  111682. * Returns the index parameters used to create the effect
  111683. * @returns The index parameters object
  111684. */
  111685. getIndexParameters(): any;
  111686. /**
  111687. * The error from the last compilation.
  111688. * @returns the error string.
  111689. */
  111690. getCompilationError(): string;
  111691. /**
  111692. * Gets a boolean indicating that all fallbacks were used during compilation
  111693. * @returns true if all fallbacks were used
  111694. */
  111695. allFallbacksProcessed(): boolean;
  111696. /**
  111697. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  111698. * @param func The callback to be used.
  111699. */
  111700. executeWhenCompiled(func: (effect: Effect) => void): void;
  111701. private _checkIsReady;
  111702. private _loadShader;
  111703. /**
  111704. * Gets the vertex shader source code of this effect
  111705. */
  111706. get vertexSourceCode(): string;
  111707. /**
  111708. * Gets the fragment shader source code of this effect
  111709. */
  111710. get fragmentSourceCode(): string;
  111711. /**
  111712. * Recompiles the webGL program
  111713. * @param vertexSourceCode The source code for the vertex shader.
  111714. * @param fragmentSourceCode The source code for the fragment shader.
  111715. * @param onCompiled Callback called when completed.
  111716. * @param onError Callback called on error.
  111717. * @hidden
  111718. */
  111719. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  111720. /**
  111721. * Prepares the effect
  111722. * @hidden
  111723. */
  111724. _prepareEffect(): void;
  111725. private _getShaderCodeAndErrorLine;
  111726. private _processCompilationErrors;
  111727. /**
  111728. * Checks if the effect is supported. (Must be called after compilation)
  111729. */
  111730. get isSupported(): boolean;
  111731. /**
  111732. * Binds a texture to the engine to be used as output of the shader.
  111733. * @param channel Name of the output variable.
  111734. * @param texture Texture to bind.
  111735. * @hidden
  111736. */
  111737. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  111738. /**
  111739. * Sets a texture on the engine to be used in the shader.
  111740. * @param channel Name of the sampler variable.
  111741. * @param texture Texture to set.
  111742. */
  111743. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  111744. /**
  111745. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  111746. * @param channel Name of the sampler variable.
  111747. * @param texture Texture to set.
  111748. */
  111749. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  111750. /**
  111751. * Sets an array of textures on the engine to be used in the shader.
  111752. * @param channel Name of the variable.
  111753. * @param textures Textures to set.
  111754. */
  111755. setTextureArray(channel: string, textures: BaseTexture[]): void;
  111756. /**
  111757. * 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)
  111758. * @param channel Name of the sampler variable.
  111759. * @param postProcess Post process to get the input texture from.
  111760. */
  111761. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  111762. /**
  111763. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  111764. * 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)
  111765. * @param channel Name of the sampler variable.
  111766. * @param postProcess Post process to get the output texture from.
  111767. */
  111768. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  111769. /** @hidden */
  111770. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  111771. /** @hidden */
  111772. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  111773. /** @hidden */
  111774. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  111775. /** @hidden */
  111776. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  111777. /**
  111778. * Binds a buffer to a uniform.
  111779. * @param buffer Buffer to bind.
  111780. * @param name Name of the uniform variable to bind to.
  111781. */
  111782. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  111783. /**
  111784. * Binds block to a uniform.
  111785. * @param blockName Name of the block to bind.
  111786. * @param index Index to bind.
  111787. */
  111788. bindUniformBlock(blockName: string, index: number): void;
  111789. /**
  111790. * Sets an interger value on a uniform variable.
  111791. * @param uniformName Name of the variable.
  111792. * @param value Value to be set.
  111793. * @returns this effect.
  111794. */
  111795. setInt(uniformName: string, value: number): Effect;
  111796. /**
  111797. * Sets an int array on a uniform variable.
  111798. * @param uniformName Name of the variable.
  111799. * @param array array to be set.
  111800. * @returns this effect.
  111801. */
  111802. setIntArray(uniformName: string, array: Int32Array): Effect;
  111803. /**
  111804. * 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)
  111805. * @param uniformName Name of the variable.
  111806. * @param array array to be set.
  111807. * @returns this effect.
  111808. */
  111809. setIntArray2(uniformName: string, array: Int32Array): Effect;
  111810. /**
  111811. * 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)
  111812. * @param uniformName Name of the variable.
  111813. * @param array array to be set.
  111814. * @returns this effect.
  111815. */
  111816. setIntArray3(uniformName: string, array: Int32Array): Effect;
  111817. /**
  111818. * 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)
  111819. * @param uniformName Name of the variable.
  111820. * @param array array to be set.
  111821. * @returns this effect.
  111822. */
  111823. setIntArray4(uniformName: string, array: Int32Array): Effect;
  111824. /**
  111825. * Sets an float array on a uniform variable.
  111826. * @param uniformName Name of the variable.
  111827. * @param array array to be set.
  111828. * @returns this effect.
  111829. */
  111830. setFloatArray(uniformName: string, array: Float32Array): Effect;
  111831. /**
  111832. * 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)
  111833. * @param uniformName Name of the variable.
  111834. * @param array array to be set.
  111835. * @returns this effect.
  111836. */
  111837. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  111838. /**
  111839. * 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)
  111840. * @param uniformName Name of the variable.
  111841. * @param array array to be set.
  111842. * @returns this effect.
  111843. */
  111844. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  111845. /**
  111846. * 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)
  111847. * @param uniformName Name of the variable.
  111848. * @param array array to be set.
  111849. * @returns this effect.
  111850. */
  111851. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  111852. /**
  111853. * Sets an array on a uniform variable.
  111854. * @param uniformName Name of the variable.
  111855. * @param array array to be set.
  111856. * @returns this effect.
  111857. */
  111858. setArray(uniformName: string, array: number[]): Effect;
  111859. /**
  111860. * 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)
  111861. * @param uniformName Name of the variable.
  111862. * @param array array to be set.
  111863. * @returns this effect.
  111864. */
  111865. setArray2(uniformName: string, array: number[]): Effect;
  111866. /**
  111867. * 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)
  111868. * @param uniformName Name of the variable.
  111869. * @param array array to be set.
  111870. * @returns this effect.
  111871. */
  111872. setArray3(uniformName: string, array: number[]): Effect;
  111873. /**
  111874. * 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)
  111875. * @param uniformName Name of the variable.
  111876. * @param array array to be set.
  111877. * @returns this effect.
  111878. */
  111879. setArray4(uniformName: string, array: number[]): Effect;
  111880. /**
  111881. * Sets matrices on a uniform variable.
  111882. * @param uniformName Name of the variable.
  111883. * @param matrices matrices to be set.
  111884. * @returns this effect.
  111885. */
  111886. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  111887. /**
  111888. * Sets matrix on a uniform variable.
  111889. * @param uniformName Name of the variable.
  111890. * @param matrix matrix to be set.
  111891. * @returns this effect.
  111892. */
  111893. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  111894. /**
  111895. * 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)
  111896. * @param uniformName Name of the variable.
  111897. * @param matrix matrix to be set.
  111898. * @returns this effect.
  111899. */
  111900. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  111901. /**
  111902. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  111903. * @param uniformName Name of the variable.
  111904. * @param matrix matrix to be set.
  111905. * @returns this effect.
  111906. */
  111907. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  111908. /**
  111909. * Sets a float on a uniform variable.
  111910. * @param uniformName Name of the variable.
  111911. * @param value value to be set.
  111912. * @returns this effect.
  111913. */
  111914. setFloat(uniformName: string, value: number): Effect;
  111915. /**
  111916. * Sets a boolean on a uniform variable.
  111917. * @param uniformName Name of the variable.
  111918. * @param bool value to be set.
  111919. * @returns this effect.
  111920. */
  111921. setBool(uniformName: string, bool: boolean): Effect;
  111922. /**
  111923. * Sets a Vector2 on a uniform variable.
  111924. * @param uniformName Name of the variable.
  111925. * @param vector2 vector2 to be set.
  111926. * @returns this effect.
  111927. */
  111928. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  111929. /**
  111930. * Sets a float2 on a uniform variable.
  111931. * @param uniformName Name of the variable.
  111932. * @param x First float in float2.
  111933. * @param y Second float in float2.
  111934. * @returns this effect.
  111935. */
  111936. setFloat2(uniformName: string, x: number, y: number): Effect;
  111937. /**
  111938. * Sets a Vector3 on a uniform variable.
  111939. * @param uniformName Name of the variable.
  111940. * @param vector3 Value to be set.
  111941. * @returns this effect.
  111942. */
  111943. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  111944. /**
  111945. * Sets a float3 on a uniform variable.
  111946. * @param uniformName Name of the variable.
  111947. * @param x First float in float3.
  111948. * @param y Second float in float3.
  111949. * @param z Third float in float3.
  111950. * @returns this effect.
  111951. */
  111952. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  111953. /**
  111954. * Sets a Vector4 on a uniform variable.
  111955. * @param uniformName Name of the variable.
  111956. * @param vector4 Value to be set.
  111957. * @returns this effect.
  111958. */
  111959. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  111960. /**
  111961. * Sets a float4 on a uniform variable.
  111962. * @param uniformName Name of the variable.
  111963. * @param x First float in float4.
  111964. * @param y Second float in float4.
  111965. * @param z Third float in float4.
  111966. * @param w Fourth float in float4.
  111967. * @returns this effect.
  111968. */
  111969. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  111970. /**
  111971. * Sets a Color3 on a uniform variable.
  111972. * @param uniformName Name of the variable.
  111973. * @param color3 Value to be set.
  111974. * @returns this effect.
  111975. */
  111976. setColor3(uniformName: string, color3: IColor3Like): Effect;
  111977. /**
  111978. * Sets a Color4 on a uniform variable.
  111979. * @param uniformName Name of the variable.
  111980. * @param color3 Value to be set.
  111981. * @param alpha Alpha value to be set.
  111982. * @returns this effect.
  111983. */
  111984. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  111985. /**
  111986. * Sets a Color4 on a uniform variable
  111987. * @param uniformName defines the name of the variable
  111988. * @param color4 defines the value to be set
  111989. * @returns this effect.
  111990. */
  111991. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  111992. /** Release all associated resources */
  111993. dispose(): void;
  111994. /**
  111995. * This function will add a new shader to the shader store
  111996. * @param name the name of the shader
  111997. * @param pixelShader optional pixel shader content
  111998. * @param vertexShader optional vertex shader content
  111999. */
  112000. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  112001. /**
  112002. * Store of each shader (The can be looked up using effect.key)
  112003. */
  112004. static ShadersStore: {
  112005. [key: string]: string;
  112006. };
  112007. /**
  112008. * Store of each included file for a shader (The can be looked up using effect.key)
  112009. */
  112010. static IncludesShadersStore: {
  112011. [key: string]: string;
  112012. };
  112013. /**
  112014. * Resets the cache of effects.
  112015. */
  112016. static ResetCache(): void;
  112017. }
  112018. }
  112019. declare module BABYLON {
  112020. /**
  112021. * Interface used to describe the capabilities of the engine relatively to the current browser
  112022. */
  112023. export interface EngineCapabilities {
  112024. /** Maximum textures units per fragment shader */
  112025. maxTexturesImageUnits: number;
  112026. /** Maximum texture units per vertex shader */
  112027. maxVertexTextureImageUnits: number;
  112028. /** Maximum textures units in the entire pipeline */
  112029. maxCombinedTexturesImageUnits: number;
  112030. /** Maximum texture size */
  112031. maxTextureSize: number;
  112032. /** Maximum texture samples */
  112033. maxSamples?: number;
  112034. /** Maximum cube texture size */
  112035. maxCubemapTextureSize: number;
  112036. /** Maximum render texture size */
  112037. maxRenderTextureSize: number;
  112038. /** Maximum number of vertex attributes */
  112039. maxVertexAttribs: number;
  112040. /** Maximum number of varyings */
  112041. maxVaryingVectors: number;
  112042. /** Maximum number of uniforms per vertex shader */
  112043. maxVertexUniformVectors: number;
  112044. /** Maximum number of uniforms per fragment shader */
  112045. maxFragmentUniformVectors: number;
  112046. /** Defines if standard derivates (dx/dy) are supported */
  112047. standardDerivatives: boolean;
  112048. /** Defines if s3tc texture compression is supported */
  112049. s3tc?: WEBGL_compressed_texture_s3tc;
  112050. /** Defines if pvrtc texture compression is supported */
  112051. pvrtc: any;
  112052. /** Defines if etc1 texture compression is supported */
  112053. etc1: any;
  112054. /** Defines if etc2 texture compression is supported */
  112055. etc2: any;
  112056. /** Defines if astc texture compression is supported */
  112057. astc: any;
  112058. /** Defines if float textures are supported */
  112059. textureFloat: boolean;
  112060. /** Defines if vertex array objects are supported */
  112061. vertexArrayObject: boolean;
  112062. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  112063. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  112064. /** Gets the maximum level of anisotropy supported */
  112065. maxAnisotropy: number;
  112066. /** Defines if instancing is supported */
  112067. instancedArrays: boolean;
  112068. /** Defines if 32 bits indices are supported */
  112069. uintIndices: boolean;
  112070. /** Defines if high precision shaders are supported */
  112071. highPrecisionShaderSupported: boolean;
  112072. /** Defines if depth reading in the fragment shader is supported */
  112073. fragmentDepthSupported: boolean;
  112074. /** Defines if float texture linear filtering is supported*/
  112075. textureFloatLinearFiltering: boolean;
  112076. /** Defines if rendering to float textures is supported */
  112077. textureFloatRender: boolean;
  112078. /** Defines if half float textures are supported*/
  112079. textureHalfFloat: boolean;
  112080. /** Defines if half float texture linear filtering is supported*/
  112081. textureHalfFloatLinearFiltering: boolean;
  112082. /** Defines if rendering to half float textures is supported */
  112083. textureHalfFloatRender: boolean;
  112084. /** Defines if textureLOD shader command is supported */
  112085. textureLOD: boolean;
  112086. /** Defines if draw buffers extension is supported */
  112087. drawBuffersExtension: boolean;
  112088. /** Defines if depth textures are supported */
  112089. depthTextureExtension: boolean;
  112090. /** Defines if float color buffer are supported */
  112091. colorBufferFloat: boolean;
  112092. /** Gets disjoint timer query extension (null if not supported) */
  112093. timerQuery?: EXT_disjoint_timer_query;
  112094. /** Defines if timestamp can be used with timer query */
  112095. canUseTimestampForTimerQuery: boolean;
  112096. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  112097. multiview?: any;
  112098. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  112099. oculusMultiview?: any;
  112100. /** Function used to let the system compiles shaders in background */
  112101. parallelShaderCompile?: {
  112102. COMPLETION_STATUS_KHR: number;
  112103. };
  112104. /** Max number of texture samples for MSAA */
  112105. maxMSAASamples: number;
  112106. /** Defines if the blend min max extension is supported */
  112107. blendMinMax: boolean;
  112108. }
  112109. }
  112110. declare module BABYLON {
  112111. /**
  112112. * @hidden
  112113. **/
  112114. export class DepthCullingState {
  112115. private _isDepthTestDirty;
  112116. private _isDepthMaskDirty;
  112117. private _isDepthFuncDirty;
  112118. private _isCullFaceDirty;
  112119. private _isCullDirty;
  112120. private _isZOffsetDirty;
  112121. private _isFrontFaceDirty;
  112122. private _depthTest;
  112123. private _depthMask;
  112124. private _depthFunc;
  112125. private _cull;
  112126. private _cullFace;
  112127. private _zOffset;
  112128. private _frontFace;
  112129. /**
  112130. * Initializes the state.
  112131. */
  112132. constructor();
  112133. get isDirty(): boolean;
  112134. get zOffset(): number;
  112135. set zOffset(value: number);
  112136. get cullFace(): Nullable<number>;
  112137. set cullFace(value: Nullable<number>);
  112138. get cull(): Nullable<boolean>;
  112139. set cull(value: Nullable<boolean>);
  112140. get depthFunc(): Nullable<number>;
  112141. set depthFunc(value: Nullable<number>);
  112142. get depthMask(): boolean;
  112143. set depthMask(value: boolean);
  112144. get depthTest(): boolean;
  112145. set depthTest(value: boolean);
  112146. get frontFace(): Nullable<number>;
  112147. set frontFace(value: Nullable<number>);
  112148. reset(): void;
  112149. apply(gl: WebGLRenderingContext): void;
  112150. }
  112151. }
  112152. declare module BABYLON {
  112153. /**
  112154. * @hidden
  112155. **/
  112156. export class StencilState {
  112157. /** 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 */
  112158. static readonly ALWAYS: number;
  112159. /** Passed to stencilOperation to specify that stencil value must be kept */
  112160. static readonly KEEP: number;
  112161. /** Passed to stencilOperation to specify that stencil value must be replaced */
  112162. static readonly REPLACE: number;
  112163. private _isStencilTestDirty;
  112164. private _isStencilMaskDirty;
  112165. private _isStencilFuncDirty;
  112166. private _isStencilOpDirty;
  112167. private _stencilTest;
  112168. private _stencilMask;
  112169. private _stencilFunc;
  112170. private _stencilFuncRef;
  112171. private _stencilFuncMask;
  112172. private _stencilOpStencilFail;
  112173. private _stencilOpDepthFail;
  112174. private _stencilOpStencilDepthPass;
  112175. get isDirty(): boolean;
  112176. get stencilFunc(): number;
  112177. set stencilFunc(value: number);
  112178. get stencilFuncRef(): number;
  112179. set stencilFuncRef(value: number);
  112180. get stencilFuncMask(): number;
  112181. set stencilFuncMask(value: number);
  112182. get stencilOpStencilFail(): number;
  112183. set stencilOpStencilFail(value: number);
  112184. get stencilOpDepthFail(): number;
  112185. set stencilOpDepthFail(value: number);
  112186. get stencilOpStencilDepthPass(): number;
  112187. set stencilOpStencilDepthPass(value: number);
  112188. get stencilMask(): number;
  112189. set stencilMask(value: number);
  112190. get stencilTest(): boolean;
  112191. set stencilTest(value: boolean);
  112192. constructor();
  112193. reset(): void;
  112194. apply(gl: WebGLRenderingContext): void;
  112195. }
  112196. }
  112197. declare module BABYLON {
  112198. /**
  112199. * @hidden
  112200. **/
  112201. export class AlphaState {
  112202. private _isAlphaBlendDirty;
  112203. private _isBlendFunctionParametersDirty;
  112204. private _isBlendEquationParametersDirty;
  112205. private _isBlendConstantsDirty;
  112206. private _alphaBlend;
  112207. private _blendFunctionParameters;
  112208. private _blendEquationParameters;
  112209. private _blendConstants;
  112210. /**
  112211. * Initializes the state.
  112212. */
  112213. constructor();
  112214. get isDirty(): boolean;
  112215. get alphaBlend(): boolean;
  112216. set alphaBlend(value: boolean);
  112217. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  112218. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  112219. setAlphaEquationParameters(rgb: number, alpha: number): void;
  112220. reset(): void;
  112221. apply(gl: WebGLRenderingContext): void;
  112222. }
  112223. }
  112224. declare module BABYLON {
  112225. /** @hidden */
  112226. export class WebGL2ShaderProcessor implements IShaderProcessor {
  112227. attributeProcessor(attribute: string): string;
  112228. varyingProcessor(varying: string, isFragment: boolean): string;
  112229. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112230. }
  112231. }
  112232. declare module BABYLON {
  112233. /**
  112234. * Interface for attribute information associated with buffer instanciation
  112235. */
  112236. export interface InstancingAttributeInfo {
  112237. /**
  112238. * Name of the GLSL attribute
  112239. * if attribute index is not specified, this is used to retrieve the index from the effect
  112240. */
  112241. attributeName: string;
  112242. /**
  112243. * Index/offset of the attribute in the vertex shader
  112244. * if not specified, this will be computes from the name.
  112245. */
  112246. index?: number;
  112247. /**
  112248. * size of the attribute, 1, 2, 3 or 4
  112249. */
  112250. attributeSize: number;
  112251. /**
  112252. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  112253. */
  112254. offset: number;
  112255. /**
  112256. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  112257. * default to 1
  112258. */
  112259. divisor?: number;
  112260. /**
  112261. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  112262. * default is FLOAT
  112263. */
  112264. attributeType?: number;
  112265. /**
  112266. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  112267. */
  112268. normalized?: boolean;
  112269. }
  112270. }
  112271. declare module BABYLON {
  112272. interface ThinEngine {
  112273. /**
  112274. * Update a video texture
  112275. * @param texture defines the texture to update
  112276. * @param video defines the video element to use
  112277. * @param invertY defines if data must be stored with Y axis inverted
  112278. */
  112279. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  112280. }
  112281. }
  112282. declare module BABYLON {
  112283. interface ThinEngine {
  112284. /**
  112285. * Creates a dynamic texture
  112286. * @param width defines the width of the texture
  112287. * @param height defines the height of the texture
  112288. * @param generateMipMaps defines if the engine should generate the mip levels
  112289. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  112290. * @returns the dynamic texture inside an InternalTexture
  112291. */
  112292. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  112293. /**
  112294. * Update the content of a dynamic texture
  112295. * @param texture defines the texture to update
  112296. * @param canvas defines the canvas containing the source
  112297. * @param invertY defines if data must be stored with Y axis inverted
  112298. * @param premulAlpha defines if alpha is stored as premultiplied
  112299. * @param format defines the format of the data
  112300. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112301. */
  112302. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  112303. }
  112304. }
  112305. declare module BABYLON {
  112306. /**
  112307. * Settings for finer control over video usage
  112308. */
  112309. export interface VideoTextureSettings {
  112310. /**
  112311. * Applies `autoplay` to video, if specified
  112312. */
  112313. autoPlay?: boolean;
  112314. /**
  112315. * Applies `loop` to video, if specified
  112316. */
  112317. loop?: boolean;
  112318. /**
  112319. * Automatically updates internal texture from video at every frame in the render loop
  112320. */
  112321. autoUpdateTexture: boolean;
  112322. /**
  112323. * Image src displayed during the video loading or until the user interacts with the video.
  112324. */
  112325. poster?: string;
  112326. }
  112327. /**
  112328. * If you want to display a video in your scene, this is the special texture for that.
  112329. * This special texture works similar to other textures, with the exception of a few parameters.
  112330. * @see https://doc.babylonjs.com/how_to/video_texture
  112331. */
  112332. export class VideoTexture extends Texture {
  112333. /**
  112334. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  112335. */
  112336. readonly autoUpdateTexture: boolean;
  112337. /**
  112338. * The video instance used by the texture internally
  112339. */
  112340. readonly video: HTMLVideoElement;
  112341. private _onUserActionRequestedObservable;
  112342. /**
  112343. * Event triggerd when a dom action is required by the user to play the video.
  112344. * This happens due to recent changes in browser policies preventing video to auto start.
  112345. */
  112346. get onUserActionRequestedObservable(): Observable<Texture>;
  112347. private _generateMipMaps;
  112348. private _stillImageCaptured;
  112349. private _displayingPosterTexture;
  112350. private _settings;
  112351. private _createInternalTextureOnEvent;
  112352. private _frameId;
  112353. private _currentSrc;
  112354. /**
  112355. * Creates a video texture.
  112356. * If you want to display a video in your scene, this is the special texture for that.
  112357. * This special texture works similar to other textures, with the exception of a few parameters.
  112358. * @see https://doc.babylonjs.com/how_to/video_texture
  112359. * @param name optional name, will detect from video source, if not defined
  112360. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  112361. * @param scene is obviously the current scene.
  112362. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  112363. * @param invertY is false by default but can be used to invert video on Y axis
  112364. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  112365. * @param settings allows finer control over video usage
  112366. */
  112367. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  112368. private _getName;
  112369. private _getVideo;
  112370. private _createInternalTexture;
  112371. private reset;
  112372. /**
  112373. * @hidden Internal method to initiate `update`.
  112374. */
  112375. _rebuild(): void;
  112376. /**
  112377. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  112378. */
  112379. update(): void;
  112380. /**
  112381. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  112382. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  112383. */
  112384. updateTexture(isVisible: boolean): void;
  112385. protected _updateInternalTexture: () => void;
  112386. /**
  112387. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  112388. * @param url New url.
  112389. */
  112390. updateURL(url: string): void;
  112391. /**
  112392. * Clones the texture.
  112393. * @returns the cloned texture
  112394. */
  112395. clone(): VideoTexture;
  112396. /**
  112397. * Dispose the texture and release its associated resources.
  112398. */
  112399. dispose(): void;
  112400. /**
  112401. * Creates a video texture straight from a stream.
  112402. * @param scene Define the scene the texture should be created in
  112403. * @param stream Define the stream the texture should be created from
  112404. * @returns The created video texture as a promise
  112405. */
  112406. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  112407. /**
  112408. * Creates a video texture straight from your WebCam video feed.
  112409. * @param scene Define the scene the texture should be created in
  112410. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  112411. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  112412. * @returns The created video texture as a promise
  112413. */
  112414. static CreateFromWebCamAsync(scene: Scene, constraints: {
  112415. minWidth: number;
  112416. maxWidth: number;
  112417. minHeight: number;
  112418. maxHeight: number;
  112419. deviceId: string;
  112420. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  112421. /**
  112422. * Creates a video texture straight from your WebCam video feed.
  112423. * @param scene Define the scene the texture should be created in
  112424. * @param onReady Define a callback to triggered once the texture will be ready
  112425. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  112426. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  112427. */
  112428. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  112429. minWidth: number;
  112430. maxWidth: number;
  112431. minHeight: number;
  112432. maxHeight: number;
  112433. deviceId: string;
  112434. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  112435. }
  112436. }
  112437. declare module BABYLON {
  112438. /**
  112439. * Defines the interface used by objects working like Scene
  112440. * @hidden
  112441. */
  112442. export interface ISceneLike {
  112443. _addPendingData(data: any): void;
  112444. _removePendingData(data: any): void;
  112445. offlineProvider: IOfflineProvider;
  112446. }
  112447. /** Interface defining initialization parameters for Engine class */
  112448. export interface EngineOptions extends WebGLContextAttributes {
  112449. /**
  112450. * Defines if the engine should no exceed a specified device ratio
  112451. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  112452. */
  112453. limitDeviceRatio?: number;
  112454. /**
  112455. * Defines if webvr should be enabled automatically
  112456. * @see https://doc.babylonjs.com/how_to/webvr_camera
  112457. */
  112458. autoEnableWebVR?: boolean;
  112459. /**
  112460. * Defines if webgl2 should be turned off even if supported
  112461. * @see https://doc.babylonjs.com/features/webgl2
  112462. */
  112463. disableWebGL2Support?: boolean;
  112464. /**
  112465. * Defines if webaudio should be initialized as well
  112466. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  112467. */
  112468. audioEngine?: boolean;
  112469. /**
  112470. * Defines if animations should run using a deterministic lock step
  112471. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112472. */
  112473. deterministicLockstep?: boolean;
  112474. /** Defines the maximum steps to use with deterministic lock step mode */
  112475. lockstepMaxSteps?: number;
  112476. /** Defines the seconds between each deterministic lock step */
  112477. timeStep?: number;
  112478. /**
  112479. * Defines that engine should ignore context lost events
  112480. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  112481. */
  112482. doNotHandleContextLost?: boolean;
  112483. /**
  112484. * Defines that engine should ignore modifying touch action attribute and style
  112485. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  112486. */
  112487. doNotHandleTouchAction?: boolean;
  112488. /**
  112489. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  112490. */
  112491. useHighPrecisionFloats?: boolean;
  112492. /**
  112493. * Make the canvas XR Compatible for XR sessions
  112494. */
  112495. xrCompatible?: boolean;
  112496. }
  112497. /**
  112498. * The base engine class (root of all engines)
  112499. */
  112500. export class ThinEngine {
  112501. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  112502. static ExceptionList: ({
  112503. key: string;
  112504. capture: string;
  112505. captureConstraint: number;
  112506. targets: string[];
  112507. } | {
  112508. key: string;
  112509. capture: null;
  112510. captureConstraint: null;
  112511. targets: string[];
  112512. })[];
  112513. /** @hidden */
  112514. static _TextureLoaders: IInternalTextureLoader[];
  112515. /**
  112516. * Returns the current npm package of the sdk
  112517. */
  112518. static get NpmPackage(): string;
  112519. /**
  112520. * Returns the current version of the framework
  112521. */
  112522. static get Version(): string;
  112523. /**
  112524. * Returns a string describing the current engine
  112525. */
  112526. get description(): string;
  112527. /**
  112528. * Gets or sets the epsilon value used by collision engine
  112529. */
  112530. static CollisionsEpsilon: number;
  112531. /**
  112532. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112533. */
  112534. static get ShadersRepository(): string;
  112535. static set ShadersRepository(value: string);
  112536. /** @hidden */
  112537. _shaderProcessor: IShaderProcessor;
  112538. /**
  112539. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  112540. */
  112541. forcePOTTextures: boolean;
  112542. /**
  112543. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  112544. */
  112545. isFullscreen: boolean;
  112546. /**
  112547. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  112548. */
  112549. cullBackFaces: boolean;
  112550. /**
  112551. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  112552. */
  112553. renderEvenInBackground: boolean;
  112554. /**
  112555. * Gets or sets a boolean indicating that cache can be kept between frames
  112556. */
  112557. preventCacheWipeBetweenFrames: boolean;
  112558. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  112559. validateShaderPrograms: boolean;
  112560. /**
  112561. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  112562. * This can provide greater z depth for distant objects.
  112563. */
  112564. useReverseDepthBuffer: boolean;
  112565. /**
  112566. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  112567. */
  112568. disableUniformBuffers: boolean;
  112569. /** @hidden */
  112570. _uniformBuffers: UniformBuffer[];
  112571. /**
  112572. * Gets a boolean indicating that the engine supports uniform buffers
  112573. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  112574. */
  112575. get supportsUniformBuffers(): boolean;
  112576. /** @hidden */
  112577. _gl: WebGLRenderingContext;
  112578. /** @hidden */
  112579. _webGLVersion: number;
  112580. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  112581. protected _windowIsBackground: boolean;
  112582. protected _creationOptions: EngineOptions;
  112583. protected _highPrecisionShadersAllowed: boolean;
  112584. /** @hidden */
  112585. get _shouldUseHighPrecisionShader(): boolean;
  112586. /**
  112587. * Gets a boolean indicating that only power of 2 textures are supported
  112588. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  112589. */
  112590. get needPOTTextures(): boolean;
  112591. /** @hidden */
  112592. _badOS: boolean;
  112593. /** @hidden */
  112594. _badDesktopOS: boolean;
  112595. private _hardwareScalingLevel;
  112596. /** @hidden */
  112597. _caps: EngineCapabilities;
  112598. private _isStencilEnable;
  112599. private _glVersion;
  112600. private _glRenderer;
  112601. private _glVendor;
  112602. /** @hidden */
  112603. _videoTextureSupported: boolean;
  112604. protected _renderingQueueLaunched: boolean;
  112605. protected _activeRenderLoops: (() => void)[];
  112606. /**
  112607. * Observable signaled when a context lost event is raised
  112608. */
  112609. onContextLostObservable: Observable<ThinEngine>;
  112610. /**
  112611. * Observable signaled when a context restored event is raised
  112612. */
  112613. onContextRestoredObservable: Observable<ThinEngine>;
  112614. private _onContextLost;
  112615. private _onContextRestored;
  112616. protected _contextWasLost: boolean;
  112617. /** @hidden */
  112618. _doNotHandleContextLost: boolean;
  112619. /**
  112620. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  112621. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  112622. */
  112623. get doNotHandleContextLost(): boolean;
  112624. set doNotHandleContextLost(value: boolean);
  112625. /**
  112626. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  112627. */
  112628. disableVertexArrayObjects: boolean;
  112629. /** @hidden */
  112630. protected _colorWrite: boolean;
  112631. /** @hidden */
  112632. protected _colorWriteChanged: boolean;
  112633. /** @hidden */
  112634. protected _depthCullingState: DepthCullingState;
  112635. /** @hidden */
  112636. protected _stencilState: StencilState;
  112637. /** @hidden */
  112638. _alphaState: AlphaState;
  112639. /** @hidden */
  112640. _alphaMode: number;
  112641. /** @hidden */
  112642. _alphaEquation: number;
  112643. /** @hidden */
  112644. _internalTexturesCache: InternalTexture[];
  112645. /** @hidden */
  112646. protected _activeChannel: number;
  112647. private _currentTextureChannel;
  112648. /** @hidden */
  112649. protected _boundTexturesCache: {
  112650. [key: string]: Nullable<InternalTexture>;
  112651. };
  112652. /** @hidden */
  112653. protected _currentEffect: Nullable<Effect>;
  112654. /** @hidden */
  112655. protected _currentProgram: Nullable<WebGLProgram>;
  112656. private _compiledEffects;
  112657. private _vertexAttribArraysEnabled;
  112658. /** @hidden */
  112659. protected _cachedViewport: Nullable<IViewportLike>;
  112660. private _cachedVertexArrayObject;
  112661. /** @hidden */
  112662. protected _cachedVertexBuffers: any;
  112663. /** @hidden */
  112664. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  112665. /** @hidden */
  112666. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  112667. /** @hidden */
  112668. _currentRenderTarget: Nullable<InternalTexture>;
  112669. private _uintIndicesCurrentlySet;
  112670. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  112671. /** @hidden */
  112672. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  112673. /** @hidden */
  112674. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  112675. private _currentBufferPointers;
  112676. private _currentInstanceLocations;
  112677. private _currentInstanceBuffers;
  112678. private _textureUnits;
  112679. /** @hidden */
  112680. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112681. /** @hidden */
  112682. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112683. /** @hidden */
  112684. _boundRenderFunction: any;
  112685. private _vaoRecordInProgress;
  112686. private _mustWipeVertexAttributes;
  112687. private _emptyTexture;
  112688. private _emptyCubeTexture;
  112689. private _emptyTexture3D;
  112690. private _emptyTexture2DArray;
  112691. /** @hidden */
  112692. _frameHandler: number;
  112693. private _nextFreeTextureSlots;
  112694. private _maxSimultaneousTextures;
  112695. private _activeRequests;
  112696. /** @hidden */
  112697. _transformTextureUrl: Nullable<(url: string) => string>;
  112698. protected get _supportsHardwareTextureRescaling(): boolean;
  112699. private _framebufferDimensionsObject;
  112700. /**
  112701. * sets the object from which width and height will be taken from when getting render width and height
  112702. * Will fallback to the gl object
  112703. * @param dimensions the framebuffer width and height that will be used.
  112704. */
  112705. set framebufferDimensionsObject(dimensions: Nullable<{
  112706. framebufferWidth: number;
  112707. framebufferHeight: number;
  112708. }>);
  112709. /**
  112710. * Gets the current viewport
  112711. */
  112712. get currentViewport(): Nullable<IViewportLike>;
  112713. /**
  112714. * Gets the default empty texture
  112715. */
  112716. get emptyTexture(): InternalTexture;
  112717. /**
  112718. * Gets the default empty 3D texture
  112719. */
  112720. get emptyTexture3D(): InternalTexture;
  112721. /**
  112722. * Gets the default empty 2D array texture
  112723. */
  112724. get emptyTexture2DArray(): InternalTexture;
  112725. /**
  112726. * Gets the default empty cube texture
  112727. */
  112728. get emptyCubeTexture(): InternalTexture;
  112729. /**
  112730. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  112731. */
  112732. readonly premultipliedAlpha: boolean;
  112733. /**
  112734. * Observable event triggered before each texture is initialized
  112735. */
  112736. onBeforeTextureInitObservable: Observable<Texture>;
  112737. /**
  112738. * Creates a new engine
  112739. * @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
  112740. * @param antialias defines enable antialiasing (default: false)
  112741. * @param options defines further options to be sent to the getContext() function
  112742. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  112743. */
  112744. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  112745. private _rebuildInternalTextures;
  112746. private _rebuildEffects;
  112747. /**
  112748. * Gets a boolean indicating if all created effects are ready
  112749. * @returns true if all effects are ready
  112750. */
  112751. areAllEffectsReady(): boolean;
  112752. protected _rebuildBuffers(): void;
  112753. protected _initGLContext(): void;
  112754. /**
  112755. * Gets version of the current webGL context
  112756. */
  112757. get webGLVersion(): number;
  112758. /**
  112759. * Gets a string idenfifying the name of the class
  112760. * @returns "Engine" string
  112761. */
  112762. getClassName(): string;
  112763. /**
  112764. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  112765. */
  112766. get isStencilEnable(): boolean;
  112767. /** @hidden */
  112768. _prepareWorkingCanvas(): void;
  112769. /**
  112770. * Reset the texture cache to empty state
  112771. */
  112772. resetTextureCache(): void;
  112773. /**
  112774. * Gets an object containing information about the current webGL context
  112775. * @returns an object containing the vender, the renderer and the version of the current webGL context
  112776. */
  112777. getGlInfo(): {
  112778. vendor: string;
  112779. renderer: string;
  112780. version: string;
  112781. };
  112782. /**
  112783. * Defines the hardware scaling level.
  112784. * By default the hardware scaling level is computed from the window device ratio.
  112785. * 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.
  112786. * @param level defines the level to use
  112787. */
  112788. setHardwareScalingLevel(level: number): void;
  112789. /**
  112790. * Gets the current hardware scaling level.
  112791. * By default the hardware scaling level is computed from the window device ratio.
  112792. * 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.
  112793. * @returns a number indicating the current hardware scaling level
  112794. */
  112795. getHardwareScalingLevel(): number;
  112796. /**
  112797. * Gets the list of loaded textures
  112798. * @returns an array containing all loaded textures
  112799. */
  112800. getLoadedTexturesCache(): InternalTexture[];
  112801. /**
  112802. * Gets the object containing all engine capabilities
  112803. * @returns the EngineCapabilities object
  112804. */
  112805. getCaps(): EngineCapabilities;
  112806. /**
  112807. * stop executing a render loop function and remove it from the execution array
  112808. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  112809. */
  112810. stopRenderLoop(renderFunction?: () => void): void;
  112811. /** @hidden */
  112812. _renderLoop(): void;
  112813. /**
  112814. * Gets the HTML canvas attached with the current webGL context
  112815. * @returns a HTML canvas
  112816. */
  112817. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  112818. /**
  112819. * Gets host window
  112820. * @returns the host window object
  112821. */
  112822. getHostWindow(): Nullable<Window>;
  112823. /**
  112824. * Gets the current render width
  112825. * @param useScreen defines if screen size must be used (or the current render target if any)
  112826. * @returns a number defining the current render width
  112827. */
  112828. getRenderWidth(useScreen?: boolean): number;
  112829. /**
  112830. * Gets the current render height
  112831. * @param useScreen defines if screen size must be used (or the current render target if any)
  112832. * @returns a number defining the current render height
  112833. */
  112834. getRenderHeight(useScreen?: boolean): number;
  112835. /**
  112836. * Can be used to override the current requestAnimationFrame requester.
  112837. * @hidden
  112838. */
  112839. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  112840. /**
  112841. * Register and execute a render loop. The engine can have more than one render function
  112842. * @param renderFunction defines the function to continuously execute
  112843. */
  112844. runRenderLoop(renderFunction: () => void): void;
  112845. /**
  112846. * Clear the current render buffer or the current render target (if any is set up)
  112847. * @param color defines the color to use
  112848. * @param backBuffer defines if the back buffer must be cleared
  112849. * @param depth defines if the depth buffer must be cleared
  112850. * @param stencil defines if the stencil buffer must be cleared
  112851. */
  112852. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112853. private _viewportCached;
  112854. /** @hidden */
  112855. _viewport(x: number, y: number, width: number, height: number): void;
  112856. /**
  112857. * Set the WebGL's viewport
  112858. * @param viewport defines the viewport element to be used
  112859. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112860. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112861. */
  112862. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112863. /**
  112864. * Begin a new frame
  112865. */
  112866. beginFrame(): void;
  112867. /**
  112868. * Enf the current frame
  112869. */
  112870. endFrame(): void;
  112871. /**
  112872. * Resize the view according to the canvas' size
  112873. */
  112874. resize(): void;
  112875. /**
  112876. * Force a specific size of the canvas
  112877. * @param width defines the new canvas' width
  112878. * @param height defines the new canvas' height
  112879. * @returns true if the size was changed
  112880. */
  112881. setSize(width: number, height: number): boolean;
  112882. /**
  112883. * Binds the frame buffer to the specified texture.
  112884. * @param texture The texture to render to or null for the default canvas
  112885. * @param faceIndex The face of the texture to render to in case of cube texture
  112886. * @param requiredWidth The width of the target to render to
  112887. * @param requiredHeight The height of the target to render to
  112888. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112889. * @param lodLevel defines the lod level to bind to the frame buffer
  112890. * @param layer defines the 2d array index to bind to frame buffer to
  112891. */
  112892. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  112893. /** @hidden */
  112894. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  112895. /**
  112896. * Unbind the current render target texture from the webGL context
  112897. * @param texture defines the render target texture to unbind
  112898. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112899. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112900. */
  112901. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112902. /**
  112903. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  112904. */
  112905. flushFramebuffer(): void;
  112906. /**
  112907. * Unbind the current render target and bind the default framebuffer
  112908. */
  112909. restoreDefaultFramebuffer(): void;
  112910. /** @hidden */
  112911. protected _resetVertexBufferBinding(): void;
  112912. /**
  112913. * Creates a vertex buffer
  112914. * @param data the data for the vertex buffer
  112915. * @returns the new WebGL static buffer
  112916. */
  112917. createVertexBuffer(data: DataArray): DataBuffer;
  112918. private _createVertexBuffer;
  112919. /**
  112920. * Creates a dynamic vertex buffer
  112921. * @param data the data for the dynamic vertex buffer
  112922. * @returns the new WebGL dynamic buffer
  112923. */
  112924. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112925. protected _resetIndexBufferBinding(): void;
  112926. /**
  112927. * Creates a new index buffer
  112928. * @param indices defines the content of the index buffer
  112929. * @param updatable defines if the index buffer must be updatable
  112930. * @returns a new webGL buffer
  112931. */
  112932. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  112933. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  112934. /**
  112935. * Bind a webGL buffer to the webGL context
  112936. * @param buffer defines the buffer to bind
  112937. */
  112938. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  112939. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  112940. private bindBuffer;
  112941. /**
  112942. * update the bound buffer with the given data
  112943. * @param data defines the data to update
  112944. */
  112945. updateArrayBuffer(data: Float32Array): void;
  112946. private _vertexAttribPointer;
  112947. /** @hidden */
  112948. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  112949. private _bindVertexBuffersAttributes;
  112950. /**
  112951. * Records a vertex array object
  112952. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112953. * @param vertexBuffers defines the list of vertex buffers to store
  112954. * @param indexBuffer defines the index buffer to store
  112955. * @param effect defines the effect to store
  112956. * @returns the new vertex array object
  112957. */
  112958. recordVertexArrayObject(vertexBuffers: {
  112959. [key: string]: VertexBuffer;
  112960. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112961. /**
  112962. * Bind a specific vertex array object
  112963. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112964. * @param vertexArrayObject defines the vertex array object to bind
  112965. * @param indexBuffer defines the index buffer to bind
  112966. */
  112967. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  112968. /**
  112969. * Bind webGl buffers directly to the webGL context
  112970. * @param vertexBuffer defines the vertex buffer to bind
  112971. * @param indexBuffer defines the index buffer to bind
  112972. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112973. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112974. * @param effect defines the effect associated with the vertex buffer
  112975. */
  112976. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  112977. private _unbindVertexArrayObject;
  112978. /**
  112979. * Bind a list of vertex buffers to the webGL context
  112980. * @param vertexBuffers defines the list of vertex buffers to bind
  112981. * @param indexBuffer defines the index buffer to bind
  112982. * @param effect defines the effect associated with the vertex buffers
  112983. */
  112984. bindBuffers(vertexBuffers: {
  112985. [key: string]: Nullable<VertexBuffer>;
  112986. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  112987. /**
  112988. * Unbind all instance attributes
  112989. */
  112990. unbindInstanceAttributes(): void;
  112991. /**
  112992. * Release and free the memory of a vertex array object
  112993. * @param vao defines the vertex array object to delete
  112994. */
  112995. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  112996. /** @hidden */
  112997. _releaseBuffer(buffer: DataBuffer): boolean;
  112998. protected _deleteBuffer(buffer: DataBuffer): void;
  112999. /**
  113000. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  113001. * @param instancesBuffer defines the webGL buffer to update and bind
  113002. * @param data defines the data to store in the buffer
  113003. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  113004. */
  113005. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  113006. /**
  113007. * Bind the content of a webGL buffer used with instantiation
  113008. * @param instancesBuffer defines the webGL buffer to bind
  113009. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  113010. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  113011. */
  113012. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  113013. /**
  113014. * Disable the instance attribute corresponding to the name in parameter
  113015. * @param name defines the name of the attribute to disable
  113016. */
  113017. disableInstanceAttributeByName(name: string): void;
  113018. /**
  113019. * Disable the instance attribute corresponding to the location in parameter
  113020. * @param attributeLocation defines the attribute location of the attribute to disable
  113021. */
  113022. disableInstanceAttribute(attributeLocation: number): void;
  113023. /**
  113024. * Disable the attribute corresponding to the location in parameter
  113025. * @param attributeLocation defines the attribute location of the attribute to disable
  113026. */
  113027. disableAttributeByIndex(attributeLocation: number): void;
  113028. /**
  113029. * Send a draw order
  113030. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113031. * @param indexStart defines the starting index
  113032. * @param indexCount defines the number of index to draw
  113033. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113034. */
  113035. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  113036. /**
  113037. * Draw a list of points
  113038. * @param verticesStart defines the index of first vertex to draw
  113039. * @param verticesCount defines the count of vertices to draw
  113040. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113041. */
  113042. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113043. /**
  113044. * Draw a list of unindexed primitives
  113045. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113046. * @param verticesStart defines the index of first vertex to draw
  113047. * @param verticesCount defines the count of vertices to draw
  113048. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113049. */
  113050. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113051. /**
  113052. * Draw a list of indexed primitives
  113053. * @param fillMode defines the primitive to use
  113054. * @param indexStart defines the starting index
  113055. * @param indexCount defines the number of index to draw
  113056. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113057. */
  113058. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113059. /**
  113060. * Draw a list of unindexed primitives
  113061. * @param fillMode defines the primitive to use
  113062. * @param verticesStart defines the index of first vertex to draw
  113063. * @param verticesCount defines the count of vertices to draw
  113064. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113065. */
  113066. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113067. private _drawMode;
  113068. /** @hidden */
  113069. protected _reportDrawCall(): void;
  113070. /** @hidden */
  113071. _releaseEffect(effect: Effect): void;
  113072. /** @hidden */
  113073. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113074. /**
  113075. * Create a new effect (used to store vertex/fragment shaders)
  113076. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  113077. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  113078. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  113079. * @param samplers defines an array of string used to represent textures
  113080. * @param defines defines the string containing the defines to use to compile the shaders
  113081. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  113082. * @param onCompiled defines a function to call when the effect creation is successful
  113083. * @param onError defines a function to call when the effect creation has failed
  113084. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  113085. * @returns the new Effect
  113086. */
  113087. 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;
  113088. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  113089. private _compileShader;
  113090. private _compileRawShader;
  113091. /** @hidden */
  113092. _getShaderSource(shader: WebGLShader): Nullable<string>;
  113093. /**
  113094. * Directly creates a webGL program
  113095. * @param pipelineContext defines the pipeline context to attach to
  113096. * @param vertexCode defines the vertex shader code to use
  113097. * @param fragmentCode defines the fragment shader code to use
  113098. * @param context defines the webGL context to use (if not set, the current one will be used)
  113099. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  113100. * @returns the new webGL program
  113101. */
  113102. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113103. /**
  113104. * Creates a webGL program
  113105. * @param pipelineContext defines the pipeline context to attach to
  113106. * @param vertexCode defines the vertex shader code to use
  113107. * @param fragmentCode defines the fragment shader code to use
  113108. * @param defines defines the string containing the defines to use to compile the shaders
  113109. * @param context defines the webGL context to use (if not set, the current one will be used)
  113110. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  113111. * @returns the new webGL program
  113112. */
  113113. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113114. /**
  113115. * Creates a new pipeline context
  113116. * @returns the new pipeline
  113117. */
  113118. createPipelineContext(): IPipelineContext;
  113119. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113120. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  113121. /** @hidden */
  113122. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113123. /** @hidden */
  113124. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113125. /** @hidden */
  113126. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113127. /**
  113128. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  113129. * @param pipelineContext defines the pipeline context to use
  113130. * @param uniformsNames defines the list of uniform names
  113131. * @returns an array of webGL uniform locations
  113132. */
  113133. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  113134. /**
  113135. * Gets the lsit of active attributes for a given webGL program
  113136. * @param pipelineContext defines the pipeline context to use
  113137. * @param attributesNames defines the list of attribute names to get
  113138. * @returns an array of indices indicating the offset of each attribute
  113139. */
  113140. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113141. /**
  113142. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  113143. * @param effect defines the effect to activate
  113144. */
  113145. enableEffect(effect: Nullable<Effect>): void;
  113146. /**
  113147. * Set the value of an uniform to a number (int)
  113148. * @param uniform defines the webGL uniform location where to store the value
  113149. * @param value defines the int number to store
  113150. */
  113151. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  113152. /**
  113153. * Set the value of an uniform to an array of int32
  113154. * @param uniform defines the webGL uniform location where to store the value
  113155. * @param array defines the array of int32 to store
  113156. */
  113157. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113158. /**
  113159. * Set the value of an uniform to an array of int32 (stored as vec2)
  113160. * @param uniform defines the webGL uniform location where to store the value
  113161. * @param array defines the array of int32 to store
  113162. */
  113163. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113164. /**
  113165. * Set the value of an uniform to an array of int32 (stored as vec3)
  113166. * @param uniform defines the webGL uniform location where to store the value
  113167. * @param array defines the array of int32 to store
  113168. */
  113169. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113170. /**
  113171. * Set the value of an uniform to an array of int32 (stored as vec4)
  113172. * @param uniform defines the webGL uniform location where to store the value
  113173. * @param array defines the array of int32 to store
  113174. */
  113175. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113176. /**
  113177. * Set the value of an uniform to an array of number
  113178. * @param uniform defines the webGL uniform location where to store the value
  113179. * @param array defines the array of number to store
  113180. */
  113181. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113182. /**
  113183. * Set the value of an uniform to an array of number (stored as vec2)
  113184. * @param uniform defines the webGL uniform location where to store the value
  113185. * @param array defines the array of number to store
  113186. */
  113187. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113188. /**
  113189. * Set the value of an uniform to an array of number (stored as vec3)
  113190. * @param uniform defines the webGL uniform location where to store the value
  113191. * @param array defines the array of number to store
  113192. */
  113193. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113194. /**
  113195. * Set the value of an uniform to an array of number (stored as vec4)
  113196. * @param uniform defines the webGL uniform location where to store the value
  113197. * @param array defines the array of number to store
  113198. */
  113199. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113200. /**
  113201. * Set the value of an uniform to an array of float32 (stored as matrices)
  113202. * @param uniform defines the webGL uniform location where to store the value
  113203. * @param matrices defines the array of float32 to store
  113204. */
  113205. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  113206. /**
  113207. * Set the value of an uniform to a matrix (3x3)
  113208. * @param uniform defines the webGL uniform location where to store the value
  113209. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  113210. */
  113211. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  113212. /**
  113213. * Set the value of an uniform to a matrix (2x2)
  113214. * @param uniform defines the webGL uniform location where to store the value
  113215. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  113216. */
  113217. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  113218. /**
  113219. * Set the value of an uniform to a number (float)
  113220. * @param uniform defines the webGL uniform location where to store the value
  113221. * @param value defines the float number to store
  113222. */
  113223. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  113224. /**
  113225. * Set the value of an uniform to a vec2
  113226. * @param uniform defines the webGL uniform location where to store the value
  113227. * @param x defines the 1st component of the value
  113228. * @param y defines the 2nd component of the value
  113229. */
  113230. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  113231. /**
  113232. * Set the value of an uniform to a vec3
  113233. * @param uniform defines the webGL uniform location where to store the value
  113234. * @param x defines the 1st component of the value
  113235. * @param y defines the 2nd component of the value
  113236. * @param z defines the 3rd component of the value
  113237. */
  113238. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  113239. /**
  113240. * Set the value of an uniform to a vec4
  113241. * @param uniform defines the webGL uniform location where to store the value
  113242. * @param x defines the 1st component of the value
  113243. * @param y defines the 2nd component of the value
  113244. * @param z defines the 3rd component of the value
  113245. * @param w defines the 4th component of the value
  113246. */
  113247. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  113248. /**
  113249. * Apply all cached states (depth, culling, stencil and alpha)
  113250. */
  113251. applyStates(): void;
  113252. /**
  113253. * Enable or disable color writing
  113254. * @param enable defines the state to set
  113255. */
  113256. setColorWrite(enable: boolean): void;
  113257. /**
  113258. * Gets a boolean indicating if color writing is enabled
  113259. * @returns the current color writing state
  113260. */
  113261. getColorWrite(): boolean;
  113262. /**
  113263. * Gets the depth culling state manager
  113264. */
  113265. get depthCullingState(): DepthCullingState;
  113266. /**
  113267. * Gets the alpha state manager
  113268. */
  113269. get alphaState(): AlphaState;
  113270. /**
  113271. * Gets the stencil state manager
  113272. */
  113273. get stencilState(): StencilState;
  113274. /**
  113275. * Clears the list of texture accessible through engine.
  113276. * This can help preventing texture load conflict due to name collision.
  113277. */
  113278. clearInternalTexturesCache(): void;
  113279. /**
  113280. * Force the entire cache to be cleared
  113281. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  113282. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  113283. */
  113284. wipeCaches(bruteForce?: boolean): void;
  113285. /** @hidden */
  113286. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  113287. min: number;
  113288. mag: number;
  113289. };
  113290. /** @hidden */
  113291. _createTexture(): WebGLTexture;
  113292. /**
  113293. * Usually called from Texture.ts.
  113294. * Passed information to create a WebGLTexture
  113295. * @param url defines a value which contains one of the following:
  113296. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113297. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113298. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113299. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113300. * @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)
  113301. * @param scene needed for loading to the correct scene
  113302. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  113303. * @param onLoad optional callback to be called upon successful completion
  113304. * @param onError optional callback to be called upon failure
  113305. * @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
  113306. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113307. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113308. * @param forcedExtension defines the extension to use to pick the right loader
  113309. * @param mimeType defines an optional mime type
  113310. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113311. */
  113312. 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;
  113313. /**
  113314. * Loads an image as an HTMLImageElement.
  113315. * @param input url string, ArrayBuffer, or Blob to load
  113316. * @param onLoad callback called when the image successfully loads
  113317. * @param onError callback called when the image fails to load
  113318. * @param offlineProvider offline provider for caching
  113319. * @param mimeType optional mime type
  113320. * @returns the HTMLImageElement of the loaded image
  113321. * @hidden
  113322. */
  113323. 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>;
  113324. /**
  113325. * @hidden
  113326. */
  113327. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  113328. private _unpackFlipYCached;
  113329. /**
  113330. * In case you are sharing the context with other applications, it might
  113331. * be interested to not cache the unpack flip y state to ensure a consistent
  113332. * value would be set.
  113333. */
  113334. enableUnpackFlipYCached: boolean;
  113335. /** @hidden */
  113336. _unpackFlipY(value: boolean): void;
  113337. /** @hidden */
  113338. _getUnpackAlignement(): number;
  113339. private _getTextureTarget;
  113340. /**
  113341. * Update the sampling mode of a given texture
  113342. * @param samplingMode defines the required sampling mode
  113343. * @param texture defines the texture to update
  113344. * @param generateMipMaps defines whether to generate mipmaps for the texture
  113345. */
  113346. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  113347. /**
  113348. * Update the sampling mode of a given texture
  113349. * @param texture defines the texture to update
  113350. * @param wrapU defines the texture wrap mode of the u coordinates
  113351. * @param wrapV defines the texture wrap mode of the v coordinates
  113352. * @param wrapR defines the texture wrap mode of the r coordinates
  113353. */
  113354. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  113355. /** @hidden */
  113356. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  113357. width: number;
  113358. height: number;
  113359. layers?: number;
  113360. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  113361. /** @hidden */
  113362. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113363. /** @hidden */
  113364. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  113365. /**
  113366. * Update a portion of an internal texture
  113367. * @param texture defines the texture to update
  113368. * @param imageData defines the data to store into the texture
  113369. * @param xOffset defines the x coordinates of the update rectangle
  113370. * @param yOffset defines the y coordinates of the update rectangle
  113371. * @param width defines the width of the update rectangle
  113372. * @param height defines the height of the update rectangle
  113373. * @param faceIndex defines the face index if texture is a cube (0 by default)
  113374. * @param lod defines the lod level to update (0 by default)
  113375. */
  113376. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  113377. /** @hidden */
  113378. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113379. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  113380. private _prepareWebGLTexture;
  113381. /** @hidden */
  113382. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  113383. private _getDepthStencilBuffer;
  113384. /** @hidden */
  113385. _releaseFramebufferObjects(texture: InternalTexture): void;
  113386. /** @hidden */
  113387. _releaseTexture(texture: InternalTexture): void;
  113388. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113389. protected _setProgram(program: WebGLProgram): void;
  113390. protected _boundUniforms: {
  113391. [key: number]: WebGLUniformLocation;
  113392. };
  113393. /**
  113394. * Binds an effect to the webGL context
  113395. * @param effect defines the effect to bind
  113396. */
  113397. bindSamplers(effect: Effect): void;
  113398. private _activateCurrentTexture;
  113399. /** @hidden */
  113400. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  113401. /** @hidden */
  113402. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  113403. /**
  113404. * Unbind all textures from the webGL context
  113405. */
  113406. unbindAllTextures(): void;
  113407. /**
  113408. * Sets a texture to the according uniform.
  113409. * @param channel The texture channel
  113410. * @param uniform The uniform to set
  113411. * @param texture The texture to apply
  113412. */
  113413. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  113414. private _bindSamplerUniformToChannel;
  113415. private _getTextureWrapMode;
  113416. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113417. /**
  113418. * Sets an array of texture to the webGL context
  113419. * @param channel defines the channel where the texture array must be set
  113420. * @param uniform defines the associated uniform location
  113421. * @param textures defines the array of textures to bind
  113422. */
  113423. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  113424. /** @hidden */
  113425. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  113426. private _setTextureParameterFloat;
  113427. private _setTextureParameterInteger;
  113428. /**
  113429. * Unbind all vertex attributes from the webGL context
  113430. */
  113431. unbindAllAttributes(): void;
  113432. /**
  113433. * 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
  113434. */
  113435. releaseEffects(): void;
  113436. /**
  113437. * Dispose and release all associated resources
  113438. */
  113439. dispose(): void;
  113440. /**
  113441. * Attach a new callback raised when context lost event is fired
  113442. * @param callback defines the callback to call
  113443. */
  113444. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113445. /**
  113446. * Attach a new callback raised when context restored event is fired
  113447. * @param callback defines the callback to call
  113448. */
  113449. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113450. /**
  113451. * Get the current error code of the webGL context
  113452. * @returns the error code
  113453. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113454. */
  113455. getError(): number;
  113456. private _canRenderToFloatFramebuffer;
  113457. private _canRenderToHalfFloatFramebuffer;
  113458. private _canRenderToFramebuffer;
  113459. /** @hidden */
  113460. _getWebGLTextureType(type: number): number;
  113461. /** @hidden */
  113462. _getInternalFormat(format: number): number;
  113463. /** @hidden */
  113464. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  113465. /** @hidden */
  113466. _getRGBAMultiSampleBufferFormat(type: number): number;
  113467. /** @hidden */
  113468. _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;
  113469. /**
  113470. * Loads a file from a url
  113471. * @param url url to load
  113472. * @param onSuccess callback called when the file successfully loads
  113473. * @param onProgress callback called while file is loading (if the server supports this mode)
  113474. * @param offlineProvider defines the offline provider for caching
  113475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113476. * @param onError callback called when the file fails to load
  113477. * @returns a file request object
  113478. * @hidden
  113479. */
  113480. 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;
  113481. /**
  113482. * Reads pixels from the current frame buffer. Please note that this function can be slow
  113483. * @param x defines the x coordinate of the rectangle where pixels must be read
  113484. * @param y defines the y coordinate of the rectangle where pixels must be read
  113485. * @param width defines the width of the rectangle where pixels must be read
  113486. * @param height defines the height of the rectangle where pixels must be read
  113487. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  113488. * @returns a Uint8Array containing RGBA colors
  113489. */
  113490. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  113491. private static _isSupported;
  113492. /**
  113493. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  113494. * @returns true if the engine can be created
  113495. * @ignorenaming
  113496. */
  113497. static isSupported(): boolean;
  113498. /**
  113499. * Find the next highest power of two.
  113500. * @param x Number to start search from.
  113501. * @return Next highest power of two.
  113502. */
  113503. static CeilingPOT(x: number): number;
  113504. /**
  113505. * Find the next lowest power of two.
  113506. * @param x Number to start search from.
  113507. * @return Next lowest power of two.
  113508. */
  113509. static FloorPOT(x: number): number;
  113510. /**
  113511. * Find the nearest power of two.
  113512. * @param x Number to start search from.
  113513. * @return Next nearest power of two.
  113514. */
  113515. static NearestPOT(x: number): number;
  113516. /**
  113517. * Get the closest exponent of two
  113518. * @param value defines the value to approximate
  113519. * @param max defines the maximum value to return
  113520. * @param mode defines how to define the closest value
  113521. * @returns closest exponent of two of the given value
  113522. */
  113523. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  113524. /**
  113525. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  113526. * @param func - the function to be called
  113527. * @param requester - the object that will request the next frame. Falls back to window.
  113528. * @returns frame number
  113529. */
  113530. static QueueNewFrame(func: () => void, requester?: any): number;
  113531. /**
  113532. * Gets host document
  113533. * @returns the host document object
  113534. */
  113535. getHostDocument(): Nullable<Document>;
  113536. }
  113537. }
  113538. declare module BABYLON {
  113539. /**
  113540. * Class representing spherical harmonics coefficients to the 3rd degree
  113541. */
  113542. export class SphericalHarmonics {
  113543. /**
  113544. * Defines whether or not the harmonics have been prescaled for rendering.
  113545. */
  113546. preScaled: boolean;
  113547. /**
  113548. * The l0,0 coefficients of the spherical harmonics
  113549. */
  113550. l00: Vector3;
  113551. /**
  113552. * The l1,-1 coefficients of the spherical harmonics
  113553. */
  113554. l1_1: Vector3;
  113555. /**
  113556. * The l1,0 coefficients of the spherical harmonics
  113557. */
  113558. l10: Vector3;
  113559. /**
  113560. * The l1,1 coefficients of the spherical harmonics
  113561. */
  113562. l11: Vector3;
  113563. /**
  113564. * The l2,-2 coefficients of the spherical harmonics
  113565. */
  113566. l2_2: Vector3;
  113567. /**
  113568. * The l2,-1 coefficients of the spherical harmonics
  113569. */
  113570. l2_1: Vector3;
  113571. /**
  113572. * The l2,0 coefficients of the spherical harmonics
  113573. */
  113574. l20: Vector3;
  113575. /**
  113576. * The l2,1 coefficients of the spherical harmonics
  113577. */
  113578. l21: Vector3;
  113579. /**
  113580. * The l2,2 coefficients of the spherical harmonics
  113581. */
  113582. l22: Vector3;
  113583. /**
  113584. * Adds a light to the spherical harmonics
  113585. * @param direction the direction of the light
  113586. * @param color the color of the light
  113587. * @param deltaSolidAngle the delta solid angle of the light
  113588. */
  113589. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  113590. /**
  113591. * Scales the spherical harmonics by the given amount
  113592. * @param scale the amount to scale
  113593. */
  113594. scaleInPlace(scale: number): void;
  113595. /**
  113596. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  113597. *
  113598. * ```
  113599. * E_lm = A_l * L_lm
  113600. * ```
  113601. *
  113602. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  113603. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  113604. * the scaling factors are given in equation 9.
  113605. */
  113606. convertIncidentRadianceToIrradiance(): void;
  113607. /**
  113608. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  113609. *
  113610. * ```
  113611. * L = (1/pi) * E * rho
  113612. * ```
  113613. *
  113614. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  113615. */
  113616. convertIrradianceToLambertianRadiance(): void;
  113617. /**
  113618. * Integrates the reconstruction coefficients directly in to the SH preventing further
  113619. * required operations at run time.
  113620. *
  113621. * This is simply done by scaling back the SH with Ylm constants parameter.
  113622. * The trigonometric part being applied by the shader at run time.
  113623. */
  113624. preScaleForRendering(): void;
  113625. /**
  113626. * Constructs a spherical harmonics from an array.
  113627. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  113628. * @returns the spherical harmonics
  113629. */
  113630. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  113631. /**
  113632. * Gets the spherical harmonics from polynomial
  113633. * @param polynomial the spherical polynomial
  113634. * @returns the spherical harmonics
  113635. */
  113636. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  113637. }
  113638. /**
  113639. * Class representing spherical polynomial coefficients to the 3rd degree
  113640. */
  113641. export class SphericalPolynomial {
  113642. private _harmonics;
  113643. /**
  113644. * The spherical harmonics used to create the polynomials.
  113645. */
  113646. get preScaledHarmonics(): SphericalHarmonics;
  113647. /**
  113648. * The x coefficients of the spherical polynomial
  113649. */
  113650. x: Vector3;
  113651. /**
  113652. * The y coefficients of the spherical polynomial
  113653. */
  113654. y: Vector3;
  113655. /**
  113656. * The z coefficients of the spherical polynomial
  113657. */
  113658. z: Vector3;
  113659. /**
  113660. * The xx coefficients of the spherical polynomial
  113661. */
  113662. xx: Vector3;
  113663. /**
  113664. * The yy coefficients of the spherical polynomial
  113665. */
  113666. yy: Vector3;
  113667. /**
  113668. * The zz coefficients of the spherical polynomial
  113669. */
  113670. zz: Vector3;
  113671. /**
  113672. * The xy coefficients of the spherical polynomial
  113673. */
  113674. xy: Vector3;
  113675. /**
  113676. * The yz coefficients of the spherical polynomial
  113677. */
  113678. yz: Vector3;
  113679. /**
  113680. * The zx coefficients of the spherical polynomial
  113681. */
  113682. zx: Vector3;
  113683. /**
  113684. * Adds an ambient color to the spherical polynomial
  113685. * @param color the color to add
  113686. */
  113687. addAmbient(color: Color3): void;
  113688. /**
  113689. * Scales the spherical polynomial by the given amount
  113690. * @param scale the amount to scale
  113691. */
  113692. scaleInPlace(scale: number): void;
  113693. /**
  113694. * Gets the spherical polynomial from harmonics
  113695. * @param harmonics the spherical harmonics
  113696. * @returns the spherical polynomial
  113697. */
  113698. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  113699. /**
  113700. * Constructs a spherical polynomial from an array.
  113701. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  113702. * @returns the spherical polynomial
  113703. */
  113704. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  113705. }
  113706. }
  113707. declare module BABYLON {
  113708. /**
  113709. * Defines the source of the internal texture
  113710. */
  113711. export enum InternalTextureSource {
  113712. /**
  113713. * The source of the texture data is unknown
  113714. */
  113715. Unknown = 0,
  113716. /**
  113717. * Texture data comes from an URL
  113718. */
  113719. Url = 1,
  113720. /**
  113721. * Texture data is only used for temporary storage
  113722. */
  113723. Temp = 2,
  113724. /**
  113725. * Texture data comes from raw data (ArrayBuffer)
  113726. */
  113727. Raw = 3,
  113728. /**
  113729. * Texture content is dynamic (video or dynamic texture)
  113730. */
  113731. Dynamic = 4,
  113732. /**
  113733. * Texture content is generated by rendering to it
  113734. */
  113735. RenderTarget = 5,
  113736. /**
  113737. * Texture content is part of a multi render target process
  113738. */
  113739. MultiRenderTarget = 6,
  113740. /**
  113741. * Texture data comes from a cube data file
  113742. */
  113743. Cube = 7,
  113744. /**
  113745. * Texture data comes from a raw cube data
  113746. */
  113747. CubeRaw = 8,
  113748. /**
  113749. * Texture data come from a prefiltered cube data file
  113750. */
  113751. CubePrefiltered = 9,
  113752. /**
  113753. * Texture content is raw 3D data
  113754. */
  113755. Raw3D = 10,
  113756. /**
  113757. * Texture content is raw 2D array data
  113758. */
  113759. Raw2DArray = 11,
  113760. /**
  113761. * Texture content is a depth texture
  113762. */
  113763. Depth = 12,
  113764. /**
  113765. * Texture data comes from a raw cube data encoded with RGBD
  113766. */
  113767. CubeRawRGBD = 13
  113768. }
  113769. /**
  113770. * Class used to store data associated with WebGL texture data for the engine
  113771. * This class should not be used directly
  113772. */
  113773. export class InternalTexture {
  113774. /** @hidden */
  113775. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  113776. /**
  113777. * Defines if the texture is ready
  113778. */
  113779. isReady: boolean;
  113780. /**
  113781. * Defines if the texture is a cube texture
  113782. */
  113783. isCube: boolean;
  113784. /**
  113785. * Defines if the texture contains 3D data
  113786. */
  113787. is3D: boolean;
  113788. /**
  113789. * Defines if the texture contains 2D array data
  113790. */
  113791. is2DArray: boolean;
  113792. /**
  113793. * Defines if the texture contains multiview data
  113794. */
  113795. isMultiview: boolean;
  113796. /**
  113797. * Gets the URL used to load this texture
  113798. */
  113799. url: string;
  113800. /**
  113801. * Gets the sampling mode of the texture
  113802. */
  113803. samplingMode: number;
  113804. /**
  113805. * Gets a boolean indicating if the texture needs mipmaps generation
  113806. */
  113807. generateMipMaps: boolean;
  113808. /**
  113809. * Gets the number of samples used by the texture (WebGL2+ only)
  113810. */
  113811. samples: number;
  113812. /**
  113813. * Gets the type of the texture (int, float...)
  113814. */
  113815. type: number;
  113816. /**
  113817. * Gets the format of the texture (RGB, RGBA...)
  113818. */
  113819. format: number;
  113820. /**
  113821. * Observable called when the texture is loaded
  113822. */
  113823. onLoadedObservable: Observable<InternalTexture>;
  113824. /**
  113825. * Gets the width of the texture
  113826. */
  113827. width: number;
  113828. /**
  113829. * Gets the height of the texture
  113830. */
  113831. height: number;
  113832. /**
  113833. * Gets the depth of the texture
  113834. */
  113835. depth: number;
  113836. /**
  113837. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  113838. */
  113839. baseWidth: number;
  113840. /**
  113841. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  113842. */
  113843. baseHeight: number;
  113844. /**
  113845. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  113846. */
  113847. baseDepth: number;
  113848. /**
  113849. * Gets a boolean indicating if the texture is inverted on Y axis
  113850. */
  113851. invertY: boolean;
  113852. /** @hidden */
  113853. _invertVScale: boolean;
  113854. /** @hidden */
  113855. _associatedChannel: number;
  113856. /** @hidden */
  113857. _source: InternalTextureSource;
  113858. /** @hidden */
  113859. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  113860. /** @hidden */
  113861. _bufferView: Nullable<ArrayBufferView>;
  113862. /** @hidden */
  113863. _bufferViewArray: Nullable<ArrayBufferView[]>;
  113864. /** @hidden */
  113865. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  113866. /** @hidden */
  113867. _size: number;
  113868. /** @hidden */
  113869. _extension: string;
  113870. /** @hidden */
  113871. _files: Nullable<string[]>;
  113872. /** @hidden */
  113873. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  113874. /** @hidden */
  113875. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  113876. /** @hidden */
  113877. _framebuffer: Nullable<WebGLFramebuffer>;
  113878. /** @hidden */
  113879. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  113880. /** @hidden */
  113881. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  113882. /** @hidden */
  113883. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  113884. /** @hidden */
  113885. _attachments: Nullable<number[]>;
  113886. /** @hidden */
  113887. _textureArray: Nullable<InternalTexture[]>;
  113888. /** @hidden */
  113889. _cachedCoordinatesMode: Nullable<number>;
  113890. /** @hidden */
  113891. _cachedWrapU: Nullable<number>;
  113892. /** @hidden */
  113893. _cachedWrapV: Nullable<number>;
  113894. /** @hidden */
  113895. _cachedWrapR: Nullable<number>;
  113896. /** @hidden */
  113897. _cachedAnisotropicFilteringLevel: Nullable<number>;
  113898. /** @hidden */
  113899. _isDisabled: boolean;
  113900. /** @hidden */
  113901. _compression: Nullable<string>;
  113902. /** @hidden */
  113903. _generateStencilBuffer: boolean;
  113904. /** @hidden */
  113905. _generateDepthBuffer: boolean;
  113906. /** @hidden */
  113907. _comparisonFunction: number;
  113908. /** @hidden */
  113909. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  113910. /** @hidden */
  113911. _lodGenerationScale: number;
  113912. /** @hidden */
  113913. _lodGenerationOffset: number;
  113914. /** @hidden */
  113915. _depthStencilTexture: Nullable<InternalTexture>;
  113916. /** @hidden */
  113917. _colorTextureArray: Nullable<WebGLTexture>;
  113918. /** @hidden */
  113919. _depthStencilTextureArray: Nullable<WebGLTexture>;
  113920. /** @hidden */
  113921. _lodTextureHigh: Nullable<BaseTexture>;
  113922. /** @hidden */
  113923. _lodTextureMid: Nullable<BaseTexture>;
  113924. /** @hidden */
  113925. _lodTextureLow: Nullable<BaseTexture>;
  113926. /** @hidden */
  113927. _isRGBD: boolean;
  113928. /** @hidden */
  113929. _linearSpecularLOD: boolean;
  113930. /** @hidden */
  113931. _irradianceTexture: Nullable<BaseTexture>;
  113932. /** @hidden */
  113933. _webGLTexture: Nullable<WebGLTexture>;
  113934. /** @hidden */
  113935. _references: number;
  113936. private _engine;
  113937. /**
  113938. * Gets the Engine the texture belongs to.
  113939. * @returns The babylon engine
  113940. */
  113941. getEngine(): ThinEngine;
  113942. /**
  113943. * Gets the data source type of the texture
  113944. */
  113945. get source(): InternalTextureSource;
  113946. /**
  113947. * Creates a new InternalTexture
  113948. * @param engine defines the engine to use
  113949. * @param source defines the type of data that will be used
  113950. * @param delayAllocation if the texture allocation should be delayed (default: false)
  113951. */
  113952. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  113953. /**
  113954. * Increments the number of references (ie. the number of Texture that point to it)
  113955. */
  113956. incrementReferences(): void;
  113957. /**
  113958. * Change the size of the texture (not the size of the content)
  113959. * @param width defines the new width
  113960. * @param height defines the new height
  113961. * @param depth defines the new depth (1 by default)
  113962. */
  113963. updateSize(width: int, height: int, depth?: int): void;
  113964. /** @hidden */
  113965. _rebuild(): void;
  113966. /** @hidden */
  113967. _swapAndDie(target: InternalTexture): void;
  113968. /**
  113969. * Dispose the current allocated resources
  113970. */
  113971. dispose(): void;
  113972. }
  113973. }
  113974. declare module BABYLON {
  113975. /**
  113976. * Class used to work with sound analyzer using fast fourier transform (FFT)
  113977. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  113978. */
  113979. export class Analyser {
  113980. /**
  113981. * Gets or sets the smoothing
  113982. * @ignorenaming
  113983. */
  113984. SMOOTHING: number;
  113985. /**
  113986. * Gets or sets the FFT table size
  113987. * @ignorenaming
  113988. */
  113989. FFT_SIZE: number;
  113990. /**
  113991. * Gets or sets the bar graph amplitude
  113992. * @ignorenaming
  113993. */
  113994. BARGRAPHAMPLITUDE: number;
  113995. /**
  113996. * Gets or sets the position of the debug canvas
  113997. * @ignorenaming
  113998. */
  113999. DEBUGCANVASPOS: {
  114000. x: number;
  114001. y: number;
  114002. };
  114003. /**
  114004. * Gets or sets the debug canvas size
  114005. * @ignorenaming
  114006. */
  114007. DEBUGCANVASSIZE: {
  114008. width: number;
  114009. height: number;
  114010. };
  114011. private _byteFreqs;
  114012. private _byteTime;
  114013. private _floatFreqs;
  114014. private _webAudioAnalyser;
  114015. private _debugCanvas;
  114016. private _debugCanvasContext;
  114017. private _scene;
  114018. private _registerFunc;
  114019. private _audioEngine;
  114020. /**
  114021. * Creates a new analyser
  114022. * @param scene defines hosting scene
  114023. */
  114024. constructor(scene: Scene);
  114025. /**
  114026. * Get the number of data values you will have to play with for the visualization
  114027. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  114028. * @returns a number
  114029. */
  114030. getFrequencyBinCount(): number;
  114031. /**
  114032. * Gets the current frequency data as a byte array
  114033. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  114034. * @returns a Uint8Array
  114035. */
  114036. getByteFrequencyData(): Uint8Array;
  114037. /**
  114038. * Gets the current waveform as a byte array
  114039. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  114040. * @returns a Uint8Array
  114041. */
  114042. getByteTimeDomainData(): Uint8Array;
  114043. /**
  114044. * Gets the current frequency data as a float array
  114045. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  114046. * @returns a Float32Array
  114047. */
  114048. getFloatFrequencyData(): Float32Array;
  114049. /**
  114050. * Renders the debug canvas
  114051. */
  114052. drawDebugCanvas(): void;
  114053. /**
  114054. * Stops rendering the debug canvas and removes it
  114055. */
  114056. stopDebugCanvas(): void;
  114057. /**
  114058. * Connects two audio nodes
  114059. * @param inputAudioNode defines first node to connect
  114060. * @param outputAudioNode defines second node to connect
  114061. */
  114062. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  114063. /**
  114064. * Releases all associated resources
  114065. */
  114066. dispose(): void;
  114067. }
  114068. }
  114069. declare module BABYLON {
  114070. /**
  114071. * This represents an audio engine and it is responsible
  114072. * to play, synchronize and analyse sounds throughout the application.
  114073. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114074. */
  114075. export interface IAudioEngine extends IDisposable {
  114076. /**
  114077. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  114078. */
  114079. readonly canUseWebAudio: boolean;
  114080. /**
  114081. * Gets the current AudioContext if available.
  114082. */
  114083. readonly audioContext: Nullable<AudioContext>;
  114084. /**
  114085. * The master gain node defines the global audio volume of your audio engine.
  114086. */
  114087. readonly masterGain: GainNode;
  114088. /**
  114089. * Gets whether or not mp3 are supported by your browser.
  114090. */
  114091. readonly isMP3supported: boolean;
  114092. /**
  114093. * Gets whether or not ogg are supported by your browser.
  114094. */
  114095. readonly isOGGsupported: boolean;
  114096. /**
  114097. * Defines if Babylon should emit a warning if WebAudio is not supported.
  114098. * @ignoreNaming
  114099. */
  114100. WarnedWebAudioUnsupported: boolean;
  114101. /**
  114102. * Defines if the audio engine relies on a custom unlocked button.
  114103. * In this case, the embedded button will not be displayed.
  114104. */
  114105. useCustomUnlockedButton: boolean;
  114106. /**
  114107. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  114108. */
  114109. readonly unlocked: boolean;
  114110. /**
  114111. * Event raised when audio has been unlocked on the browser.
  114112. */
  114113. onAudioUnlockedObservable: Observable<AudioEngine>;
  114114. /**
  114115. * Event raised when audio has been locked on the browser.
  114116. */
  114117. onAudioLockedObservable: Observable<AudioEngine>;
  114118. /**
  114119. * Flags the audio engine in Locked state.
  114120. * This happens due to new browser policies preventing audio to autoplay.
  114121. */
  114122. lock(): void;
  114123. /**
  114124. * Unlocks the audio engine once a user action has been done on the dom.
  114125. * This is helpful to resume play once browser policies have been satisfied.
  114126. */
  114127. unlock(): void;
  114128. /**
  114129. * Gets the global volume sets on the master gain.
  114130. * @returns the global volume if set or -1 otherwise
  114131. */
  114132. getGlobalVolume(): number;
  114133. /**
  114134. * Sets the global volume of your experience (sets on the master gain).
  114135. * @param newVolume Defines the new global volume of the application
  114136. */
  114137. setGlobalVolume(newVolume: number): void;
  114138. /**
  114139. * Connect the audio engine to an audio analyser allowing some amazing
  114140. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114141. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114142. * @param analyser The analyser to connect to the engine
  114143. */
  114144. connectToAnalyser(analyser: Analyser): void;
  114145. }
  114146. /**
  114147. * This represents the default audio engine used in babylon.
  114148. * It is responsible to play, synchronize and analyse sounds throughout the application.
  114149. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114150. */
  114151. export class AudioEngine implements IAudioEngine {
  114152. private _audioContext;
  114153. private _audioContextInitialized;
  114154. private _muteButton;
  114155. private _hostElement;
  114156. /**
  114157. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  114158. */
  114159. canUseWebAudio: boolean;
  114160. /**
  114161. * The master gain node defines the global audio volume of your audio engine.
  114162. */
  114163. masterGain: GainNode;
  114164. /**
  114165. * Defines if Babylon should emit a warning if WebAudio is not supported.
  114166. * @ignoreNaming
  114167. */
  114168. WarnedWebAudioUnsupported: boolean;
  114169. /**
  114170. * Gets whether or not mp3 are supported by your browser.
  114171. */
  114172. isMP3supported: boolean;
  114173. /**
  114174. * Gets whether or not ogg are supported by your browser.
  114175. */
  114176. isOGGsupported: boolean;
  114177. /**
  114178. * Gets whether audio has been unlocked on the device.
  114179. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  114180. * a user interaction has happened.
  114181. */
  114182. unlocked: boolean;
  114183. /**
  114184. * Defines if the audio engine relies on a custom unlocked button.
  114185. * In this case, the embedded button will not be displayed.
  114186. */
  114187. useCustomUnlockedButton: boolean;
  114188. /**
  114189. * Event raised when audio has been unlocked on the browser.
  114190. */
  114191. onAudioUnlockedObservable: Observable<AudioEngine>;
  114192. /**
  114193. * Event raised when audio has been locked on the browser.
  114194. */
  114195. onAudioLockedObservable: Observable<AudioEngine>;
  114196. /**
  114197. * Gets the current AudioContext if available.
  114198. */
  114199. get audioContext(): Nullable<AudioContext>;
  114200. private _connectedAnalyser;
  114201. /**
  114202. * Instantiates a new audio engine.
  114203. *
  114204. * There should be only one per page as some browsers restrict the number
  114205. * of audio contexts you can create.
  114206. * @param hostElement defines the host element where to display the mute icon if necessary
  114207. */
  114208. constructor(hostElement?: Nullable<HTMLElement>);
  114209. /**
  114210. * Flags the audio engine in Locked state.
  114211. * This happens due to new browser policies preventing audio to autoplay.
  114212. */
  114213. lock(): void;
  114214. /**
  114215. * Unlocks the audio engine once a user action has been done on the dom.
  114216. * This is helpful to resume play once browser policies have been satisfied.
  114217. */
  114218. unlock(): void;
  114219. private _resumeAudioContext;
  114220. private _initializeAudioContext;
  114221. private _tryToRun;
  114222. private _triggerRunningState;
  114223. private _triggerSuspendedState;
  114224. private _displayMuteButton;
  114225. private _moveButtonToTopLeft;
  114226. private _onResize;
  114227. private _hideMuteButton;
  114228. /**
  114229. * Destroy and release the resources associated with the audio ccontext.
  114230. */
  114231. dispose(): void;
  114232. /**
  114233. * Gets the global volume sets on the master gain.
  114234. * @returns the global volume if set or -1 otherwise
  114235. */
  114236. getGlobalVolume(): number;
  114237. /**
  114238. * Sets the global volume of your experience (sets on the master gain).
  114239. * @param newVolume Defines the new global volume of the application
  114240. */
  114241. setGlobalVolume(newVolume: number): void;
  114242. /**
  114243. * Connect the audio engine to an audio analyser allowing some amazing
  114244. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114245. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114246. * @param analyser The analyser to connect to the engine
  114247. */
  114248. connectToAnalyser(analyser: Analyser): void;
  114249. }
  114250. }
  114251. declare module BABYLON {
  114252. /**
  114253. * Interface used to present a loading screen while loading a scene
  114254. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114255. */
  114256. export interface ILoadingScreen {
  114257. /**
  114258. * Function called to display the loading screen
  114259. */
  114260. displayLoadingUI: () => void;
  114261. /**
  114262. * Function called to hide the loading screen
  114263. */
  114264. hideLoadingUI: () => void;
  114265. /**
  114266. * Gets or sets the color to use for the background
  114267. */
  114268. loadingUIBackgroundColor: string;
  114269. /**
  114270. * Gets or sets the text to display while loading
  114271. */
  114272. loadingUIText: string;
  114273. }
  114274. /**
  114275. * Class used for the default loading screen
  114276. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114277. */
  114278. export class DefaultLoadingScreen implements ILoadingScreen {
  114279. private _renderingCanvas;
  114280. private _loadingText;
  114281. private _loadingDivBackgroundColor;
  114282. private _loadingDiv;
  114283. private _loadingTextDiv;
  114284. /** Gets or sets the logo url to use for the default loading screen */
  114285. static DefaultLogoUrl: string;
  114286. /** Gets or sets the spinner url to use for the default loading screen */
  114287. static DefaultSpinnerUrl: string;
  114288. /**
  114289. * Creates a new default loading screen
  114290. * @param _renderingCanvas defines the canvas used to render the scene
  114291. * @param _loadingText defines the default text to display
  114292. * @param _loadingDivBackgroundColor defines the default background color
  114293. */
  114294. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  114295. /**
  114296. * Function called to display the loading screen
  114297. */
  114298. displayLoadingUI(): void;
  114299. /**
  114300. * Function called to hide the loading screen
  114301. */
  114302. hideLoadingUI(): void;
  114303. /**
  114304. * Gets or sets the text to display while loading
  114305. */
  114306. set loadingUIText(text: string);
  114307. get loadingUIText(): string;
  114308. /**
  114309. * Gets or sets the color to use for the background
  114310. */
  114311. get loadingUIBackgroundColor(): string;
  114312. set loadingUIBackgroundColor(color: string);
  114313. private _resizeLoadingUI;
  114314. }
  114315. }
  114316. declare module BABYLON {
  114317. /**
  114318. * Interface for any object that can request an animation frame
  114319. */
  114320. export interface ICustomAnimationFrameRequester {
  114321. /**
  114322. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  114323. */
  114324. renderFunction?: Function;
  114325. /**
  114326. * Called to request the next frame to render to
  114327. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  114328. */
  114329. requestAnimationFrame: Function;
  114330. /**
  114331. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  114332. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  114333. */
  114334. requestID?: number;
  114335. }
  114336. }
  114337. declare module BABYLON {
  114338. /**
  114339. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  114340. */
  114341. export class PerformanceMonitor {
  114342. private _enabled;
  114343. private _rollingFrameTime;
  114344. private _lastFrameTimeMs;
  114345. /**
  114346. * constructor
  114347. * @param frameSampleSize The number of samples required to saturate the sliding window
  114348. */
  114349. constructor(frameSampleSize?: number);
  114350. /**
  114351. * Samples current frame
  114352. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  114353. */
  114354. sampleFrame(timeMs?: number): void;
  114355. /**
  114356. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  114357. */
  114358. get averageFrameTime(): number;
  114359. /**
  114360. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  114361. */
  114362. get averageFrameTimeVariance(): number;
  114363. /**
  114364. * Returns the frame time of the most recent frame
  114365. */
  114366. get instantaneousFrameTime(): number;
  114367. /**
  114368. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  114369. */
  114370. get averageFPS(): number;
  114371. /**
  114372. * Returns the average framerate in frames per second using the most recent frame time
  114373. */
  114374. get instantaneousFPS(): number;
  114375. /**
  114376. * Returns true if enough samples have been taken to completely fill the sliding window
  114377. */
  114378. get isSaturated(): boolean;
  114379. /**
  114380. * Enables contributions to the sliding window sample set
  114381. */
  114382. enable(): void;
  114383. /**
  114384. * Disables contributions to the sliding window sample set
  114385. * Samples will not be interpolated over the disabled period
  114386. */
  114387. disable(): void;
  114388. /**
  114389. * Returns true if sampling is enabled
  114390. */
  114391. get isEnabled(): boolean;
  114392. /**
  114393. * Resets performance monitor
  114394. */
  114395. reset(): void;
  114396. }
  114397. /**
  114398. * RollingAverage
  114399. *
  114400. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  114401. */
  114402. export class RollingAverage {
  114403. /**
  114404. * Current average
  114405. */
  114406. average: number;
  114407. /**
  114408. * Current variance
  114409. */
  114410. variance: number;
  114411. protected _samples: Array<number>;
  114412. protected _sampleCount: number;
  114413. protected _pos: number;
  114414. protected _m2: number;
  114415. /**
  114416. * constructor
  114417. * @param length The number of samples required to saturate the sliding window
  114418. */
  114419. constructor(length: number);
  114420. /**
  114421. * Adds a sample to the sample set
  114422. * @param v The sample value
  114423. */
  114424. add(v: number): void;
  114425. /**
  114426. * Returns previously added values or null if outside of history or outside the sliding window domain
  114427. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  114428. * @return Value previously recorded with add() or null if outside of range
  114429. */
  114430. history(i: number): number;
  114431. /**
  114432. * Returns true if enough samples have been taken to completely fill the sliding window
  114433. * @return true if sample-set saturated
  114434. */
  114435. isSaturated(): boolean;
  114436. /**
  114437. * Resets the rolling average (equivalent to 0 samples taken so far)
  114438. */
  114439. reset(): void;
  114440. /**
  114441. * Wraps a value around the sample range boundaries
  114442. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  114443. * @return Wrapped position in sample range
  114444. */
  114445. protected _wrapPosition(i: number): number;
  114446. }
  114447. }
  114448. declare module BABYLON {
  114449. /**
  114450. * This class is used to track a performance counter which is number based.
  114451. * The user has access to many properties which give statistics of different nature.
  114452. *
  114453. * The implementer can track two kinds of Performance Counter: time and count.
  114454. * 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.
  114455. * 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.
  114456. */
  114457. export class PerfCounter {
  114458. /**
  114459. * Gets or sets a global boolean to turn on and off all the counters
  114460. */
  114461. static Enabled: boolean;
  114462. /**
  114463. * Returns the smallest value ever
  114464. */
  114465. get min(): number;
  114466. /**
  114467. * Returns the biggest value ever
  114468. */
  114469. get max(): number;
  114470. /**
  114471. * Returns the average value since the performance counter is running
  114472. */
  114473. get average(): number;
  114474. /**
  114475. * Returns the average value of the last second the counter was monitored
  114476. */
  114477. get lastSecAverage(): number;
  114478. /**
  114479. * Returns the current value
  114480. */
  114481. get current(): number;
  114482. /**
  114483. * Gets the accumulated total
  114484. */
  114485. get total(): number;
  114486. /**
  114487. * Gets the total value count
  114488. */
  114489. get count(): number;
  114490. /**
  114491. * Creates a new counter
  114492. */
  114493. constructor();
  114494. /**
  114495. * Call this method to start monitoring a new frame.
  114496. * 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.
  114497. */
  114498. fetchNewFrame(): void;
  114499. /**
  114500. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  114501. * @param newCount the count value to add to the monitored count
  114502. * @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.
  114503. */
  114504. addCount(newCount: number, fetchResult: boolean): void;
  114505. /**
  114506. * Start monitoring this performance counter
  114507. */
  114508. beginMonitoring(): void;
  114509. /**
  114510. * Compute the time lapsed since the previous beginMonitoring() call.
  114511. * @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
  114512. */
  114513. endMonitoring(newFrame?: boolean): void;
  114514. private _fetchResult;
  114515. private _startMonitoringTime;
  114516. private _min;
  114517. private _max;
  114518. private _average;
  114519. private _current;
  114520. private _totalValueCount;
  114521. private _totalAccumulated;
  114522. private _lastSecAverage;
  114523. private _lastSecAccumulated;
  114524. private _lastSecTime;
  114525. private _lastSecValueCount;
  114526. }
  114527. }
  114528. declare module BABYLON {
  114529. interface ThinEngine {
  114530. /**
  114531. * Sets alpha constants used by some alpha blending modes
  114532. * @param r defines the red component
  114533. * @param g defines the green component
  114534. * @param b defines the blue component
  114535. * @param a defines the alpha component
  114536. */
  114537. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114538. /**
  114539. * Sets the current alpha mode
  114540. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  114541. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114542. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114543. */
  114544. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114545. /**
  114546. * Gets the current alpha mode
  114547. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114548. * @returns the current alpha mode
  114549. */
  114550. getAlphaMode(): number;
  114551. /**
  114552. * Sets the current alpha equation
  114553. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  114554. */
  114555. setAlphaEquation(equation: number): void;
  114556. /**
  114557. * Gets the current alpha equation.
  114558. * @returns the current alpha equation
  114559. */
  114560. getAlphaEquation(): number;
  114561. }
  114562. }
  114563. declare module BABYLON {
  114564. interface ThinEngine {
  114565. /** @hidden */
  114566. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  114567. }
  114568. }
  114569. declare module BABYLON {
  114570. /**
  114571. * Defines the interface used by display changed events
  114572. */
  114573. export interface IDisplayChangedEventArgs {
  114574. /** Gets the vrDisplay object (if any) */
  114575. vrDisplay: Nullable<any>;
  114576. /** Gets a boolean indicating if webVR is supported */
  114577. vrSupported: boolean;
  114578. }
  114579. /**
  114580. * Defines the interface used by objects containing a viewport (like a camera)
  114581. */
  114582. interface IViewportOwnerLike {
  114583. /**
  114584. * Gets or sets the viewport
  114585. */
  114586. viewport: IViewportLike;
  114587. }
  114588. /**
  114589. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  114590. */
  114591. export class Engine extends ThinEngine {
  114592. /** Defines that alpha blending is disabled */
  114593. static readonly ALPHA_DISABLE: number;
  114594. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  114595. static readonly ALPHA_ADD: number;
  114596. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  114597. static readonly ALPHA_COMBINE: number;
  114598. /** Defines that alpha blending to DEST - SRC * DEST */
  114599. static readonly ALPHA_SUBTRACT: number;
  114600. /** Defines that alpha blending to SRC * DEST */
  114601. static readonly ALPHA_MULTIPLY: number;
  114602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  114603. static readonly ALPHA_MAXIMIZED: number;
  114604. /** Defines that alpha blending to SRC + DEST */
  114605. static readonly ALPHA_ONEONE: number;
  114606. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  114607. static readonly ALPHA_PREMULTIPLIED: number;
  114608. /**
  114609. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  114610. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  114611. */
  114612. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  114613. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  114614. static readonly ALPHA_INTERPOLATE: number;
  114615. /**
  114616. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  114617. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  114618. */
  114619. static readonly ALPHA_SCREENMODE: number;
  114620. /** Defines that the ressource is not delayed*/
  114621. static readonly DELAYLOADSTATE_NONE: number;
  114622. /** Defines that the ressource was successfully delay loaded */
  114623. static readonly DELAYLOADSTATE_LOADED: number;
  114624. /** Defines that the ressource is currently delay loading */
  114625. static readonly DELAYLOADSTATE_LOADING: number;
  114626. /** Defines that the ressource is delayed and has not started loading */
  114627. static readonly DELAYLOADSTATE_NOTLOADED: number;
  114628. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  114629. static readonly NEVER: number;
  114630. /** 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 */
  114631. static readonly ALWAYS: number;
  114632. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  114633. static readonly LESS: number;
  114634. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  114635. static readonly EQUAL: number;
  114636. /** 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 */
  114637. static readonly LEQUAL: number;
  114638. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  114639. static readonly GREATER: number;
  114640. /** 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 */
  114641. static readonly GEQUAL: number;
  114642. /** 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 */
  114643. static readonly NOTEQUAL: number;
  114644. /** Passed to stencilOperation to specify that stencil value must be kept */
  114645. static readonly KEEP: number;
  114646. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114647. static readonly REPLACE: number;
  114648. /** Passed to stencilOperation to specify that stencil value must be incremented */
  114649. static readonly INCR: number;
  114650. /** Passed to stencilOperation to specify that stencil value must be decremented */
  114651. static readonly DECR: number;
  114652. /** Passed to stencilOperation to specify that stencil value must be inverted */
  114653. static readonly INVERT: number;
  114654. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  114655. static readonly INCR_WRAP: number;
  114656. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  114657. static readonly DECR_WRAP: number;
  114658. /** Texture is not repeating outside of 0..1 UVs */
  114659. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  114660. /** Texture is repeating outside of 0..1 UVs */
  114661. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  114662. /** Texture is repeating and mirrored */
  114663. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  114664. /** ALPHA */
  114665. static readonly TEXTUREFORMAT_ALPHA: number;
  114666. /** LUMINANCE */
  114667. static readonly TEXTUREFORMAT_LUMINANCE: number;
  114668. /** LUMINANCE_ALPHA */
  114669. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  114670. /** RGB */
  114671. static readonly TEXTUREFORMAT_RGB: number;
  114672. /** RGBA */
  114673. static readonly TEXTUREFORMAT_RGBA: number;
  114674. /** RED */
  114675. static readonly TEXTUREFORMAT_RED: number;
  114676. /** RED (2nd reference) */
  114677. static readonly TEXTUREFORMAT_R: number;
  114678. /** RG */
  114679. static readonly TEXTUREFORMAT_RG: number;
  114680. /** RED_INTEGER */
  114681. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  114682. /** RED_INTEGER (2nd reference) */
  114683. static readonly TEXTUREFORMAT_R_INTEGER: number;
  114684. /** RG_INTEGER */
  114685. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  114686. /** RGB_INTEGER */
  114687. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  114688. /** RGBA_INTEGER */
  114689. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  114690. /** UNSIGNED_BYTE */
  114691. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  114692. /** UNSIGNED_BYTE (2nd reference) */
  114693. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  114694. /** FLOAT */
  114695. static readonly TEXTURETYPE_FLOAT: number;
  114696. /** HALF_FLOAT */
  114697. static readonly TEXTURETYPE_HALF_FLOAT: number;
  114698. /** BYTE */
  114699. static readonly TEXTURETYPE_BYTE: number;
  114700. /** SHORT */
  114701. static readonly TEXTURETYPE_SHORT: number;
  114702. /** UNSIGNED_SHORT */
  114703. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  114704. /** INT */
  114705. static readonly TEXTURETYPE_INT: number;
  114706. /** UNSIGNED_INT */
  114707. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  114708. /** UNSIGNED_SHORT_4_4_4_4 */
  114709. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  114710. /** UNSIGNED_SHORT_5_5_5_1 */
  114711. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  114712. /** UNSIGNED_SHORT_5_6_5 */
  114713. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  114714. /** UNSIGNED_INT_2_10_10_10_REV */
  114715. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  114716. /** UNSIGNED_INT_24_8 */
  114717. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  114718. /** UNSIGNED_INT_10F_11F_11F_REV */
  114719. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  114720. /** UNSIGNED_INT_5_9_9_9_REV */
  114721. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  114722. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  114723. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114724. /** nearest is mag = nearest and min = nearest and mip = linear */
  114725. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  114726. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114727. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  114728. /** Trilinear is mag = linear and min = linear and mip = linear */
  114729. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  114730. /** nearest is mag = nearest and min = nearest and mip = linear */
  114731. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  114732. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114733. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  114734. /** Trilinear is mag = linear and min = linear and mip = linear */
  114735. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  114736. /** mag = nearest and min = nearest and mip = nearest */
  114737. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  114738. /** mag = nearest and min = linear and mip = nearest */
  114739. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  114740. /** mag = nearest and min = linear and mip = linear */
  114741. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  114742. /** mag = nearest and min = linear and mip = none */
  114743. static readonly TEXTURE_NEAREST_LINEAR: number;
  114744. /** mag = nearest and min = nearest and mip = none */
  114745. static readonly TEXTURE_NEAREST_NEAREST: number;
  114746. /** mag = linear and min = nearest and mip = nearest */
  114747. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  114748. /** mag = linear and min = nearest and mip = linear */
  114749. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  114750. /** mag = linear and min = linear and mip = none */
  114751. static readonly TEXTURE_LINEAR_LINEAR: number;
  114752. /** mag = linear and min = nearest and mip = none */
  114753. static readonly TEXTURE_LINEAR_NEAREST: number;
  114754. /** Explicit coordinates mode */
  114755. static readonly TEXTURE_EXPLICIT_MODE: number;
  114756. /** Spherical coordinates mode */
  114757. static readonly TEXTURE_SPHERICAL_MODE: number;
  114758. /** Planar coordinates mode */
  114759. static readonly TEXTURE_PLANAR_MODE: number;
  114760. /** Cubic coordinates mode */
  114761. static readonly TEXTURE_CUBIC_MODE: number;
  114762. /** Projection coordinates mode */
  114763. static readonly TEXTURE_PROJECTION_MODE: number;
  114764. /** Skybox coordinates mode */
  114765. static readonly TEXTURE_SKYBOX_MODE: number;
  114766. /** Inverse Cubic coordinates mode */
  114767. static readonly TEXTURE_INVCUBIC_MODE: number;
  114768. /** Equirectangular coordinates mode */
  114769. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  114770. /** Equirectangular Fixed coordinates mode */
  114771. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  114772. /** Equirectangular Fixed Mirrored coordinates mode */
  114773. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  114774. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  114775. static readonly SCALEMODE_FLOOR: number;
  114776. /** Defines that texture rescaling will look for the nearest power of 2 size */
  114777. static readonly SCALEMODE_NEAREST: number;
  114778. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  114779. static readonly SCALEMODE_CEILING: number;
  114780. /**
  114781. * Returns the current npm package of the sdk
  114782. */
  114783. static get NpmPackage(): string;
  114784. /**
  114785. * Returns the current version of the framework
  114786. */
  114787. static get Version(): string;
  114788. /** Gets the list of created engines */
  114789. static get Instances(): Engine[];
  114790. /**
  114791. * Gets the latest created engine
  114792. */
  114793. static get LastCreatedEngine(): Nullable<Engine>;
  114794. /**
  114795. * Gets the latest created scene
  114796. */
  114797. static get LastCreatedScene(): Nullable<Scene>;
  114798. /**
  114799. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  114800. * @param flag defines which part of the materials must be marked as dirty
  114801. * @param predicate defines a predicate used to filter which materials should be affected
  114802. */
  114803. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  114804. /**
  114805. * Method called to create the default loading screen.
  114806. * This can be overriden in your own app.
  114807. * @param canvas The rendering canvas element
  114808. * @returns The loading screen
  114809. */
  114810. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  114811. /**
  114812. * Method called to create the default rescale post process on each engine.
  114813. */
  114814. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  114815. /**
  114816. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  114817. **/
  114818. enableOfflineSupport: boolean;
  114819. /**
  114820. * 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)
  114821. **/
  114822. disableManifestCheck: boolean;
  114823. /**
  114824. * Gets the list of created scenes
  114825. */
  114826. scenes: Scene[];
  114827. /**
  114828. * Event raised when a new scene is created
  114829. */
  114830. onNewSceneAddedObservable: Observable<Scene>;
  114831. /**
  114832. * Gets the list of created postprocesses
  114833. */
  114834. postProcesses: PostProcess[];
  114835. /**
  114836. * Gets a boolean indicating if the pointer is currently locked
  114837. */
  114838. isPointerLock: boolean;
  114839. /**
  114840. * Observable event triggered each time the rendering canvas is resized
  114841. */
  114842. onResizeObservable: Observable<Engine>;
  114843. /**
  114844. * Observable event triggered each time the canvas loses focus
  114845. */
  114846. onCanvasBlurObservable: Observable<Engine>;
  114847. /**
  114848. * Observable event triggered each time the canvas gains focus
  114849. */
  114850. onCanvasFocusObservable: Observable<Engine>;
  114851. /**
  114852. * Observable event triggered each time the canvas receives pointerout event
  114853. */
  114854. onCanvasPointerOutObservable: Observable<PointerEvent>;
  114855. /**
  114856. * Observable raised when the engine begins a new frame
  114857. */
  114858. onBeginFrameObservable: Observable<Engine>;
  114859. /**
  114860. * If set, will be used to request the next animation frame for the render loop
  114861. */
  114862. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  114863. /**
  114864. * Observable raised when the engine ends the current frame
  114865. */
  114866. onEndFrameObservable: Observable<Engine>;
  114867. /**
  114868. * Observable raised when the engine is about to compile a shader
  114869. */
  114870. onBeforeShaderCompilationObservable: Observable<Engine>;
  114871. /**
  114872. * Observable raised when the engine has jsut compiled a shader
  114873. */
  114874. onAfterShaderCompilationObservable: Observable<Engine>;
  114875. /**
  114876. * Gets the audio engine
  114877. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114878. * @ignorenaming
  114879. */
  114880. static audioEngine: IAudioEngine;
  114881. /**
  114882. * Default AudioEngine factory responsible of creating the Audio Engine.
  114883. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  114884. */
  114885. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  114886. /**
  114887. * Default offline support factory responsible of creating a tool used to store data locally.
  114888. * By default, this will create a Database object if the workload has been embedded.
  114889. */
  114890. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  114891. private _loadingScreen;
  114892. private _pointerLockRequested;
  114893. private _rescalePostProcess;
  114894. private _deterministicLockstep;
  114895. private _lockstepMaxSteps;
  114896. private _timeStep;
  114897. protected get _supportsHardwareTextureRescaling(): boolean;
  114898. private _fps;
  114899. private _deltaTime;
  114900. /** @hidden */
  114901. _drawCalls: PerfCounter;
  114902. /** 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 */
  114903. canvasTabIndex: number;
  114904. /**
  114905. * Turn this value on if you want to pause FPS computation when in background
  114906. */
  114907. disablePerformanceMonitorInBackground: boolean;
  114908. private _performanceMonitor;
  114909. /**
  114910. * Gets the performance monitor attached to this engine
  114911. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114912. */
  114913. get performanceMonitor(): PerformanceMonitor;
  114914. private _onFocus;
  114915. private _onBlur;
  114916. private _onCanvasPointerOut;
  114917. private _onCanvasBlur;
  114918. private _onCanvasFocus;
  114919. private _onFullscreenChange;
  114920. private _onPointerLockChange;
  114921. /**
  114922. * Gets the HTML element used to attach event listeners
  114923. * @returns a HTML element
  114924. */
  114925. getInputElement(): Nullable<HTMLElement>;
  114926. /**
  114927. * Creates a new engine
  114928. * @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
  114929. * @param antialias defines enable antialiasing (default: false)
  114930. * @param options defines further options to be sent to the getContext() function
  114931. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114932. */
  114933. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114934. /**
  114935. * Gets current aspect ratio
  114936. * @param viewportOwner defines the camera to use to get the aspect ratio
  114937. * @param useScreen defines if screen size must be used (or the current render target if any)
  114938. * @returns a number defining the aspect ratio
  114939. */
  114940. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  114941. /**
  114942. * Gets current screen aspect ratio
  114943. * @returns a number defining the aspect ratio
  114944. */
  114945. getScreenAspectRatio(): number;
  114946. /**
  114947. * Gets the client rect of the HTML canvas attached with the current webGL context
  114948. * @returns a client rectanglee
  114949. */
  114950. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  114951. /**
  114952. * Gets the client rect of the HTML element used for events
  114953. * @returns a client rectanglee
  114954. */
  114955. getInputElementClientRect(): Nullable<ClientRect>;
  114956. /**
  114957. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  114958. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114959. * @returns true if engine is in deterministic lock step mode
  114960. */
  114961. isDeterministicLockStep(): boolean;
  114962. /**
  114963. * Gets the max steps when engine is running in deterministic lock step
  114964. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114965. * @returns the max steps
  114966. */
  114967. getLockstepMaxSteps(): number;
  114968. /**
  114969. * Returns the time in ms between steps when using deterministic lock step.
  114970. * @returns time step in (ms)
  114971. */
  114972. getTimeStep(): number;
  114973. /**
  114974. * Force the mipmap generation for the given render target texture
  114975. * @param texture defines the render target texture to use
  114976. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  114977. */
  114978. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  114979. /** States */
  114980. /**
  114981. * Set various states to the webGL context
  114982. * @param culling defines backface culling state
  114983. * @param zOffset defines the value to apply to zOffset (0 by default)
  114984. * @param force defines if states must be applied even if cache is up to date
  114985. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  114986. */
  114987. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114988. /**
  114989. * Set the z offset to apply to current rendering
  114990. * @param value defines the offset to apply
  114991. */
  114992. setZOffset(value: number): void;
  114993. /**
  114994. * Gets the current value of the zOffset
  114995. * @returns the current zOffset state
  114996. */
  114997. getZOffset(): number;
  114998. /**
  114999. * Enable or disable depth buffering
  115000. * @param enable defines the state to set
  115001. */
  115002. setDepthBuffer(enable: boolean): void;
  115003. /**
  115004. * Gets a boolean indicating if depth writing is enabled
  115005. * @returns the current depth writing state
  115006. */
  115007. getDepthWrite(): boolean;
  115008. /**
  115009. * Enable or disable depth writing
  115010. * @param enable defines the state to set
  115011. */
  115012. setDepthWrite(enable: boolean): void;
  115013. /**
  115014. * Gets a boolean indicating if stencil buffer is enabled
  115015. * @returns the current stencil buffer state
  115016. */
  115017. getStencilBuffer(): boolean;
  115018. /**
  115019. * Enable or disable the stencil buffer
  115020. * @param enable defines if the stencil buffer must be enabled or disabled
  115021. */
  115022. setStencilBuffer(enable: boolean): void;
  115023. /**
  115024. * Gets the current stencil mask
  115025. * @returns a number defining the new stencil mask to use
  115026. */
  115027. getStencilMask(): number;
  115028. /**
  115029. * Sets the current stencil mask
  115030. * @param mask defines the new stencil mask to use
  115031. */
  115032. setStencilMask(mask: number): void;
  115033. /**
  115034. * Gets the current stencil function
  115035. * @returns a number defining the stencil function to use
  115036. */
  115037. getStencilFunction(): number;
  115038. /**
  115039. * Gets the current stencil reference value
  115040. * @returns a number defining the stencil reference value to use
  115041. */
  115042. getStencilFunctionReference(): number;
  115043. /**
  115044. * Gets the current stencil mask
  115045. * @returns a number defining the stencil mask to use
  115046. */
  115047. getStencilFunctionMask(): number;
  115048. /**
  115049. * Sets the current stencil function
  115050. * @param stencilFunc defines the new stencil function to use
  115051. */
  115052. setStencilFunction(stencilFunc: number): void;
  115053. /**
  115054. * Sets the current stencil reference
  115055. * @param reference defines the new stencil reference to use
  115056. */
  115057. setStencilFunctionReference(reference: number): void;
  115058. /**
  115059. * Sets the current stencil mask
  115060. * @param mask defines the new stencil mask to use
  115061. */
  115062. setStencilFunctionMask(mask: number): void;
  115063. /**
  115064. * Gets the current stencil operation when stencil fails
  115065. * @returns a number defining stencil operation to use when stencil fails
  115066. */
  115067. getStencilOperationFail(): number;
  115068. /**
  115069. * Gets the current stencil operation when depth fails
  115070. * @returns a number defining stencil operation to use when depth fails
  115071. */
  115072. getStencilOperationDepthFail(): number;
  115073. /**
  115074. * Gets the current stencil operation when stencil passes
  115075. * @returns a number defining stencil operation to use when stencil passes
  115076. */
  115077. getStencilOperationPass(): number;
  115078. /**
  115079. * Sets the stencil operation to use when stencil fails
  115080. * @param operation defines the stencil operation to use when stencil fails
  115081. */
  115082. setStencilOperationFail(operation: number): void;
  115083. /**
  115084. * Sets the stencil operation to use when depth fails
  115085. * @param operation defines the stencil operation to use when depth fails
  115086. */
  115087. setStencilOperationDepthFail(operation: number): void;
  115088. /**
  115089. * Sets the stencil operation to use when stencil passes
  115090. * @param operation defines the stencil operation to use when stencil passes
  115091. */
  115092. setStencilOperationPass(operation: number): void;
  115093. /**
  115094. * Sets a boolean indicating if the dithering state is enabled or disabled
  115095. * @param value defines the dithering state
  115096. */
  115097. setDitheringState(value: boolean): void;
  115098. /**
  115099. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  115100. * @param value defines the rasterizer state
  115101. */
  115102. setRasterizerState(value: boolean): void;
  115103. /**
  115104. * Gets the current depth function
  115105. * @returns a number defining the depth function
  115106. */
  115107. getDepthFunction(): Nullable<number>;
  115108. /**
  115109. * Sets the current depth function
  115110. * @param depthFunc defines the function to use
  115111. */
  115112. setDepthFunction(depthFunc: number): void;
  115113. /**
  115114. * Sets the current depth function to GREATER
  115115. */
  115116. setDepthFunctionToGreater(): void;
  115117. /**
  115118. * Sets the current depth function to GEQUAL
  115119. */
  115120. setDepthFunctionToGreaterOrEqual(): void;
  115121. /**
  115122. * Sets the current depth function to LESS
  115123. */
  115124. setDepthFunctionToLess(): void;
  115125. /**
  115126. * Sets the current depth function to LEQUAL
  115127. */
  115128. setDepthFunctionToLessOrEqual(): void;
  115129. private _cachedStencilBuffer;
  115130. private _cachedStencilFunction;
  115131. private _cachedStencilMask;
  115132. private _cachedStencilOperationPass;
  115133. private _cachedStencilOperationFail;
  115134. private _cachedStencilOperationDepthFail;
  115135. private _cachedStencilReference;
  115136. /**
  115137. * Caches the the state of the stencil buffer
  115138. */
  115139. cacheStencilState(): void;
  115140. /**
  115141. * Restores the state of the stencil buffer
  115142. */
  115143. restoreStencilState(): void;
  115144. /**
  115145. * Directly set the WebGL Viewport
  115146. * @param x defines the x coordinate of the viewport (in screen space)
  115147. * @param y defines the y coordinate of the viewport (in screen space)
  115148. * @param width defines the width of the viewport (in screen space)
  115149. * @param height defines the height of the viewport (in screen space)
  115150. * @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
  115151. */
  115152. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  115153. /**
  115154. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  115155. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  115156. * @param y defines the y-coordinate of the corner of the clear rectangle
  115157. * @param width defines the width of the clear rectangle
  115158. * @param height defines the height of the clear rectangle
  115159. * @param clearColor defines the clear color
  115160. */
  115161. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  115162. /**
  115163. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  115164. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  115165. * @param y defines the y-coordinate of the corner of the clear rectangle
  115166. * @param width defines the width of the clear rectangle
  115167. * @param height defines the height of the clear rectangle
  115168. */
  115169. enableScissor(x: number, y: number, width: number, height: number): void;
  115170. /**
  115171. * Disable previously set scissor test rectangle
  115172. */
  115173. disableScissor(): void;
  115174. protected _reportDrawCall(): void;
  115175. /**
  115176. * Initializes a webVR display and starts listening to display change events
  115177. * The onVRDisplayChangedObservable will be notified upon these changes
  115178. * @returns The onVRDisplayChangedObservable
  115179. */
  115180. initWebVR(): Observable<IDisplayChangedEventArgs>;
  115181. /** @hidden */
  115182. _prepareVRComponent(): void;
  115183. /** @hidden */
  115184. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  115185. /** @hidden */
  115186. _submitVRFrame(): void;
  115187. /**
  115188. * Call this function to leave webVR mode
  115189. * Will do nothing if webVR is not supported or if there is no webVR device
  115190. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115191. */
  115192. disableVR(): void;
  115193. /**
  115194. * Gets a boolean indicating that the system is in VR mode and is presenting
  115195. * @returns true if VR mode is engaged
  115196. */
  115197. isVRPresenting(): boolean;
  115198. /** @hidden */
  115199. _requestVRFrame(): void;
  115200. /** @hidden */
  115201. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  115202. /**
  115203. * Gets the source code of the vertex shader associated with a specific webGL program
  115204. * @param program defines the program to use
  115205. * @returns a string containing the source code of the vertex shader associated with the program
  115206. */
  115207. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  115208. /**
  115209. * Gets the source code of the fragment shader associated with a specific webGL program
  115210. * @param program defines the program to use
  115211. * @returns a string containing the source code of the fragment shader associated with the program
  115212. */
  115213. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  115214. /**
  115215. * Sets a depth stencil texture from a render target to the according uniform.
  115216. * @param channel The texture channel
  115217. * @param uniform The uniform to set
  115218. * @param texture The render target texture containing the depth stencil texture to apply
  115219. */
  115220. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  115221. /**
  115222. * Sets a texture to the webGL context from a postprocess
  115223. * @param channel defines the channel to use
  115224. * @param postProcess defines the source postprocess
  115225. */
  115226. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  115227. /**
  115228. * Binds the output of the passed in post process to the texture channel specified
  115229. * @param channel The channel the texture should be bound to
  115230. * @param postProcess The post process which's output should be bound
  115231. */
  115232. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  115233. protected _rebuildBuffers(): void;
  115234. /** @hidden */
  115235. _renderFrame(): void;
  115236. _renderLoop(): void;
  115237. /** @hidden */
  115238. _renderViews(): boolean;
  115239. /**
  115240. * Toggle full screen mode
  115241. * @param requestPointerLock defines if a pointer lock should be requested from the user
  115242. */
  115243. switchFullscreen(requestPointerLock: boolean): void;
  115244. /**
  115245. * Enters full screen mode
  115246. * @param requestPointerLock defines if a pointer lock should be requested from the user
  115247. */
  115248. enterFullscreen(requestPointerLock: boolean): void;
  115249. /**
  115250. * Exits full screen mode
  115251. */
  115252. exitFullscreen(): void;
  115253. /**
  115254. * Enters Pointerlock mode
  115255. */
  115256. enterPointerlock(): void;
  115257. /**
  115258. * Exits Pointerlock mode
  115259. */
  115260. exitPointerlock(): void;
  115261. /**
  115262. * Begin a new frame
  115263. */
  115264. beginFrame(): void;
  115265. /**
  115266. * Enf the current frame
  115267. */
  115268. endFrame(): void;
  115269. resize(): void;
  115270. /**
  115271. * Force a specific size of the canvas
  115272. * @param width defines the new canvas' width
  115273. * @param height defines the new canvas' height
  115274. * @returns true if the size was changed
  115275. */
  115276. setSize(width: number, height: number): boolean;
  115277. /**
  115278. * Updates a dynamic vertex buffer.
  115279. * @param vertexBuffer the vertex buffer to update
  115280. * @param data the data used to update the vertex buffer
  115281. * @param byteOffset the byte offset of the data
  115282. * @param byteLength the byte length of the data
  115283. */
  115284. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  115285. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115286. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115287. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115288. _releaseTexture(texture: InternalTexture): void;
  115289. /**
  115290. * @hidden
  115291. * Rescales a texture
  115292. * @param source input texutre
  115293. * @param destination destination texture
  115294. * @param scene scene to use to render the resize
  115295. * @param internalFormat format to use when resizing
  115296. * @param onComplete callback to be called when resize has completed
  115297. */
  115298. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  115299. /**
  115300. * Gets the current framerate
  115301. * @returns a number representing the framerate
  115302. */
  115303. getFps(): number;
  115304. /**
  115305. * Gets the time spent between current and previous frame
  115306. * @returns a number representing the delta time in ms
  115307. */
  115308. getDeltaTime(): number;
  115309. private _measureFps;
  115310. /** @hidden */
  115311. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  115312. /**
  115313. * Update a dynamic index buffer
  115314. * @param indexBuffer defines the target index buffer
  115315. * @param indices defines the data to update
  115316. * @param offset defines the offset in the target index buffer where update should start
  115317. */
  115318. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  115319. /**
  115320. * Updates the sample count of a render target texture
  115321. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  115322. * @param texture defines the texture to update
  115323. * @param samples defines the sample count to set
  115324. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  115325. */
  115326. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  115327. /**
  115328. * Updates a depth texture Comparison Mode and Function.
  115329. * If the comparison Function is equal to 0, the mode will be set to none.
  115330. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  115331. * @param texture The texture to set the comparison function for
  115332. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  115333. */
  115334. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  115335. /**
  115336. * Creates a webGL buffer to use with instanciation
  115337. * @param capacity defines the size of the buffer
  115338. * @returns the webGL buffer
  115339. */
  115340. createInstancesBuffer(capacity: number): DataBuffer;
  115341. /**
  115342. * Delete a webGL buffer used with instanciation
  115343. * @param buffer defines the webGL buffer to delete
  115344. */
  115345. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  115346. private _clientWaitAsync;
  115347. /** @hidden */
  115348. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  115349. dispose(): void;
  115350. private _disableTouchAction;
  115351. /**
  115352. * Display the loading screen
  115353. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115354. */
  115355. displayLoadingUI(): void;
  115356. /**
  115357. * Hide the loading screen
  115358. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115359. */
  115360. hideLoadingUI(): void;
  115361. /**
  115362. * Gets the current loading screen object
  115363. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115364. */
  115365. get loadingScreen(): ILoadingScreen;
  115366. /**
  115367. * Sets the current loading screen object
  115368. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115369. */
  115370. set loadingScreen(loadingScreen: ILoadingScreen);
  115371. /**
  115372. * Sets the current loading screen text
  115373. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115374. */
  115375. set loadingUIText(text: string);
  115376. /**
  115377. * Sets the current loading screen background color
  115378. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115379. */
  115380. set loadingUIBackgroundColor(color: string);
  115381. /** Pointerlock and fullscreen */
  115382. /**
  115383. * Ask the browser to promote the current element to pointerlock mode
  115384. * @param element defines the DOM element to promote
  115385. */
  115386. static _RequestPointerlock(element: HTMLElement): void;
  115387. /**
  115388. * Asks the browser to exit pointerlock mode
  115389. */
  115390. static _ExitPointerlock(): void;
  115391. /**
  115392. * Ask the browser to promote the current element to fullscreen rendering mode
  115393. * @param element defines the DOM element to promote
  115394. */
  115395. static _RequestFullscreen(element: HTMLElement): void;
  115396. /**
  115397. * Asks the browser to exit fullscreen mode
  115398. */
  115399. static _ExitFullscreen(): void;
  115400. }
  115401. }
  115402. declare module BABYLON {
  115403. /**
  115404. * The engine store class is responsible to hold all the instances of Engine and Scene created
  115405. * during the life time of the application.
  115406. */
  115407. export class EngineStore {
  115408. /** Gets the list of created engines */
  115409. static Instances: Engine[];
  115410. /** @hidden */
  115411. static _LastCreatedScene: Nullable<Scene>;
  115412. /**
  115413. * Gets the latest created engine
  115414. */
  115415. static get LastCreatedEngine(): Nullable<Engine>;
  115416. /**
  115417. * Gets the latest created scene
  115418. */
  115419. static get LastCreatedScene(): Nullable<Scene>;
  115420. /**
  115421. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115422. * @ignorenaming
  115423. */
  115424. static UseFallbackTexture: boolean;
  115425. /**
  115426. * Texture content used if a texture cannot loaded
  115427. * @ignorenaming
  115428. */
  115429. static FallbackTexture: string;
  115430. }
  115431. }
  115432. declare module BABYLON {
  115433. /**
  115434. * Helper class that provides a small promise polyfill
  115435. */
  115436. export class PromisePolyfill {
  115437. /**
  115438. * Static function used to check if the polyfill is required
  115439. * If this is the case then the function will inject the polyfill to window.Promise
  115440. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  115441. */
  115442. static Apply(force?: boolean): void;
  115443. }
  115444. }
  115445. declare module BABYLON {
  115446. /**
  115447. * Interface for screenshot methods with describe argument called `size` as object with options
  115448. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  115449. */
  115450. export interface IScreenshotSize {
  115451. /**
  115452. * number in pixels for canvas height
  115453. */
  115454. height?: number;
  115455. /**
  115456. * multiplier allowing render at a higher or lower resolution
  115457. * If value is defined then height and width will be ignored and taken from camera
  115458. */
  115459. precision?: number;
  115460. /**
  115461. * number in pixels for canvas width
  115462. */
  115463. width?: number;
  115464. }
  115465. }
  115466. declare module BABYLON {
  115467. interface IColor4Like {
  115468. r: float;
  115469. g: float;
  115470. b: float;
  115471. a: float;
  115472. }
  115473. /**
  115474. * Class containing a set of static utilities functions
  115475. */
  115476. export class Tools {
  115477. /**
  115478. * Gets or sets the base URL to use to load assets
  115479. */
  115480. static get BaseUrl(): string;
  115481. static set BaseUrl(value: string);
  115482. /**
  115483. * Enable/Disable Custom HTTP Request Headers globally.
  115484. * default = false
  115485. * @see CustomRequestHeaders
  115486. */
  115487. static UseCustomRequestHeaders: boolean;
  115488. /**
  115489. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  115490. * i.e. when loading files, where the server/service expects an Authorization header
  115491. */
  115492. static CustomRequestHeaders: {
  115493. [key: string]: string;
  115494. };
  115495. /**
  115496. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  115497. */
  115498. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  115499. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  115500. /**
  115501. * Default behaviour for cors in the application.
  115502. * It can be a string if the expected behavior is identical in the entire app.
  115503. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  115504. */
  115505. static get CorsBehavior(): string | ((url: string | string[]) => string);
  115506. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  115507. /**
  115508. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115509. * @ignorenaming
  115510. */
  115511. static get UseFallbackTexture(): boolean;
  115512. static set UseFallbackTexture(value: boolean);
  115513. /**
  115514. * Use this object to register external classes like custom textures or material
  115515. * to allow the laoders to instantiate them
  115516. */
  115517. static get RegisteredExternalClasses(): {
  115518. [key: string]: Object;
  115519. };
  115520. static set RegisteredExternalClasses(classes: {
  115521. [key: string]: Object;
  115522. });
  115523. /**
  115524. * Texture content used if a texture cannot loaded
  115525. * @ignorenaming
  115526. */
  115527. static get fallbackTexture(): string;
  115528. static set fallbackTexture(value: string);
  115529. /**
  115530. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  115531. * @param u defines the coordinate on X axis
  115532. * @param v defines the coordinate on Y axis
  115533. * @param width defines the width of the source data
  115534. * @param height defines the height of the source data
  115535. * @param pixels defines the source byte array
  115536. * @param color defines the output color
  115537. */
  115538. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  115539. /**
  115540. * Interpolates between a and b via alpha
  115541. * @param a The lower value (returned when alpha = 0)
  115542. * @param b The upper value (returned when alpha = 1)
  115543. * @param alpha The interpolation-factor
  115544. * @return The mixed value
  115545. */
  115546. static Mix(a: number, b: number, alpha: number): number;
  115547. /**
  115548. * Tries to instantiate a new object from a given class name
  115549. * @param className defines the class name to instantiate
  115550. * @returns the new object or null if the system was not able to do the instantiation
  115551. */
  115552. static Instantiate(className: string): any;
  115553. /**
  115554. * Provides a slice function that will work even on IE
  115555. * @param data defines the array to slice
  115556. * @param start defines the start of the data (optional)
  115557. * @param end defines the end of the data (optional)
  115558. * @returns the new sliced array
  115559. */
  115560. static Slice<T>(data: T, start?: number, end?: number): T;
  115561. /**
  115562. * Polyfill for setImmediate
  115563. * @param action defines the action to execute after the current execution block
  115564. */
  115565. static SetImmediate(action: () => void): void;
  115566. /**
  115567. * Function indicating if a number is an exponent of 2
  115568. * @param value defines the value to test
  115569. * @returns true if the value is an exponent of 2
  115570. */
  115571. static IsExponentOfTwo(value: number): boolean;
  115572. private static _tmpFloatArray;
  115573. /**
  115574. * Returns the nearest 32-bit single precision float representation of a Number
  115575. * @param value A Number. If the parameter is of a different type, it will get converted
  115576. * to a number or to NaN if it cannot be converted
  115577. * @returns number
  115578. */
  115579. static FloatRound(value: number): number;
  115580. /**
  115581. * Extracts the filename from a path
  115582. * @param path defines the path to use
  115583. * @returns the filename
  115584. */
  115585. static GetFilename(path: string): string;
  115586. /**
  115587. * Extracts the "folder" part of a path (everything before the filename).
  115588. * @param uri The URI to extract the info from
  115589. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  115590. * @returns The "folder" part of the path
  115591. */
  115592. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  115593. /**
  115594. * Extracts text content from a DOM element hierarchy
  115595. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  115596. */
  115597. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  115598. /**
  115599. * Convert an angle in radians to degrees
  115600. * @param angle defines the angle to convert
  115601. * @returns the angle in degrees
  115602. */
  115603. static ToDegrees(angle: number): number;
  115604. /**
  115605. * Convert an angle in degrees to radians
  115606. * @param angle defines the angle to convert
  115607. * @returns the angle in radians
  115608. */
  115609. static ToRadians(angle: number): number;
  115610. /**
  115611. * Returns an array if obj is not an array
  115612. * @param obj defines the object to evaluate as an array
  115613. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  115614. * @returns either obj directly if obj is an array or a new array containing obj
  115615. */
  115616. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  115617. /**
  115618. * Gets the pointer prefix to use
  115619. * @param engine defines the engine we are finding the prefix for
  115620. * @returns "pointer" if touch is enabled. Else returns "mouse"
  115621. */
  115622. static GetPointerPrefix(engine: Engine): string;
  115623. /**
  115624. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  115625. * @param url define the url we are trying
  115626. * @param element define the dom element where to configure the cors policy
  115627. */
  115628. static SetCorsBehavior(url: string | string[], element: {
  115629. crossOrigin: string | null;
  115630. }): void;
  115631. /**
  115632. * Removes unwanted characters from an url
  115633. * @param url defines the url to clean
  115634. * @returns the cleaned url
  115635. */
  115636. static CleanUrl(url: string): string;
  115637. /**
  115638. * Gets or sets a function used to pre-process url before using them to load assets
  115639. */
  115640. static get PreprocessUrl(): (url: string) => string;
  115641. static set PreprocessUrl(processor: (url: string) => string);
  115642. /**
  115643. * Loads an image as an HTMLImageElement.
  115644. * @param input url string, ArrayBuffer, or Blob to load
  115645. * @param onLoad callback called when the image successfully loads
  115646. * @param onError callback called when the image fails to load
  115647. * @param offlineProvider offline provider for caching
  115648. * @param mimeType optional mime type
  115649. * @returns the HTMLImageElement of the loaded image
  115650. */
  115651. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  115652. /**
  115653. * Loads a file from a url
  115654. * @param url url string, ArrayBuffer, or Blob to load
  115655. * @param onSuccess callback called when the file successfully loads
  115656. * @param onProgress callback called while file is loading (if the server supports this mode)
  115657. * @param offlineProvider defines the offline provider for caching
  115658. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115659. * @param onError callback called when the file fails to load
  115660. * @returns a file request object
  115661. */
  115662. 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;
  115663. /**
  115664. * Loads a file from a url
  115665. * @param url the file url to load
  115666. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115667. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  115668. */
  115669. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  115670. /**
  115671. * Load a script (identified by an url). When the url returns, the
  115672. * content of this file is added into a new script element, attached to the DOM (body element)
  115673. * @param scriptUrl defines the url of the script to laod
  115674. * @param onSuccess defines the callback called when the script is loaded
  115675. * @param onError defines the callback to call if an error occurs
  115676. * @param scriptId defines the id of the script element
  115677. */
  115678. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  115679. /**
  115680. * Load an asynchronous script (identified by an url). When the url returns, the
  115681. * content of this file is added into a new script element, attached to the DOM (body element)
  115682. * @param scriptUrl defines the url of the script to laod
  115683. * @param scriptId defines the id of the script element
  115684. * @returns a promise request object
  115685. */
  115686. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  115687. /**
  115688. * Loads a file from a blob
  115689. * @param fileToLoad defines the blob to use
  115690. * @param callback defines the callback to call when data is loaded
  115691. * @param progressCallback defines the callback to call during loading process
  115692. * @returns a file request object
  115693. */
  115694. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  115695. /**
  115696. * Reads a file from a File object
  115697. * @param file defines the file to load
  115698. * @param onSuccess defines the callback to call when data is loaded
  115699. * @param onProgress defines the callback to call during loading process
  115700. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115701. * @param onError defines the callback to call when an error occurs
  115702. * @returns a file request object
  115703. */
  115704. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  115705. /**
  115706. * Creates a data url from a given string content
  115707. * @param content defines the content to convert
  115708. * @returns the new data url link
  115709. */
  115710. static FileAsURL(content: string): string;
  115711. /**
  115712. * Format the given number to a specific decimal format
  115713. * @param value defines the number to format
  115714. * @param decimals defines the number of decimals to use
  115715. * @returns the formatted string
  115716. */
  115717. static Format(value: number, decimals?: number): string;
  115718. /**
  115719. * Tries to copy an object by duplicating every property
  115720. * @param source defines the source object
  115721. * @param destination defines the target object
  115722. * @param doNotCopyList defines a list of properties to avoid
  115723. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  115724. */
  115725. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  115726. /**
  115727. * Gets a boolean indicating if the given object has no own property
  115728. * @param obj defines the object to test
  115729. * @returns true if object has no own property
  115730. */
  115731. static IsEmpty(obj: any): boolean;
  115732. /**
  115733. * Function used to register events at window level
  115734. * @param windowElement defines the Window object to use
  115735. * @param events defines the events to register
  115736. */
  115737. static RegisterTopRootEvents(windowElement: Window, events: {
  115738. name: string;
  115739. handler: Nullable<(e: FocusEvent) => any>;
  115740. }[]): void;
  115741. /**
  115742. * Function used to unregister events from window level
  115743. * @param windowElement defines the Window object to use
  115744. * @param events defines the events to unregister
  115745. */
  115746. static UnregisterTopRootEvents(windowElement: Window, events: {
  115747. name: string;
  115748. handler: Nullable<(e: FocusEvent) => any>;
  115749. }[]): void;
  115750. /**
  115751. * @ignore
  115752. */
  115753. static _ScreenshotCanvas: HTMLCanvasElement;
  115754. /**
  115755. * Dumps the current bound framebuffer
  115756. * @param width defines the rendering width
  115757. * @param height defines the rendering height
  115758. * @param engine defines the hosting engine
  115759. * @param successCallback defines the callback triggered once the data are available
  115760. * @param mimeType defines the mime type of the result
  115761. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  115762. */
  115763. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115764. /**
  115765. * Converts the canvas data to blob.
  115766. * This acts as a polyfill for browsers not supporting the to blob function.
  115767. * @param canvas Defines the canvas to extract the data from
  115768. * @param successCallback Defines the callback triggered once the data are available
  115769. * @param mimeType Defines the mime type of the result
  115770. */
  115771. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  115772. /**
  115773. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  115774. * @param successCallback defines the callback triggered once the data are available
  115775. * @param mimeType defines the mime type of the result
  115776. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  115777. */
  115778. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115779. /**
  115780. * Downloads a blob in the browser
  115781. * @param blob defines the blob to download
  115782. * @param fileName defines the name of the downloaded file
  115783. */
  115784. static Download(blob: Blob, fileName: string): void;
  115785. /**
  115786. * Captures a screenshot of the current rendering
  115787. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115788. * @param engine defines the rendering engine
  115789. * @param camera defines the source camera
  115790. * @param size This parameter can be set to a single number or to an object with the
  115791. * following (optional) properties: precision, width, height. If a single number is passed,
  115792. * it will be used for both width and height. If an object is passed, the screenshot size
  115793. * will be derived from the parameters. The precision property is a multiplier allowing
  115794. * rendering at a higher or lower resolution
  115795. * @param successCallback defines the callback receives a single parameter which contains the
  115796. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115797. * src parameter of an <img> to display it
  115798. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115799. * Check your browser for supported MIME types
  115800. */
  115801. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  115802. /**
  115803. * Captures a screenshot of the current rendering
  115804. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115805. * @param engine defines the rendering engine
  115806. * @param camera defines the source camera
  115807. * @param size This parameter can be set to a single number or to an object with the
  115808. * following (optional) properties: precision, width, height. If a single number is passed,
  115809. * it will be used for both width and height. If an object is passed, the screenshot size
  115810. * will be derived from the parameters. The precision property is a multiplier allowing
  115811. * rendering at a higher or lower resolution
  115812. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115813. * Check your browser for supported MIME types
  115814. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115815. * to the src parameter of an <img> to display it
  115816. */
  115817. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  115818. /**
  115819. * Generates an image screenshot from the specified camera.
  115820. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115821. * @param engine The engine to use for rendering
  115822. * @param camera The camera to use for rendering
  115823. * @param size This parameter can be set to a single number or to an object with the
  115824. * following (optional) properties: precision, width, height. If a single number is passed,
  115825. * it will be used for both width and height. If an object is passed, the screenshot size
  115826. * will be derived from the parameters. The precision property is a multiplier allowing
  115827. * rendering at a higher or lower resolution
  115828. * @param successCallback The callback receives a single parameter which contains the
  115829. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115830. * src parameter of an <img> to display it
  115831. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115832. * Check your browser for supported MIME types
  115833. * @param samples Texture samples (default: 1)
  115834. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115835. * @param fileName A name for for the downloaded file.
  115836. */
  115837. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115838. /**
  115839. * Generates an image screenshot from the specified camera.
  115840. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115841. * @param engine The engine to use for rendering
  115842. * @param camera The camera to use for rendering
  115843. * @param size This parameter can be set to a single number or to an object with the
  115844. * following (optional) properties: precision, width, height. If a single number is passed,
  115845. * it will be used for both width and height. If an object is passed, the screenshot size
  115846. * will be derived from the parameters. The precision property is a multiplier allowing
  115847. * rendering at a higher or lower resolution
  115848. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115849. * Check your browser for supported MIME types
  115850. * @param samples Texture samples (default: 1)
  115851. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115852. * @param fileName A name for for the downloaded file.
  115853. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115854. * to the src parameter of an <img> to display it
  115855. */
  115856. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  115857. /**
  115858. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  115859. * Be aware Math.random() could cause collisions, but:
  115860. * "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"
  115861. * @returns a pseudo random id
  115862. */
  115863. static RandomId(): string;
  115864. /**
  115865. * Test if the given uri is a base64 string
  115866. * @param uri The uri to test
  115867. * @return True if the uri is a base64 string or false otherwise
  115868. */
  115869. static IsBase64(uri: string): boolean;
  115870. /**
  115871. * Decode the given base64 uri.
  115872. * @param uri The uri to decode
  115873. * @return The decoded base64 data.
  115874. */
  115875. static DecodeBase64(uri: string): ArrayBuffer;
  115876. /**
  115877. * Gets the absolute url.
  115878. * @param url the input url
  115879. * @return the absolute url
  115880. */
  115881. static GetAbsoluteUrl(url: string): string;
  115882. /**
  115883. * No log
  115884. */
  115885. static readonly NoneLogLevel: number;
  115886. /**
  115887. * Only message logs
  115888. */
  115889. static readonly MessageLogLevel: number;
  115890. /**
  115891. * Only warning logs
  115892. */
  115893. static readonly WarningLogLevel: number;
  115894. /**
  115895. * Only error logs
  115896. */
  115897. static readonly ErrorLogLevel: number;
  115898. /**
  115899. * All logs
  115900. */
  115901. static readonly AllLogLevel: number;
  115902. /**
  115903. * Gets a value indicating the number of loading errors
  115904. * @ignorenaming
  115905. */
  115906. static get errorsCount(): number;
  115907. /**
  115908. * Callback called when a new log is added
  115909. */
  115910. static OnNewCacheEntry: (entry: string) => void;
  115911. /**
  115912. * Log a message to the console
  115913. * @param message defines the message to log
  115914. */
  115915. static Log(message: string): void;
  115916. /**
  115917. * Write a warning message to the console
  115918. * @param message defines the message to log
  115919. */
  115920. static Warn(message: string): void;
  115921. /**
  115922. * Write an error message to the console
  115923. * @param message defines the message to log
  115924. */
  115925. static Error(message: string): void;
  115926. /**
  115927. * Gets current log cache (list of logs)
  115928. */
  115929. static get LogCache(): string;
  115930. /**
  115931. * Clears the log cache
  115932. */
  115933. static ClearLogCache(): void;
  115934. /**
  115935. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  115936. */
  115937. static set LogLevels(level: number);
  115938. /**
  115939. * Checks if the window object exists
  115940. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  115941. */
  115942. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  115943. /**
  115944. * No performance log
  115945. */
  115946. static readonly PerformanceNoneLogLevel: number;
  115947. /**
  115948. * Use user marks to log performance
  115949. */
  115950. static readonly PerformanceUserMarkLogLevel: number;
  115951. /**
  115952. * Log performance to the console
  115953. */
  115954. static readonly PerformanceConsoleLogLevel: number;
  115955. private static _performance;
  115956. /**
  115957. * Sets the current performance log level
  115958. */
  115959. static set PerformanceLogLevel(level: number);
  115960. private static _StartPerformanceCounterDisabled;
  115961. private static _EndPerformanceCounterDisabled;
  115962. private static _StartUserMark;
  115963. private static _EndUserMark;
  115964. private static _StartPerformanceConsole;
  115965. private static _EndPerformanceConsole;
  115966. /**
  115967. * Starts a performance counter
  115968. */
  115969. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115970. /**
  115971. * Ends a specific performance coutner
  115972. */
  115973. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115974. /**
  115975. * Gets either window.performance.now() if supported or Date.now() else
  115976. */
  115977. static get Now(): number;
  115978. /**
  115979. * This method will return the name of the class used to create the instance of the given object.
  115980. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  115981. * @param object the object to get the class name from
  115982. * @param isType defines if the object is actually a type
  115983. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  115984. */
  115985. static GetClassName(object: any, isType?: boolean): string;
  115986. /**
  115987. * Gets the first element of an array satisfying a given predicate
  115988. * @param array defines the array to browse
  115989. * @param predicate defines the predicate to use
  115990. * @returns null if not found or the element
  115991. */
  115992. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  115993. /**
  115994. * This method will return the name of the full name of the class, including its owning module (if any).
  115995. * 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).
  115996. * @param object the object to get the class name from
  115997. * @param isType defines if the object is actually a type
  115998. * @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.
  115999. * @ignorenaming
  116000. */
  116001. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  116002. /**
  116003. * Returns a promise that resolves after the given amount of time.
  116004. * @param delay Number of milliseconds to delay
  116005. * @returns Promise that resolves after the given amount of time
  116006. */
  116007. static DelayAsync(delay: number): Promise<void>;
  116008. /**
  116009. * Utility function to detect if the current user agent is Safari
  116010. * @returns whether or not the current user agent is safari
  116011. */
  116012. static IsSafari(): boolean;
  116013. }
  116014. /**
  116015. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  116016. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  116017. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  116018. * @param name The name of the class, case should be preserved
  116019. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  116020. */
  116021. export function className(name: string, module?: string): (target: Object) => void;
  116022. /**
  116023. * An implementation of a loop for asynchronous functions.
  116024. */
  116025. export class AsyncLoop {
  116026. /**
  116027. * Defines the number of iterations for the loop
  116028. */
  116029. iterations: number;
  116030. /**
  116031. * Defines the current index of the loop.
  116032. */
  116033. index: number;
  116034. private _done;
  116035. private _fn;
  116036. private _successCallback;
  116037. /**
  116038. * Constructor.
  116039. * @param iterations the number of iterations.
  116040. * @param func the function to run each iteration
  116041. * @param successCallback the callback that will be called upon succesful execution
  116042. * @param offset starting offset.
  116043. */
  116044. constructor(
  116045. /**
  116046. * Defines the number of iterations for the loop
  116047. */
  116048. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  116049. /**
  116050. * Execute the next iteration. Must be called after the last iteration was finished.
  116051. */
  116052. executeNext(): void;
  116053. /**
  116054. * Break the loop and run the success callback.
  116055. */
  116056. breakLoop(): void;
  116057. /**
  116058. * Create and run an async loop.
  116059. * @param iterations the number of iterations.
  116060. * @param fn the function to run each iteration
  116061. * @param successCallback the callback that will be called upon succesful execution
  116062. * @param offset starting offset.
  116063. * @returns the created async loop object
  116064. */
  116065. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  116066. /**
  116067. * A for-loop that will run a given number of iterations synchronous and the rest async.
  116068. * @param iterations total number of iterations
  116069. * @param syncedIterations number of synchronous iterations in each async iteration.
  116070. * @param fn the function to call each iteration.
  116071. * @param callback a success call back that will be called when iterating stops.
  116072. * @param breakFunction a break condition (optional)
  116073. * @param timeout timeout settings for the setTimeout function. default - 0.
  116074. * @returns the created async loop object
  116075. */
  116076. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  116077. }
  116078. }
  116079. declare module BABYLON {
  116080. /**
  116081. * This class implement a typical dictionary using a string as key and the generic type T as value.
  116082. * The underlying implementation relies on an associative array to ensure the best performances.
  116083. * The value can be anything including 'null' but except 'undefined'
  116084. */
  116085. export class StringDictionary<T> {
  116086. /**
  116087. * This will clear this dictionary and copy the content from the 'source' one.
  116088. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  116089. * @param source the dictionary to take the content from and copy to this dictionary
  116090. */
  116091. copyFrom(source: StringDictionary<T>): void;
  116092. /**
  116093. * Get a value based from its key
  116094. * @param key the given key to get the matching value from
  116095. * @return the value if found, otherwise undefined is returned
  116096. */
  116097. get(key: string): T | undefined;
  116098. /**
  116099. * Get a value from its key or add it if it doesn't exist.
  116100. * This method will ensure you that a given key/data will be present in the dictionary.
  116101. * @param key the given key to get the matching value from
  116102. * @param factory the factory that will create the value if the key is not present in the dictionary.
  116103. * The factory will only be invoked if there's no data for the given key.
  116104. * @return the value corresponding to the key.
  116105. */
  116106. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  116107. /**
  116108. * Get a value from its key if present in the dictionary otherwise add it
  116109. * @param key the key to get the value from
  116110. * @param val if there's no such key/value pair in the dictionary add it with this value
  116111. * @return the value corresponding to the key
  116112. */
  116113. getOrAdd(key: string, val: T): T;
  116114. /**
  116115. * Check if there's a given key in the dictionary
  116116. * @param key the key to check for
  116117. * @return true if the key is present, false otherwise
  116118. */
  116119. contains(key: string): boolean;
  116120. /**
  116121. * Add a new key and its corresponding value
  116122. * @param key the key to add
  116123. * @param value the value corresponding to the key
  116124. * @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
  116125. */
  116126. add(key: string, value: T): boolean;
  116127. /**
  116128. * Update a specific value associated to a key
  116129. * @param key defines the key to use
  116130. * @param value defines the value to store
  116131. * @returns true if the value was updated (or false if the key was not found)
  116132. */
  116133. set(key: string, value: T): boolean;
  116134. /**
  116135. * Get the element of the given key and remove it from the dictionary
  116136. * @param key defines the key to search
  116137. * @returns the value associated with the key or null if not found
  116138. */
  116139. getAndRemove(key: string): Nullable<T>;
  116140. /**
  116141. * Remove a key/value from the dictionary.
  116142. * @param key the key to remove
  116143. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  116144. */
  116145. remove(key: string): boolean;
  116146. /**
  116147. * Clear the whole content of the dictionary
  116148. */
  116149. clear(): void;
  116150. /**
  116151. * Gets the current count
  116152. */
  116153. get count(): number;
  116154. /**
  116155. * Execute a callback on each key/val of the dictionary.
  116156. * Note that you can remove any element in this dictionary in the callback implementation
  116157. * @param callback the callback to execute on a given key/value pair
  116158. */
  116159. forEach(callback: (key: string, val: T) => void): void;
  116160. /**
  116161. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  116162. * If the callback returns null or undefined the method will iterate to the next key/value pair
  116163. * Note that you can remove any element in this dictionary in the callback implementation
  116164. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  116165. * @returns the first item
  116166. */
  116167. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  116168. private _count;
  116169. private _data;
  116170. }
  116171. }
  116172. declare module BABYLON {
  116173. /** @hidden */
  116174. export interface ICollisionCoordinator {
  116175. createCollider(): Collider;
  116176. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  116177. init(scene: Scene): void;
  116178. }
  116179. /** @hidden */
  116180. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  116181. private _scene;
  116182. private _scaledPosition;
  116183. private _scaledVelocity;
  116184. private _finalPosition;
  116185. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  116186. createCollider(): Collider;
  116187. init(scene: Scene): void;
  116188. private _collideWithWorld;
  116189. }
  116190. }
  116191. declare module BABYLON {
  116192. /**
  116193. * Class used to manage all inputs for the scene.
  116194. */
  116195. export class InputManager {
  116196. /** The distance in pixel that you have to move to prevent some events */
  116197. static DragMovementThreshold: number;
  116198. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  116199. static LongPressDelay: number;
  116200. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  116201. static DoubleClickDelay: number;
  116202. /** If you need to check double click without raising a single click at first click, enable this flag */
  116203. static ExclusiveDoubleClickMode: boolean;
  116204. private _wheelEventName;
  116205. private _onPointerMove;
  116206. private _onPointerDown;
  116207. private _onPointerUp;
  116208. private _initClickEvent;
  116209. private _initActionManager;
  116210. private _delayedSimpleClick;
  116211. private _delayedSimpleClickTimeout;
  116212. private _previousDelayedSimpleClickTimeout;
  116213. private _meshPickProceed;
  116214. private _previousButtonPressed;
  116215. private _currentPickResult;
  116216. private _previousPickResult;
  116217. private _totalPointersPressed;
  116218. private _doubleClickOccured;
  116219. private _pointerOverMesh;
  116220. private _pickedDownMesh;
  116221. private _pickedUpMesh;
  116222. private _pointerX;
  116223. private _pointerY;
  116224. private _unTranslatedPointerX;
  116225. private _unTranslatedPointerY;
  116226. private _startingPointerPosition;
  116227. private _previousStartingPointerPosition;
  116228. private _startingPointerTime;
  116229. private _previousStartingPointerTime;
  116230. private _pointerCaptures;
  116231. private _onKeyDown;
  116232. private _onKeyUp;
  116233. private _onCanvasFocusObserver;
  116234. private _onCanvasBlurObserver;
  116235. private _scene;
  116236. /**
  116237. * Creates a new InputManager
  116238. * @param scene defines the hosting scene
  116239. */
  116240. constructor(scene: Scene);
  116241. /**
  116242. * Gets the mesh that is currently under the pointer
  116243. */
  116244. get meshUnderPointer(): Nullable<AbstractMesh>;
  116245. /**
  116246. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  116247. */
  116248. get unTranslatedPointer(): Vector2;
  116249. /**
  116250. * Gets or sets the current on-screen X position of the pointer
  116251. */
  116252. get pointerX(): number;
  116253. set pointerX(value: number);
  116254. /**
  116255. * Gets or sets the current on-screen Y position of the pointer
  116256. */
  116257. get pointerY(): number;
  116258. set pointerY(value: number);
  116259. private _updatePointerPosition;
  116260. private _processPointerMove;
  116261. private _setRayOnPointerInfo;
  116262. private _checkPrePointerObservable;
  116263. /**
  116264. * Use this method to simulate a pointer move on a mesh
  116265. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116266. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116267. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116268. */
  116269. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  116270. /**
  116271. * Use this method to simulate a pointer down on a mesh
  116272. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116273. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116274. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116275. */
  116276. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  116277. private _processPointerDown;
  116278. /** @hidden */
  116279. _isPointerSwiping(): boolean;
  116280. /**
  116281. * Use this method to simulate a pointer up on a mesh
  116282. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116283. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116284. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116285. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  116286. */
  116287. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  116288. private _processPointerUp;
  116289. /**
  116290. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  116291. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  116292. * @returns true if the pointer was captured
  116293. */
  116294. isPointerCaptured(pointerId?: number): boolean;
  116295. /**
  116296. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  116297. * @param attachUp defines if you want to attach events to pointerup
  116298. * @param attachDown defines if you want to attach events to pointerdown
  116299. * @param attachMove defines if you want to attach events to pointermove
  116300. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  116301. */
  116302. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  116303. /**
  116304. * Detaches all event handlers
  116305. */
  116306. detachControl(): void;
  116307. /**
  116308. * Force the value of meshUnderPointer
  116309. * @param mesh defines the mesh to use
  116310. */
  116311. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  116312. /**
  116313. * Gets the mesh under the pointer
  116314. * @returns a Mesh or null if no mesh is under the pointer
  116315. */
  116316. getPointerOverMesh(): Nullable<AbstractMesh>;
  116317. }
  116318. }
  116319. declare module BABYLON {
  116320. /**
  116321. * This class defines the direct association between an animation and a target
  116322. */
  116323. export class TargetedAnimation {
  116324. /**
  116325. * Animation to perform
  116326. */
  116327. animation: Animation;
  116328. /**
  116329. * Target to animate
  116330. */
  116331. target: any;
  116332. /**
  116333. * Returns the string "TargetedAnimation"
  116334. * @returns "TargetedAnimation"
  116335. */
  116336. getClassName(): string;
  116337. /**
  116338. * Serialize the object
  116339. * @returns the JSON object representing the current entity
  116340. */
  116341. serialize(): any;
  116342. }
  116343. /**
  116344. * Use this class to create coordinated animations on multiple targets
  116345. */
  116346. export class AnimationGroup implements IDisposable {
  116347. /** The name of the animation group */
  116348. name: string;
  116349. private _scene;
  116350. private _targetedAnimations;
  116351. private _animatables;
  116352. private _from;
  116353. private _to;
  116354. private _isStarted;
  116355. private _isPaused;
  116356. private _speedRatio;
  116357. private _loopAnimation;
  116358. private _isAdditive;
  116359. /**
  116360. * Gets or sets the unique id of the node
  116361. */
  116362. uniqueId: number;
  116363. /**
  116364. * This observable will notify when one animation have ended
  116365. */
  116366. onAnimationEndObservable: Observable<TargetedAnimation>;
  116367. /**
  116368. * Observer raised when one animation loops
  116369. */
  116370. onAnimationLoopObservable: Observable<TargetedAnimation>;
  116371. /**
  116372. * Observer raised when all animations have looped
  116373. */
  116374. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  116375. /**
  116376. * This observable will notify when all animations have ended.
  116377. */
  116378. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  116379. /**
  116380. * This observable will notify when all animations have paused.
  116381. */
  116382. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  116383. /**
  116384. * This observable will notify when all animations are playing.
  116385. */
  116386. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  116387. /**
  116388. * Gets the first frame
  116389. */
  116390. get from(): number;
  116391. /**
  116392. * Gets the last frame
  116393. */
  116394. get to(): number;
  116395. /**
  116396. * Define if the animations are started
  116397. */
  116398. get isStarted(): boolean;
  116399. /**
  116400. * Gets a value indicating that the current group is playing
  116401. */
  116402. get isPlaying(): boolean;
  116403. /**
  116404. * Gets or sets the speed ratio to use for all animations
  116405. */
  116406. get speedRatio(): number;
  116407. /**
  116408. * Gets or sets the speed ratio to use for all animations
  116409. */
  116410. set speedRatio(value: number);
  116411. /**
  116412. * Gets or sets if all animations should loop or not
  116413. */
  116414. get loopAnimation(): boolean;
  116415. set loopAnimation(value: boolean);
  116416. /**
  116417. * Gets or sets if all animations should be evaluated additively
  116418. */
  116419. get isAdditive(): boolean;
  116420. set isAdditive(value: boolean);
  116421. /**
  116422. * Gets the targeted animations for this animation group
  116423. */
  116424. get targetedAnimations(): Array<TargetedAnimation>;
  116425. /**
  116426. * returning the list of animatables controlled by this animation group.
  116427. */
  116428. get animatables(): Array<Animatable>;
  116429. /**
  116430. * Gets the list of target animations
  116431. */
  116432. get children(): TargetedAnimation[];
  116433. /**
  116434. * Instantiates a new Animation Group.
  116435. * This helps managing several animations at once.
  116436. * @see https://doc.babylonjs.com/how_to/group
  116437. * @param name Defines the name of the group
  116438. * @param scene Defines the scene the group belongs to
  116439. */
  116440. constructor(
  116441. /** The name of the animation group */
  116442. name: string, scene?: Nullable<Scene>);
  116443. /**
  116444. * Add an animation (with its target) in the group
  116445. * @param animation defines the animation we want to add
  116446. * @param target defines the target of the animation
  116447. * @returns the TargetedAnimation object
  116448. */
  116449. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  116450. /**
  116451. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  116452. * It can add constant keys at begin or end
  116453. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  116454. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  116455. * @returns the animation group
  116456. */
  116457. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  116458. private _animationLoopCount;
  116459. private _animationLoopFlags;
  116460. private _processLoop;
  116461. /**
  116462. * Start all animations on given targets
  116463. * @param loop defines if animations must loop
  116464. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  116465. * @param from defines the from key (optional)
  116466. * @param to defines the to key (optional)
  116467. * @param isAdditive defines the additive state for the resulting animatables (optional)
  116468. * @returns the current animation group
  116469. */
  116470. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  116471. /**
  116472. * Pause all animations
  116473. * @returns the animation group
  116474. */
  116475. pause(): AnimationGroup;
  116476. /**
  116477. * Play all animations to initial state
  116478. * This function will start() the animations if they were not started or will restart() them if they were paused
  116479. * @param loop defines if animations must loop
  116480. * @returns the animation group
  116481. */
  116482. play(loop?: boolean): AnimationGroup;
  116483. /**
  116484. * Reset all animations to initial state
  116485. * @returns the animation group
  116486. */
  116487. reset(): AnimationGroup;
  116488. /**
  116489. * Restart animations from key 0
  116490. * @returns the animation group
  116491. */
  116492. restart(): AnimationGroup;
  116493. /**
  116494. * Stop all animations
  116495. * @returns the animation group
  116496. */
  116497. stop(): AnimationGroup;
  116498. /**
  116499. * Set animation weight for all animatables
  116500. * @param weight defines the weight to use
  116501. * @return the animationGroup
  116502. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  116503. */
  116504. setWeightForAllAnimatables(weight: number): AnimationGroup;
  116505. /**
  116506. * Synchronize and normalize all animatables with a source animatable
  116507. * @param root defines the root animatable to synchronize with
  116508. * @return the animationGroup
  116509. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  116510. */
  116511. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  116512. /**
  116513. * Goes to a specific frame in this animation group
  116514. * @param frame the frame number to go to
  116515. * @return the animationGroup
  116516. */
  116517. goToFrame(frame: number): AnimationGroup;
  116518. /**
  116519. * Dispose all associated resources
  116520. */
  116521. dispose(): void;
  116522. private _checkAnimationGroupEnded;
  116523. /**
  116524. * Clone the current animation group and returns a copy
  116525. * @param newName defines the name of the new group
  116526. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  116527. * @returns the new aniamtion group
  116528. */
  116529. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  116530. /**
  116531. * Serializes the animationGroup to an object
  116532. * @returns Serialized object
  116533. */
  116534. serialize(): any;
  116535. /**
  116536. * Returns a new AnimationGroup object parsed from the source provided.
  116537. * @param parsedAnimationGroup defines the source
  116538. * @param scene defines the scene that will receive the animationGroup
  116539. * @returns a new AnimationGroup
  116540. */
  116541. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  116542. /**
  116543. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  116544. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  116545. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  116546. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  116547. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  116548. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  116549. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  116550. */
  116551. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  116552. /**
  116553. * Returns the string "AnimationGroup"
  116554. * @returns "AnimationGroup"
  116555. */
  116556. getClassName(): string;
  116557. /**
  116558. * Creates a detailled string about the object
  116559. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  116560. * @returns a string representing the object
  116561. */
  116562. toString(fullDetails?: boolean): string;
  116563. }
  116564. }
  116565. declare module BABYLON {
  116566. /**
  116567. * Define an interface for all classes that will hold resources
  116568. */
  116569. export interface IDisposable {
  116570. /**
  116571. * Releases all held resources
  116572. */
  116573. dispose(): void;
  116574. }
  116575. /** Interface defining initialization parameters for Scene class */
  116576. export interface SceneOptions {
  116577. /**
  116578. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  116579. * It will improve performance when the number of geometries becomes important.
  116580. */
  116581. useGeometryUniqueIdsMap?: boolean;
  116582. /**
  116583. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  116584. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116585. */
  116586. useMaterialMeshMap?: boolean;
  116587. /**
  116588. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  116589. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116590. */
  116591. useClonedMeshMap?: boolean;
  116592. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  116593. virtual?: boolean;
  116594. }
  116595. /**
  116596. * Represents a scene to be rendered by the engine.
  116597. * @see https://doc.babylonjs.com/features/scene
  116598. */
  116599. export class Scene extends AbstractScene implements IAnimatable {
  116600. /** The fog is deactivated */
  116601. static readonly FOGMODE_NONE: number;
  116602. /** The fog density is following an exponential function */
  116603. static readonly FOGMODE_EXP: number;
  116604. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  116605. static readonly FOGMODE_EXP2: number;
  116606. /** The fog density is following a linear function. */
  116607. static readonly FOGMODE_LINEAR: number;
  116608. /**
  116609. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  116610. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116611. */
  116612. static MinDeltaTime: number;
  116613. /**
  116614. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  116615. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116616. */
  116617. static MaxDeltaTime: number;
  116618. /**
  116619. * Factory used to create the default material.
  116620. * @param name The name of the material to create
  116621. * @param scene The scene to create the material for
  116622. * @returns The default material
  116623. */
  116624. static DefaultMaterialFactory(scene: Scene): Material;
  116625. /**
  116626. * Factory used to create the a collision coordinator.
  116627. * @returns The collision coordinator
  116628. */
  116629. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  116630. /** @hidden */
  116631. _inputManager: InputManager;
  116632. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  116633. cameraToUseForPointers: Nullable<Camera>;
  116634. /** @hidden */
  116635. readonly _isScene: boolean;
  116636. /** @hidden */
  116637. _blockEntityCollection: boolean;
  116638. /**
  116639. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  116640. */
  116641. autoClear: boolean;
  116642. /**
  116643. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  116644. */
  116645. autoClearDepthAndStencil: boolean;
  116646. /**
  116647. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  116648. */
  116649. clearColor: Color4;
  116650. /**
  116651. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  116652. */
  116653. ambientColor: Color3;
  116654. /**
  116655. * This is use to store the default BRDF lookup for PBR materials in your scene.
  116656. * It should only be one of the following (if not the default embedded one):
  116657. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116658. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  116659. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116660. * The material properties need to be setup according to the type of texture in use.
  116661. */
  116662. environmentBRDFTexture: BaseTexture;
  116663. /** @hidden */
  116664. protected _environmentTexture: Nullable<BaseTexture>;
  116665. /**
  116666. * Texture used in all pbr material as the reflection texture.
  116667. * As in the majority of the scene they are the same (exception for multi room and so on),
  116668. * this is easier to reference from here than from all the materials.
  116669. */
  116670. get environmentTexture(): Nullable<BaseTexture>;
  116671. /**
  116672. * Texture used in all pbr material as the reflection texture.
  116673. * As in the majority of the scene they are the same (exception for multi room and so on),
  116674. * this is easier to set here than in all the materials.
  116675. */
  116676. set environmentTexture(value: Nullable<BaseTexture>);
  116677. /** @hidden */
  116678. protected _environmentIntensity: number;
  116679. /**
  116680. * Intensity of the environment in all pbr material.
  116681. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116682. * As in the majority of the scene they are the same (exception for multi room and so on),
  116683. * this is easier to reference from here than from all the materials.
  116684. */
  116685. get environmentIntensity(): number;
  116686. /**
  116687. * Intensity of the environment in all pbr material.
  116688. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116689. * As in the majority of the scene they are the same (exception for multi room and so on),
  116690. * this is easier to set here than in all the materials.
  116691. */
  116692. set environmentIntensity(value: number);
  116693. /** @hidden */
  116694. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116695. /**
  116696. * Default image processing configuration used either in the rendering
  116697. * Forward main pass or through the imageProcessingPostProcess if present.
  116698. * As in the majority of the scene they are the same (exception for multi camera),
  116699. * this is easier to reference from here than from all the materials and post process.
  116700. *
  116701. * No setter as we it is a shared configuration, you can set the values instead.
  116702. */
  116703. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116704. private _forceWireframe;
  116705. /**
  116706. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  116707. */
  116708. set forceWireframe(value: boolean);
  116709. get forceWireframe(): boolean;
  116710. private _skipFrustumClipping;
  116711. /**
  116712. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  116713. */
  116714. set skipFrustumClipping(value: boolean);
  116715. get skipFrustumClipping(): boolean;
  116716. private _forcePointsCloud;
  116717. /**
  116718. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  116719. */
  116720. set forcePointsCloud(value: boolean);
  116721. get forcePointsCloud(): boolean;
  116722. /**
  116723. * Gets or sets the active clipplane 1
  116724. */
  116725. clipPlane: Nullable<Plane>;
  116726. /**
  116727. * Gets or sets the active clipplane 2
  116728. */
  116729. clipPlane2: Nullable<Plane>;
  116730. /**
  116731. * Gets or sets the active clipplane 3
  116732. */
  116733. clipPlane3: Nullable<Plane>;
  116734. /**
  116735. * Gets or sets the active clipplane 4
  116736. */
  116737. clipPlane4: Nullable<Plane>;
  116738. /**
  116739. * Gets or sets the active clipplane 5
  116740. */
  116741. clipPlane5: Nullable<Plane>;
  116742. /**
  116743. * Gets or sets the active clipplane 6
  116744. */
  116745. clipPlane6: Nullable<Plane>;
  116746. /**
  116747. * Gets or sets a boolean indicating if animations are enabled
  116748. */
  116749. animationsEnabled: boolean;
  116750. private _animationPropertiesOverride;
  116751. /**
  116752. * Gets or sets the animation properties override
  116753. */
  116754. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116755. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116756. /**
  116757. * Gets or sets a boolean indicating if a constant deltatime has to be used
  116758. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  116759. */
  116760. useConstantAnimationDeltaTime: boolean;
  116761. /**
  116762. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  116763. * Please note that it requires to run a ray cast through the scene on every frame
  116764. */
  116765. constantlyUpdateMeshUnderPointer: boolean;
  116766. /**
  116767. * Defines the HTML cursor to use when hovering over interactive elements
  116768. */
  116769. hoverCursor: string;
  116770. /**
  116771. * Defines the HTML default cursor to use (empty by default)
  116772. */
  116773. defaultCursor: string;
  116774. /**
  116775. * Defines whether cursors are handled by the scene.
  116776. */
  116777. doNotHandleCursors: boolean;
  116778. /**
  116779. * This is used to call preventDefault() on pointer down
  116780. * in order to block unwanted artifacts like system double clicks
  116781. */
  116782. preventDefaultOnPointerDown: boolean;
  116783. /**
  116784. * This is used to call preventDefault() on pointer up
  116785. * in order to block unwanted artifacts like system double clicks
  116786. */
  116787. preventDefaultOnPointerUp: boolean;
  116788. /**
  116789. * Gets or sets user defined metadata
  116790. */
  116791. metadata: any;
  116792. /**
  116793. * For internal use only. Please do not use.
  116794. */
  116795. reservedDataStore: any;
  116796. /**
  116797. * Gets the name of the plugin used to load this scene (null by default)
  116798. */
  116799. loadingPluginName: string;
  116800. /**
  116801. * Use this array to add regular expressions used to disable offline support for specific urls
  116802. */
  116803. disableOfflineSupportExceptionRules: RegExp[];
  116804. /**
  116805. * An event triggered when the scene is disposed.
  116806. */
  116807. onDisposeObservable: Observable<Scene>;
  116808. private _onDisposeObserver;
  116809. /** Sets a function to be executed when this scene is disposed. */
  116810. set onDispose(callback: () => void);
  116811. /**
  116812. * An event triggered before rendering the scene (right after animations and physics)
  116813. */
  116814. onBeforeRenderObservable: Observable<Scene>;
  116815. private _onBeforeRenderObserver;
  116816. /** Sets a function to be executed before rendering this scene */
  116817. set beforeRender(callback: Nullable<() => void>);
  116818. /**
  116819. * An event triggered after rendering the scene
  116820. */
  116821. onAfterRenderObservable: Observable<Scene>;
  116822. /**
  116823. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  116824. */
  116825. onAfterRenderCameraObservable: Observable<Camera>;
  116826. private _onAfterRenderObserver;
  116827. /** Sets a function to be executed after rendering this scene */
  116828. set afterRender(callback: Nullable<() => void>);
  116829. /**
  116830. * An event triggered before animating the scene
  116831. */
  116832. onBeforeAnimationsObservable: Observable<Scene>;
  116833. /**
  116834. * An event triggered after animations processing
  116835. */
  116836. onAfterAnimationsObservable: Observable<Scene>;
  116837. /**
  116838. * An event triggered before draw calls are ready to be sent
  116839. */
  116840. onBeforeDrawPhaseObservable: Observable<Scene>;
  116841. /**
  116842. * An event triggered after draw calls have been sent
  116843. */
  116844. onAfterDrawPhaseObservable: Observable<Scene>;
  116845. /**
  116846. * An event triggered when the scene is ready
  116847. */
  116848. onReadyObservable: Observable<Scene>;
  116849. /**
  116850. * An event triggered before rendering a camera
  116851. */
  116852. onBeforeCameraRenderObservable: Observable<Camera>;
  116853. private _onBeforeCameraRenderObserver;
  116854. /** Sets a function to be executed before rendering a camera*/
  116855. set beforeCameraRender(callback: () => void);
  116856. /**
  116857. * An event triggered after rendering a camera
  116858. */
  116859. onAfterCameraRenderObservable: Observable<Camera>;
  116860. private _onAfterCameraRenderObserver;
  116861. /** Sets a function to be executed after rendering a camera*/
  116862. set afterCameraRender(callback: () => void);
  116863. /**
  116864. * An event triggered when active meshes evaluation is about to start
  116865. */
  116866. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  116867. /**
  116868. * An event triggered when active meshes evaluation is done
  116869. */
  116870. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  116871. /**
  116872. * An event triggered when particles rendering is about to start
  116873. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116874. */
  116875. onBeforeParticlesRenderingObservable: Observable<Scene>;
  116876. /**
  116877. * An event triggered when particles rendering is done
  116878. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116879. */
  116880. onAfterParticlesRenderingObservable: Observable<Scene>;
  116881. /**
  116882. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  116883. */
  116884. onDataLoadedObservable: Observable<Scene>;
  116885. /**
  116886. * An event triggered when a camera is created
  116887. */
  116888. onNewCameraAddedObservable: Observable<Camera>;
  116889. /**
  116890. * An event triggered when a camera is removed
  116891. */
  116892. onCameraRemovedObservable: Observable<Camera>;
  116893. /**
  116894. * An event triggered when a light is created
  116895. */
  116896. onNewLightAddedObservable: Observable<Light>;
  116897. /**
  116898. * An event triggered when a light is removed
  116899. */
  116900. onLightRemovedObservable: Observable<Light>;
  116901. /**
  116902. * An event triggered when a geometry is created
  116903. */
  116904. onNewGeometryAddedObservable: Observable<Geometry>;
  116905. /**
  116906. * An event triggered when a geometry is removed
  116907. */
  116908. onGeometryRemovedObservable: Observable<Geometry>;
  116909. /**
  116910. * An event triggered when a transform node is created
  116911. */
  116912. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  116913. /**
  116914. * An event triggered when a transform node is removed
  116915. */
  116916. onTransformNodeRemovedObservable: Observable<TransformNode>;
  116917. /**
  116918. * An event triggered when a mesh is created
  116919. */
  116920. onNewMeshAddedObservable: Observable<AbstractMesh>;
  116921. /**
  116922. * An event triggered when a mesh is removed
  116923. */
  116924. onMeshRemovedObservable: Observable<AbstractMesh>;
  116925. /**
  116926. * An event triggered when a skeleton is created
  116927. */
  116928. onNewSkeletonAddedObservable: Observable<Skeleton>;
  116929. /**
  116930. * An event triggered when a skeleton is removed
  116931. */
  116932. onSkeletonRemovedObservable: Observable<Skeleton>;
  116933. /**
  116934. * An event triggered when a material is created
  116935. */
  116936. onNewMaterialAddedObservable: Observable<Material>;
  116937. /**
  116938. * An event triggered when a material is removed
  116939. */
  116940. onMaterialRemovedObservable: Observable<Material>;
  116941. /**
  116942. * An event triggered when a texture is created
  116943. */
  116944. onNewTextureAddedObservable: Observable<BaseTexture>;
  116945. /**
  116946. * An event triggered when a texture is removed
  116947. */
  116948. onTextureRemovedObservable: Observable<BaseTexture>;
  116949. /**
  116950. * An event triggered when render targets are about to be rendered
  116951. * Can happen multiple times per frame.
  116952. */
  116953. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  116954. /**
  116955. * An event triggered when render targets were rendered.
  116956. * Can happen multiple times per frame.
  116957. */
  116958. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  116959. /**
  116960. * An event triggered before calculating deterministic simulation step
  116961. */
  116962. onBeforeStepObservable: Observable<Scene>;
  116963. /**
  116964. * An event triggered after calculating deterministic simulation step
  116965. */
  116966. onAfterStepObservable: Observable<Scene>;
  116967. /**
  116968. * An event triggered when the activeCamera property is updated
  116969. */
  116970. onActiveCameraChanged: Observable<Scene>;
  116971. /**
  116972. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  116973. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116974. * 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)
  116975. */
  116976. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116977. /**
  116978. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  116979. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116980. * 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)
  116981. */
  116982. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116983. /**
  116984. * This Observable will when a mesh has been imported into the scene.
  116985. */
  116986. onMeshImportedObservable: Observable<AbstractMesh>;
  116987. /**
  116988. * This Observable will when an animation file has been imported into the scene.
  116989. */
  116990. onAnimationFileImportedObservable: Observable<Scene>;
  116991. /**
  116992. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  116993. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  116994. */
  116995. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  116996. /** @hidden */
  116997. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  116998. /**
  116999. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  117000. */
  117001. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  117002. /**
  117003. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  117004. */
  117005. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  117006. /**
  117007. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  117008. */
  117009. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  117010. /** Callback called when a pointer move is detected */
  117011. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  117012. /** Callback called when a pointer down is detected */
  117013. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  117014. /** Callback called when a pointer up is detected */
  117015. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  117016. /** Callback called when a pointer pick is detected */
  117017. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  117018. /**
  117019. * 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).
  117020. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  117021. */
  117022. onPrePointerObservable: Observable<PointerInfoPre>;
  117023. /**
  117024. * Observable event triggered each time an input event is received from the rendering canvas
  117025. */
  117026. onPointerObservable: Observable<PointerInfo>;
  117027. /**
  117028. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  117029. */
  117030. get unTranslatedPointer(): Vector2;
  117031. /**
  117032. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  117033. */
  117034. static get DragMovementThreshold(): number;
  117035. static set DragMovementThreshold(value: number);
  117036. /**
  117037. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  117038. */
  117039. static get LongPressDelay(): number;
  117040. static set LongPressDelay(value: number);
  117041. /**
  117042. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  117043. */
  117044. static get DoubleClickDelay(): number;
  117045. static set DoubleClickDelay(value: number);
  117046. /** If you need to check double click without raising a single click at first click, enable this flag */
  117047. static get ExclusiveDoubleClickMode(): boolean;
  117048. static set ExclusiveDoubleClickMode(value: boolean);
  117049. /** @hidden */
  117050. _mirroredCameraPosition: Nullable<Vector3>;
  117051. /**
  117052. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  117053. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  117054. */
  117055. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  117056. /**
  117057. * Observable event triggered each time an keyboard event is received from the hosting window
  117058. */
  117059. onKeyboardObservable: Observable<KeyboardInfo>;
  117060. private _useRightHandedSystem;
  117061. /**
  117062. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  117063. */
  117064. set useRightHandedSystem(value: boolean);
  117065. get useRightHandedSystem(): boolean;
  117066. private _timeAccumulator;
  117067. private _currentStepId;
  117068. private _currentInternalStep;
  117069. /**
  117070. * Sets the step Id used by deterministic lock step
  117071. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117072. * @param newStepId defines the step Id
  117073. */
  117074. setStepId(newStepId: number): void;
  117075. /**
  117076. * Gets the step Id used by deterministic lock step
  117077. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117078. * @returns the step Id
  117079. */
  117080. getStepId(): number;
  117081. /**
  117082. * Gets the internal step used by deterministic lock step
  117083. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117084. * @returns the internal step
  117085. */
  117086. getInternalStep(): number;
  117087. private _fogEnabled;
  117088. /**
  117089. * Gets or sets a boolean indicating if fog is enabled on this scene
  117090. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117091. * (Default is true)
  117092. */
  117093. set fogEnabled(value: boolean);
  117094. get fogEnabled(): boolean;
  117095. private _fogMode;
  117096. /**
  117097. * Gets or sets the fog mode to use
  117098. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117099. * | mode | value |
  117100. * | --- | --- |
  117101. * | FOGMODE_NONE | 0 |
  117102. * | FOGMODE_EXP | 1 |
  117103. * | FOGMODE_EXP2 | 2 |
  117104. * | FOGMODE_LINEAR | 3 |
  117105. */
  117106. set fogMode(value: number);
  117107. get fogMode(): number;
  117108. /**
  117109. * Gets or sets the fog color to use
  117110. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117111. * (Default is Color3(0.2, 0.2, 0.3))
  117112. */
  117113. fogColor: Color3;
  117114. /**
  117115. * Gets or sets the fog density to use
  117116. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117117. * (Default is 0.1)
  117118. */
  117119. fogDensity: number;
  117120. /**
  117121. * Gets or sets the fog start distance to use
  117122. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117123. * (Default is 0)
  117124. */
  117125. fogStart: number;
  117126. /**
  117127. * Gets or sets the fog end distance to use
  117128. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117129. * (Default is 1000)
  117130. */
  117131. fogEnd: number;
  117132. /**
  117133. * Flag indicating that the frame buffer binding is handled by another component
  117134. */
  117135. prePass: boolean;
  117136. private _shadowsEnabled;
  117137. /**
  117138. * Gets or sets a boolean indicating if shadows are enabled on this scene
  117139. */
  117140. set shadowsEnabled(value: boolean);
  117141. get shadowsEnabled(): boolean;
  117142. private _lightsEnabled;
  117143. /**
  117144. * Gets or sets a boolean indicating if lights are enabled on this scene
  117145. */
  117146. set lightsEnabled(value: boolean);
  117147. get lightsEnabled(): boolean;
  117148. /** All of the active cameras added to this scene. */
  117149. activeCameras: Camera[];
  117150. /** @hidden */
  117151. _activeCamera: Nullable<Camera>;
  117152. /** Gets or sets the current active camera */
  117153. get activeCamera(): Nullable<Camera>;
  117154. set activeCamera(value: Nullable<Camera>);
  117155. private _defaultMaterial;
  117156. /** The default material used on meshes when no material is affected */
  117157. get defaultMaterial(): Material;
  117158. /** The default material used on meshes when no material is affected */
  117159. set defaultMaterial(value: Material);
  117160. private _texturesEnabled;
  117161. /**
  117162. * Gets or sets a boolean indicating if textures are enabled on this scene
  117163. */
  117164. set texturesEnabled(value: boolean);
  117165. get texturesEnabled(): boolean;
  117166. /**
  117167. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  117168. */
  117169. physicsEnabled: boolean;
  117170. /**
  117171. * Gets or sets a boolean indicating if particles are enabled on this scene
  117172. */
  117173. particlesEnabled: boolean;
  117174. /**
  117175. * Gets or sets a boolean indicating if sprites are enabled on this scene
  117176. */
  117177. spritesEnabled: boolean;
  117178. private _skeletonsEnabled;
  117179. /**
  117180. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  117181. */
  117182. set skeletonsEnabled(value: boolean);
  117183. get skeletonsEnabled(): boolean;
  117184. /**
  117185. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  117186. */
  117187. lensFlaresEnabled: boolean;
  117188. /**
  117189. * Gets or sets a boolean indicating if collisions are enabled on this scene
  117190. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117191. */
  117192. collisionsEnabled: boolean;
  117193. private _collisionCoordinator;
  117194. /** @hidden */
  117195. get collisionCoordinator(): ICollisionCoordinator;
  117196. /**
  117197. * Defines the gravity applied to this scene (used only for collisions)
  117198. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117199. */
  117200. gravity: Vector3;
  117201. /**
  117202. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  117203. */
  117204. postProcessesEnabled: boolean;
  117205. /**
  117206. * The list of postprocesses added to the scene
  117207. */
  117208. postProcesses: PostProcess[];
  117209. /**
  117210. * Gets the current postprocess manager
  117211. */
  117212. postProcessManager: PostProcessManager;
  117213. /**
  117214. * Gets or sets a boolean indicating if render targets are enabled on this scene
  117215. */
  117216. renderTargetsEnabled: boolean;
  117217. /**
  117218. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  117219. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  117220. */
  117221. dumpNextRenderTargets: boolean;
  117222. /**
  117223. * The list of user defined render targets added to the scene
  117224. */
  117225. customRenderTargets: RenderTargetTexture[];
  117226. /**
  117227. * Defines if texture loading must be delayed
  117228. * If true, textures will only be loaded when they need to be rendered
  117229. */
  117230. useDelayedTextureLoading: boolean;
  117231. /**
  117232. * Gets the list of meshes imported to the scene through SceneLoader
  117233. */
  117234. importedMeshesFiles: String[];
  117235. /**
  117236. * Gets or sets a boolean indicating if probes are enabled on this scene
  117237. */
  117238. probesEnabled: boolean;
  117239. /**
  117240. * Gets or sets the current offline provider to use to store scene data
  117241. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  117242. */
  117243. offlineProvider: IOfflineProvider;
  117244. /**
  117245. * Gets or sets the action manager associated with the scene
  117246. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117247. */
  117248. actionManager: AbstractActionManager;
  117249. private _meshesForIntersections;
  117250. /**
  117251. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  117252. */
  117253. proceduralTexturesEnabled: boolean;
  117254. private _engine;
  117255. private _totalVertices;
  117256. /** @hidden */
  117257. _activeIndices: PerfCounter;
  117258. /** @hidden */
  117259. _activeParticles: PerfCounter;
  117260. /** @hidden */
  117261. _activeBones: PerfCounter;
  117262. private _animationRatio;
  117263. /** @hidden */
  117264. _animationTimeLast: number;
  117265. /** @hidden */
  117266. _animationTime: number;
  117267. /**
  117268. * Gets or sets a general scale for animation speed
  117269. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  117270. */
  117271. animationTimeScale: number;
  117272. /** @hidden */
  117273. _cachedMaterial: Nullable<Material>;
  117274. /** @hidden */
  117275. _cachedEffect: Nullable<Effect>;
  117276. /** @hidden */
  117277. _cachedVisibility: Nullable<number>;
  117278. private _renderId;
  117279. private _frameId;
  117280. private _executeWhenReadyTimeoutId;
  117281. private _intermediateRendering;
  117282. private _viewUpdateFlag;
  117283. private _projectionUpdateFlag;
  117284. /** @hidden */
  117285. _toBeDisposed: Nullable<IDisposable>[];
  117286. private _activeRequests;
  117287. /** @hidden */
  117288. _pendingData: any[];
  117289. private _isDisposed;
  117290. /**
  117291. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  117292. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  117293. */
  117294. dispatchAllSubMeshesOfActiveMeshes: boolean;
  117295. private _activeMeshes;
  117296. private _processedMaterials;
  117297. private _renderTargets;
  117298. /** @hidden */
  117299. _activeParticleSystems: SmartArray<IParticleSystem>;
  117300. private _activeSkeletons;
  117301. private _softwareSkinnedMeshes;
  117302. private _renderingManager;
  117303. /** @hidden */
  117304. _activeAnimatables: Animatable[];
  117305. private _transformMatrix;
  117306. private _sceneUbo;
  117307. /** @hidden */
  117308. _viewMatrix: Matrix;
  117309. private _projectionMatrix;
  117310. /** @hidden */
  117311. _forcedViewPosition: Nullable<Vector3>;
  117312. /** @hidden */
  117313. _frustumPlanes: Plane[];
  117314. /**
  117315. * Gets the list of frustum planes (built from the active camera)
  117316. */
  117317. get frustumPlanes(): Plane[];
  117318. /**
  117319. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  117320. * This is useful if there are more lights that the maximum simulteanous authorized
  117321. */
  117322. requireLightSorting: boolean;
  117323. /** @hidden */
  117324. readonly useMaterialMeshMap: boolean;
  117325. /** @hidden */
  117326. readonly useClonedMeshMap: boolean;
  117327. private _externalData;
  117328. private _uid;
  117329. /**
  117330. * @hidden
  117331. * Backing store of defined scene components.
  117332. */
  117333. _components: ISceneComponent[];
  117334. /**
  117335. * @hidden
  117336. * Backing store of defined scene components.
  117337. */
  117338. _serializableComponents: ISceneSerializableComponent[];
  117339. /**
  117340. * List of components to register on the next registration step.
  117341. */
  117342. private _transientComponents;
  117343. /**
  117344. * Registers the transient components if needed.
  117345. */
  117346. private _registerTransientComponents;
  117347. /**
  117348. * @hidden
  117349. * Add a component to the scene.
  117350. * Note that the ccomponent could be registered on th next frame if this is called after
  117351. * the register component stage.
  117352. * @param component Defines the component to add to the scene
  117353. */
  117354. _addComponent(component: ISceneComponent): void;
  117355. /**
  117356. * @hidden
  117357. * Gets a component from the scene.
  117358. * @param name defines the name of the component to retrieve
  117359. * @returns the component or null if not present
  117360. */
  117361. _getComponent(name: string): Nullable<ISceneComponent>;
  117362. /**
  117363. * @hidden
  117364. * Defines the actions happening before camera updates.
  117365. */
  117366. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  117367. /**
  117368. * @hidden
  117369. * Defines the actions happening before clear the canvas.
  117370. */
  117371. _beforeClearStage: Stage<SimpleStageAction>;
  117372. /**
  117373. * @hidden
  117374. * Defines the actions when collecting render targets for the frame.
  117375. */
  117376. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  117377. /**
  117378. * @hidden
  117379. * Defines the actions happening for one camera in the frame.
  117380. */
  117381. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  117382. /**
  117383. * @hidden
  117384. * Defines the actions happening during the per mesh ready checks.
  117385. */
  117386. _isReadyForMeshStage: Stage<MeshStageAction>;
  117387. /**
  117388. * @hidden
  117389. * Defines the actions happening before evaluate active mesh checks.
  117390. */
  117391. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  117392. /**
  117393. * @hidden
  117394. * Defines the actions happening during the evaluate sub mesh checks.
  117395. */
  117396. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  117397. /**
  117398. * @hidden
  117399. * Defines the actions happening during the active mesh stage.
  117400. */
  117401. _activeMeshStage: Stage<ActiveMeshStageAction>;
  117402. /**
  117403. * @hidden
  117404. * Defines the actions happening during the per camera render target step.
  117405. */
  117406. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  117407. /**
  117408. * @hidden
  117409. * Defines the actions happening just before the active camera is drawing.
  117410. */
  117411. _beforeCameraDrawStage: Stage<CameraStageAction>;
  117412. /**
  117413. * @hidden
  117414. * Defines the actions happening just before a render target is drawing.
  117415. */
  117416. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117417. /**
  117418. * @hidden
  117419. * Defines the actions happening just before a rendering group is drawing.
  117420. */
  117421. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117422. /**
  117423. * @hidden
  117424. * Defines the actions happening just before a mesh is drawing.
  117425. */
  117426. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117427. /**
  117428. * @hidden
  117429. * Defines the actions happening just after a mesh has been drawn.
  117430. */
  117431. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117432. /**
  117433. * @hidden
  117434. * Defines the actions happening just after a rendering group has been drawn.
  117435. */
  117436. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117437. /**
  117438. * @hidden
  117439. * Defines the actions happening just after the active camera has been drawn.
  117440. */
  117441. _afterCameraDrawStage: Stage<CameraStageAction>;
  117442. /**
  117443. * @hidden
  117444. * Defines the actions happening just after a render target has been drawn.
  117445. */
  117446. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117447. /**
  117448. * @hidden
  117449. * Defines the actions happening just after rendering all cameras and computing intersections.
  117450. */
  117451. _afterRenderStage: Stage<SimpleStageAction>;
  117452. /**
  117453. * @hidden
  117454. * Defines the actions happening when a pointer move event happens.
  117455. */
  117456. _pointerMoveStage: Stage<PointerMoveStageAction>;
  117457. /**
  117458. * @hidden
  117459. * Defines the actions happening when a pointer down event happens.
  117460. */
  117461. _pointerDownStage: Stage<PointerUpDownStageAction>;
  117462. /**
  117463. * @hidden
  117464. * Defines the actions happening when a pointer up event happens.
  117465. */
  117466. _pointerUpStage: Stage<PointerUpDownStageAction>;
  117467. /**
  117468. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  117469. */
  117470. private geometriesByUniqueId;
  117471. /**
  117472. * Creates a new Scene
  117473. * @param engine defines the engine to use to render this scene
  117474. * @param options defines the scene options
  117475. */
  117476. constructor(engine: Engine, options?: SceneOptions);
  117477. /**
  117478. * Gets a string idenfifying the name of the class
  117479. * @returns "Scene" string
  117480. */
  117481. getClassName(): string;
  117482. private _defaultMeshCandidates;
  117483. /**
  117484. * @hidden
  117485. */
  117486. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  117487. private _defaultSubMeshCandidates;
  117488. /**
  117489. * @hidden
  117490. */
  117491. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  117492. /**
  117493. * Sets the default candidate providers for the scene.
  117494. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  117495. * and getCollidingSubMeshCandidates to their default function
  117496. */
  117497. setDefaultCandidateProviders(): void;
  117498. /**
  117499. * Gets the mesh that is currently under the pointer
  117500. */
  117501. get meshUnderPointer(): Nullable<AbstractMesh>;
  117502. /**
  117503. * Gets or sets the current on-screen X position of the pointer
  117504. */
  117505. get pointerX(): number;
  117506. set pointerX(value: number);
  117507. /**
  117508. * Gets or sets the current on-screen Y position of the pointer
  117509. */
  117510. get pointerY(): number;
  117511. set pointerY(value: number);
  117512. /**
  117513. * Gets the cached material (ie. the latest rendered one)
  117514. * @returns the cached material
  117515. */
  117516. getCachedMaterial(): Nullable<Material>;
  117517. /**
  117518. * Gets the cached effect (ie. the latest rendered one)
  117519. * @returns the cached effect
  117520. */
  117521. getCachedEffect(): Nullable<Effect>;
  117522. /**
  117523. * Gets the cached visibility state (ie. the latest rendered one)
  117524. * @returns the cached visibility state
  117525. */
  117526. getCachedVisibility(): Nullable<number>;
  117527. /**
  117528. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  117529. * @param material defines the current material
  117530. * @param effect defines the current effect
  117531. * @param visibility defines the current visibility state
  117532. * @returns true if one parameter is not cached
  117533. */
  117534. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  117535. /**
  117536. * Gets the engine associated with the scene
  117537. * @returns an Engine
  117538. */
  117539. getEngine(): Engine;
  117540. /**
  117541. * Gets the total number of vertices rendered per frame
  117542. * @returns the total number of vertices rendered per frame
  117543. */
  117544. getTotalVertices(): number;
  117545. /**
  117546. * Gets the performance counter for total vertices
  117547. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117548. */
  117549. get totalVerticesPerfCounter(): PerfCounter;
  117550. /**
  117551. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  117552. * @returns the total number of active indices rendered per frame
  117553. */
  117554. getActiveIndices(): number;
  117555. /**
  117556. * Gets the performance counter for active indices
  117557. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117558. */
  117559. get totalActiveIndicesPerfCounter(): PerfCounter;
  117560. /**
  117561. * Gets the total number of active particles rendered per frame
  117562. * @returns the total number of active particles rendered per frame
  117563. */
  117564. getActiveParticles(): number;
  117565. /**
  117566. * Gets the performance counter for active particles
  117567. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117568. */
  117569. get activeParticlesPerfCounter(): PerfCounter;
  117570. /**
  117571. * Gets the total number of active bones rendered per frame
  117572. * @returns the total number of active bones rendered per frame
  117573. */
  117574. getActiveBones(): number;
  117575. /**
  117576. * Gets the performance counter for active bones
  117577. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117578. */
  117579. get activeBonesPerfCounter(): PerfCounter;
  117580. /**
  117581. * Gets the array of active meshes
  117582. * @returns an array of AbstractMesh
  117583. */
  117584. getActiveMeshes(): SmartArray<AbstractMesh>;
  117585. /**
  117586. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  117587. * @returns a number
  117588. */
  117589. getAnimationRatio(): number;
  117590. /**
  117591. * Gets an unique Id for the current render phase
  117592. * @returns a number
  117593. */
  117594. getRenderId(): number;
  117595. /**
  117596. * Gets an unique Id for the current frame
  117597. * @returns a number
  117598. */
  117599. getFrameId(): number;
  117600. /** Call this function if you want to manually increment the render Id*/
  117601. incrementRenderId(): void;
  117602. private _createUbo;
  117603. /**
  117604. * Use this method to simulate a pointer move on a mesh
  117605. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117606. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117607. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117608. * @returns the current scene
  117609. */
  117610. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117611. /**
  117612. * Use this method to simulate a pointer down on a mesh
  117613. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117614. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117615. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117616. * @returns the current scene
  117617. */
  117618. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117619. /**
  117620. * Use this method to simulate a pointer up on a mesh
  117621. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117622. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117623. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117624. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117625. * @returns the current scene
  117626. */
  117627. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  117628. /**
  117629. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117630. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117631. * @returns true if the pointer was captured
  117632. */
  117633. isPointerCaptured(pointerId?: number): boolean;
  117634. /**
  117635. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117636. * @param attachUp defines if you want to attach events to pointerup
  117637. * @param attachDown defines if you want to attach events to pointerdown
  117638. * @param attachMove defines if you want to attach events to pointermove
  117639. */
  117640. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  117641. /** Detaches all event handlers*/
  117642. detachControl(): void;
  117643. /**
  117644. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  117645. * Delay loaded resources are not taking in account
  117646. * @return true if all required resources are ready
  117647. */
  117648. isReady(): boolean;
  117649. /** Resets all cached information relative to material (including effect and visibility) */
  117650. resetCachedMaterial(): void;
  117651. /**
  117652. * Registers a function to be called before every frame render
  117653. * @param func defines the function to register
  117654. */
  117655. registerBeforeRender(func: () => void): void;
  117656. /**
  117657. * Unregisters a function called before every frame render
  117658. * @param func defines the function to unregister
  117659. */
  117660. unregisterBeforeRender(func: () => void): void;
  117661. /**
  117662. * Registers a function to be called after every frame render
  117663. * @param func defines the function to register
  117664. */
  117665. registerAfterRender(func: () => void): void;
  117666. /**
  117667. * Unregisters a function called after every frame render
  117668. * @param func defines the function to unregister
  117669. */
  117670. unregisterAfterRender(func: () => void): void;
  117671. private _executeOnceBeforeRender;
  117672. /**
  117673. * The provided function will run before render once and will be disposed afterwards.
  117674. * A timeout delay can be provided so that the function will be executed in N ms.
  117675. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  117676. * @param func The function to be executed.
  117677. * @param timeout optional delay in ms
  117678. */
  117679. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  117680. /** @hidden */
  117681. _addPendingData(data: any): void;
  117682. /** @hidden */
  117683. _removePendingData(data: any): void;
  117684. /**
  117685. * Returns the number of items waiting to be loaded
  117686. * @returns the number of items waiting to be loaded
  117687. */
  117688. getWaitingItemsCount(): number;
  117689. /**
  117690. * Returns a boolean indicating if the scene is still loading data
  117691. */
  117692. get isLoading(): boolean;
  117693. /**
  117694. * Registers a function to be executed when the scene is ready
  117695. * @param {Function} func - the function to be executed
  117696. */
  117697. executeWhenReady(func: () => void): void;
  117698. /**
  117699. * Returns a promise that resolves when the scene is ready
  117700. * @returns A promise that resolves when the scene is ready
  117701. */
  117702. whenReadyAsync(): Promise<void>;
  117703. /** @hidden */
  117704. _checkIsReady(): void;
  117705. /**
  117706. * Gets all animatable attached to the scene
  117707. */
  117708. get animatables(): Animatable[];
  117709. /**
  117710. * Resets the last animation time frame.
  117711. * Useful to override when animations start running when loading a scene for the first time.
  117712. */
  117713. resetLastAnimationTimeFrame(): void;
  117714. /**
  117715. * Gets the current view matrix
  117716. * @returns a Matrix
  117717. */
  117718. getViewMatrix(): Matrix;
  117719. /**
  117720. * Gets the current projection matrix
  117721. * @returns a Matrix
  117722. */
  117723. getProjectionMatrix(): Matrix;
  117724. /**
  117725. * Gets the current transform matrix
  117726. * @returns a Matrix made of View * Projection
  117727. */
  117728. getTransformMatrix(): Matrix;
  117729. /**
  117730. * Sets the current transform matrix
  117731. * @param viewL defines the View matrix to use
  117732. * @param projectionL defines the Projection matrix to use
  117733. * @param viewR defines the right View matrix to use (if provided)
  117734. * @param projectionR defines the right Projection matrix to use (if provided)
  117735. */
  117736. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  117737. /**
  117738. * Gets the uniform buffer used to store scene data
  117739. * @returns a UniformBuffer
  117740. */
  117741. getSceneUniformBuffer(): UniformBuffer;
  117742. /**
  117743. * Gets an unique (relatively to the current scene) Id
  117744. * @returns an unique number for the scene
  117745. */
  117746. getUniqueId(): number;
  117747. /**
  117748. * Add a mesh to the list of scene's meshes
  117749. * @param newMesh defines the mesh to add
  117750. * @param recursive if all child meshes should also be added to the scene
  117751. */
  117752. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  117753. /**
  117754. * Remove a mesh for the list of scene's meshes
  117755. * @param toRemove defines the mesh to remove
  117756. * @param recursive if all child meshes should also be removed from the scene
  117757. * @returns the index where the mesh was in the mesh list
  117758. */
  117759. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  117760. /**
  117761. * Add a transform node to the list of scene's transform nodes
  117762. * @param newTransformNode defines the transform node to add
  117763. */
  117764. addTransformNode(newTransformNode: TransformNode): void;
  117765. /**
  117766. * Remove a transform node for the list of scene's transform nodes
  117767. * @param toRemove defines the transform node to remove
  117768. * @returns the index where the transform node was in the transform node list
  117769. */
  117770. removeTransformNode(toRemove: TransformNode): number;
  117771. /**
  117772. * Remove a skeleton for the list of scene's skeletons
  117773. * @param toRemove defines the skeleton to remove
  117774. * @returns the index where the skeleton was in the skeleton list
  117775. */
  117776. removeSkeleton(toRemove: Skeleton): number;
  117777. /**
  117778. * Remove a morph target for the list of scene's morph targets
  117779. * @param toRemove defines the morph target to remove
  117780. * @returns the index where the morph target was in the morph target list
  117781. */
  117782. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  117783. /**
  117784. * Remove a light for the list of scene's lights
  117785. * @param toRemove defines the light to remove
  117786. * @returns the index where the light was in the light list
  117787. */
  117788. removeLight(toRemove: Light): number;
  117789. /**
  117790. * Remove a camera for the list of scene's cameras
  117791. * @param toRemove defines the camera to remove
  117792. * @returns the index where the camera was in the camera list
  117793. */
  117794. removeCamera(toRemove: Camera): number;
  117795. /**
  117796. * Remove a particle system for the list of scene's particle systems
  117797. * @param toRemove defines the particle system to remove
  117798. * @returns the index where the particle system was in the particle system list
  117799. */
  117800. removeParticleSystem(toRemove: IParticleSystem): number;
  117801. /**
  117802. * Remove a animation for the list of scene's animations
  117803. * @param toRemove defines the animation to remove
  117804. * @returns the index where the animation was in the animation list
  117805. */
  117806. removeAnimation(toRemove: Animation): number;
  117807. /**
  117808. * Will stop the animation of the given target
  117809. * @param target - the target
  117810. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  117811. * @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)
  117812. */
  117813. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  117814. /**
  117815. * Removes the given animation group from this scene.
  117816. * @param toRemove The animation group to remove
  117817. * @returns The index of the removed animation group
  117818. */
  117819. removeAnimationGroup(toRemove: AnimationGroup): number;
  117820. /**
  117821. * Removes the given multi-material from this scene.
  117822. * @param toRemove The multi-material to remove
  117823. * @returns The index of the removed multi-material
  117824. */
  117825. removeMultiMaterial(toRemove: MultiMaterial): number;
  117826. /**
  117827. * Removes the given material from this scene.
  117828. * @param toRemove The material to remove
  117829. * @returns The index of the removed material
  117830. */
  117831. removeMaterial(toRemove: Material): number;
  117832. /**
  117833. * Removes the given action manager from this scene.
  117834. * @param toRemove The action manager to remove
  117835. * @returns The index of the removed action manager
  117836. */
  117837. removeActionManager(toRemove: AbstractActionManager): number;
  117838. /**
  117839. * Removes the given texture from this scene.
  117840. * @param toRemove The texture to remove
  117841. * @returns The index of the removed texture
  117842. */
  117843. removeTexture(toRemove: BaseTexture): number;
  117844. /**
  117845. * Adds the given light to this scene
  117846. * @param newLight The light to add
  117847. */
  117848. addLight(newLight: Light): void;
  117849. /**
  117850. * Sorts the list list based on light priorities
  117851. */
  117852. sortLightsByPriority(): void;
  117853. /**
  117854. * Adds the given camera to this scene
  117855. * @param newCamera The camera to add
  117856. */
  117857. addCamera(newCamera: Camera): void;
  117858. /**
  117859. * Adds the given skeleton to this scene
  117860. * @param newSkeleton The skeleton to add
  117861. */
  117862. addSkeleton(newSkeleton: Skeleton): void;
  117863. /**
  117864. * Adds the given particle system to this scene
  117865. * @param newParticleSystem The particle system to add
  117866. */
  117867. addParticleSystem(newParticleSystem: IParticleSystem): void;
  117868. /**
  117869. * Adds the given animation to this scene
  117870. * @param newAnimation The animation to add
  117871. */
  117872. addAnimation(newAnimation: Animation): void;
  117873. /**
  117874. * Adds the given animation group to this scene.
  117875. * @param newAnimationGroup The animation group to add
  117876. */
  117877. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  117878. /**
  117879. * Adds the given multi-material to this scene
  117880. * @param newMultiMaterial The multi-material to add
  117881. */
  117882. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  117883. /**
  117884. * Adds the given material to this scene
  117885. * @param newMaterial The material to add
  117886. */
  117887. addMaterial(newMaterial: Material): void;
  117888. /**
  117889. * Adds the given morph target to this scene
  117890. * @param newMorphTargetManager The morph target to add
  117891. */
  117892. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  117893. /**
  117894. * Adds the given geometry to this scene
  117895. * @param newGeometry The geometry to add
  117896. */
  117897. addGeometry(newGeometry: Geometry): void;
  117898. /**
  117899. * Adds the given action manager to this scene
  117900. * @param newActionManager The action manager to add
  117901. */
  117902. addActionManager(newActionManager: AbstractActionManager): void;
  117903. /**
  117904. * Adds the given texture to this scene.
  117905. * @param newTexture The texture to add
  117906. */
  117907. addTexture(newTexture: BaseTexture): void;
  117908. /**
  117909. * Switch active camera
  117910. * @param newCamera defines the new active camera
  117911. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  117912. */
  117913. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  117914. /**
  117915. * sets the active camera of the scene using its ID
  117916. * @param id defines the camera's ID
  117917. * @return the new active camera or null if none found.
  117918. */
  117919. setActiveCameraByID(id: string): Nullable<Camera>;
  117920. /**
  117921. * sets the active camera of the scene using its name
  117922. * @param name defines the camera's name
  117923. * @returns the new active camera or null if none found.
  117924. */
  117925. setActiveCameraByName(name: string): Nullable<Camera>;
  117926. /**
  117927. * get an animation group using its name
  117928. * @param name defines the material's name
  117929. * @return the animation group or null if none found.
  117930. */
  117931. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  117932. /**
  117933. * Get a material using its unique id
  117934. * @param uniqueId defines the material's unique id
  117935. * @return the material or null if none found.
  117936. */
  117937. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  117938. /**
  117939. * get a material using its id
  117940. * @param id defines the material's ID
  117941. * @return the material or null if none found.
  117942. */
  117943. getMaterialByID(id: string): Nullable<Material>;
  117944. /**
  117945. * Gets a the last added material using a given id
  117946. * @param id defines the material's ID
  117947. * @return the last material with the given id or null if none found.
  117948. */
  117949. getLastMaterialByID(id: string): Nullable<Material>;
  117950. /**
  117951. * Gets a material using its name
  117952. * @param name defines the material's name
  117953. * @return the material or null if none found.
  117954. */
  117955. getMaterialByName(name: string): Nullable<Material>;
  117956. /**
  117957. * Get a texture using its unique id
  117958. * @param uniqueId defines the texture's unique id
  117959. * @return the texture or null if none found.
  117960. */
  117961. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  117962. /**
  117963. * Gets a camera using its id
  117964. * @param id defines the id to look for
  117965. * @returns the camera or null if not found
  117966. */
  117967. getCameraByID(id: string): Nullable<Camera>;
  117968. /**
  117969. * Gets a camera using its unique id
  117970. * @param uniqueId defines the unique id to look for
  117971. * @returns the camera or null if not found
  117972. */
  117973. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  117974. /**
  117975. * Gets a camera using its name
  117976. * @param name defines the camera's name
  117977. * @return the camera or null if none found.
  117978. */
  117979. getCameraByName(name: string): Nullable<Camera>;
  117980. /**
  117981. * Gets a bone using its id
  117982. * @param id defines the bone's id
  117983. * @return the bone or null if not found
  117984. */
  117985. getBoneByID(id: string): Nullable<Bone>;
  117986. /**
  117987. * Gets a bone using its id
  117988. * @param name defines the bone's name
  117989. * @return the bone or null if not found
  117990. */
  117991. getBoneByName(name: string): Nullable<Bone>;
  117992. /**
  117993. * Gets a light node using its name
  117994. * @param name defines the the light's name
  117995. * @return the light or null if none found.
  117996. */
  117997. getLightByName(name: string): Nullable<Light>;
  117998. /**
  117999. * Gets a light node using its id
  118000. * @param id defines the light's id
  118001. * @return the light or null if none found.
  118002. */
  118003. getLightByID(id: string): Nullable<Light>;
  118004. /**
  118005. * Gets a light node using its scene-generated unique ID
  118006. * @param uniqueId defines the light's unique id
  118007. * @return the light or null if none found.
  118008. */
  118009. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  118010. /**
  118011. * Gets a particle system by id
  118012. * @param id defines the particle system id
  118013. * @return the corresponding system or null if none found
  118014. */
  118015. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  118016. /**
  118017. * Gets a geometry using its ID
  118018. * @param id defines the geometry's id
  118019. * @return the geometry or null if none found.
  118020. */
  118021. getGeometryByID(id: string): Nullable<Geometry>;
  118022. private _getGeometryByUniqueID;
  118023. /**
  118024. * Add a new geometry to this scene
  118025. * @param geometry defines the geometry to be added to the scene.
  118026. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  118027. * @return a boolean defining if the geometry was added or not
  118028. */
  118029. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  118030. /**
  118031. * Removes an existing geometry
  118032. * @param geometry defines the geometry to be removed from the scene
  118033. * @return a boolean defining if the geometry was removed or not
  118034. */
  118035. removeGeometry(geometry: Geometry): boolean;
  118036. /**
  118037. * Gets the list of geometries attached to the scene
  118038. * @returns an array of Geometry
  118039. */
  118040. getGeometries(): Geometry[];
  118041. /**
  118042. * Gets the first added mesh found of a given ID
  118043. * @param id defines the id to search for
  118044. * @return the mesh found or null if not found at all
  118045. */
  118046. getMeshByID(id: string): Nullable<AbstractMesh>;
  118047. /**
  118048. * Gets a list of meshes using their id
  118049. * @param id defines the id to search for
  118050. * @returns a list of meshes
  118051. */
  118052. getMeshesByID(id: string): Array<AbstractMesh>;
  118053. /**
  118054. * Gets the first added transform node found of a given ID
  118055. * @param id defines the id to search for
  118056. * @return the found transform node or null if not found at all.
  118057. */
  118058. getTransformNodeByID(id: string): Nullable<TransformNode>;
  118059. /**
  118060. * Gets a transform node with its auto-generated unique id
  118061. * @param uniqueId efines the unique id to search for
  118062. * @return the found transform node or null if not found at all.
  118063. */
  118064. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  118065. /**
  118066. * Gets a list of transform nodes using their id
  118067. * @param id defines the id to search for
  118068. * @returns a list of transform nodes
  118069. */
  118070. getTransformNodesByID(id: string): Array<TransformNode>;
  118071. /**
  118072. * Gets a mesh with its auto-generated unique id
  118073. * @param uniqueId defines the unique id to search for
  118074. * @return the found mesh or null if not found at all.
  118075. */
  118076. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  118077. /**
  118078. * Gets a the last added mesh using a given id
  118079. * @param id defines the id to search for
  118080. * @return the found mesh or null if not found at all.
  118081. */
  118082. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  118083. /**
  118084. * Gets a the last added node (Mesh, Camera, Light) using a given id
  118085. * @param id defines the id to search for
  118086. * @return the found node or null if not found at all
  118087. */
  118088. getLastEntryByID(id: string): Nullable<Node>;
  118089. /**
  118090. * Gets a node (Mesh, Camera, Light) using a given id
  118091. * @param id defines the id to search for
  118092. * @return the found node or null if not found at all
  118093. */
  118094. getNodeByID(id: string): Nullable<Node>;
  118095. /**
  118096. * Gets a node (Mesh, Camera, Light) using a given name
  118097. * @param name defines the name to search for
  118098. * @return the found node or null if not found at all.
  118099. */
  118100. getNodeByName(name: string): Nullable<Node>;
  118101. /**
  118102. * Gets a mesh using a given name
  118103. * @param name defines the name to search for
  118104. * @return the found mesh or null if not found at all.
  118105. */
  118106. getMeshByName(name: string): Nullable<AbstractMesh>;
  118107. /**
  118108. * Gets a transform node using a given name
  118109. * @param name defines the name to search for
  118110. * @return the found transform node or null if not found at all.
  118111. */
  118112. getTransformNodeByName(name: string): Nullable<TransformNode>;
  118113. /**
  118114. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  118115. * @param id defines the id to search for
  118116. * @return the found skeleton or null if not found at all.
  118117. */
  118118. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  118119. /**
  118120. * Gets a skeleton using a given auto generated unique id
  118121. * @param uniqueId defines the unique id to search for
  118122. * @return the found skeleton or null if not found at all.
  118123. */
  118124. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  118125. /**
  118126. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  118127. * @param id defines the id to search for
  118128. * @return the found skeleton or null if not found at all.
  118129. */
  118130. getSkeletonById(id: string): Nullable<Skeleton>;
  118131. /**
  118132. * Gets a skeleton using a given name
  118133. * @param name defines the name to search for
  118134. * @return the found skeleton or null if not found at all.
  118135. */
  118136. getSkeletonByName(name: string): Nullable<Skeleton>;
  118137. /**
  118138. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  118139. * @param id defines the id to search for
  118140. * @return the found morph target manager or null if not found at all.
  118141. */
  118142. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  118143. /**
  118144. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  118145. * @param id defines the id to search for
  118146. * @return the found morph target or null if not found at all.
  118147. */
  118148. getMorphTargetById(id: string): Nullable<MorphTarget>;
  118149. /**
  118150. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  118151. * @param name defines the name to search for
  118152. * @return the found morph target or null if not found at all.
  118153. */
  118154. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  118155. /**
  118156. * Gets a boolean indicating if the given mesh is active
  118157. * @param mesh defines the mesh to look for
  118158. * @returns true if the mesh is in the active list
  118159. */
  118160. isActiveMesh(mesh: AbstractMesh): boolean;
  118161. /**
  118162. * Return a unique id as a string which can serve as an identifier for the scene
  118163. */
  118164. get uid(): string;
  118165. /**
  118166. * Add an externaly attached data from its key.
  118167. * This method call will fail and return false, if such key already exists.
  118168. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  118169. * @param key the unique key that identifies the data
  118170. * @param data the data object to associate to the key for this Engine instance
  118171. * @return true if no such key were already present and the data was added successfully, false otherwise
  118172. */
  118173. addExternalData<T>(key: string, data: T): boolean;
  118174. /**
  118175. * Get an externaly attached data from its key
  118176. * @param key the unique key that identifies the data
  118177. * @return the associated data, if present (can be null), or undefined if not present
  118178. */
  118179. getExternalData<T>(key: string): Nullable<T>;
  118180. /**
  118181. * Get an externaly attached data from its key, create it using a factory if it's not already present
  118182. * @param key the unique key that identifies the data
  118183. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  118184. * @return the associated data, can be null if the factory returned null.
  118185. */
  118186. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  118187. /**
  118188. * Remove an externaly attached data from the Engine instance
  118189. * @param key the unique key that identifies the data
  118190. * @return true if the data was successfully removed, false if it doesn't exist
  118191. */
  118192. removeExternalData(key: string): boolean;
  118193. private _evaluateSubMesh;
  118194. /**
  118195. * Clear the processed materials smart array preventing retention point in material dispose.
  118196. */
  118197. freeProcessedMaterials(): void;
  118198. private _preventFreeActiveMeshesAndRenderingGroups;
  118199. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  118200. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  118201. * when disposing several meshes in a row or a hierarchy of meshes.
  118202. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  118203. */
  118204. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  118205. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  118206. /**
  118207. * Clear the active meshes smart array preventing retention point in mesh dispose.
  118208. */
  118209. freeActiveMeshes(): void;
  118210. /**
  118211. * Clear the info related to rendering groups preventing retention points during dispose.
  118212. */
  118213. freeRenderingGroups(): void;
  118214. /** @hidden */
  118215. _isInIntermediateRendering(): boolean;
  118216. /**
  118217. * Lambda returning the list of potentially active meshes.
  118218. */
  118219. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  118220. /**
  118221. * Lambda returning the list of potentially active sub meshes.
  118222. */
  118223. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  118224. /**
  118225. * Lambda returning the list of potentially intersecting sub meshes.
  118226. */
  118227. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  118228. /**
  118229. * Lambda returning the list of potentially colliding sub meshes.
  118230. */
  118231. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  118232. private _activeMeshesFrozen;
  118233. private _skipEvaluateActiveMeshesCompletely;
  118234. /**
  118235. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  118236. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  118237. * @returns the current scene
  118238. */
  118239. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  118240. /**
  118241. * Use this function to restart evaluating active meshes on every frame
  118242. * @returns the current scene
  118243. */
  118244. unfreezeActiveMeshes(): Scene;
  118245. private _evaluateActiveMeshes;
  118246. private _activeMesh;
  118247. /**
  118248. * Update the transform matrix to update from the current active camera
  118249. * @param force defines a boolean used to force the update even if cache is up to date
  118250. */
  118251. updateTransformMatrix(force?: boolean): void;
  118252. private _bindFrameBuffer;
  118253. /** @hidden */
  118254. _allowPostProcessClearColor: boolean;
  118255. /** @hidden */
  118256. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  118257. private _processSubCameras;
  118258. private _checkIntersections;
  118259. /** @hidden */
  118260. _advancePhysicsEngineStep(step: number): void;
  118261. /**
  118262. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  118263. */
  118264. getDeterministicFrameTime: () => number;
  118265. /** @hidden */
  118266. _animate(): void;
  118267. /** Execute all animations (for a frame) */
  118268. animate(): void;
  118269. /**
  118270. * Render the scene
  118271. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  118272. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  118273. */
  118274. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  118275. /**
  118276. * Freeze all materials
  118277. * A frozen material will not be updatable but should be faster to render
  118278. */
  118279. freezeMaterials(): void;
  118280. /**
  118281. * Unfreeze all materials
  118282. * A frozen material will not be updatable but should be faster to render
  118283. */
  118284. unfreezeMaterials(): void;
  118285. /**
  118286. * Releases all held ressources
  118287. */
  118288. dispose(): void;
  118289. /**
  118290. * Gets if the scene is already disposed
  118291. */
  118292. get isDisposed(): boolean;
  118293. /**
  118294. * Call this function to reduce memory footprint of the scene.
  118295. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  118296. */
  118297. clearCachedVertexData(): void;
  118298. /**
  118299. * This function will remove the local cached buffer data from texture.
  118300. * It will save memory but will prevent the texture from being rebuilt
  118301. */
  118302. cleanCachedTextureBuffer(): void;
  118303. /**
  118304. * Get the world extend vectors with an optional filter
  118305. *
  118306. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  118307. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  118308. */
  118309. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  118310. min: Vector3;
  118311. max: Vector3;
  118312. };
  118313. /**
  118314. * Creates a ray that can be used to pick in the scene
  118315. * @param x defines the x coordinate of the origin (on-screen)
  118316. * @param y defines the y coordinate of the origin (on-screen)
  118317. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  118318. * @param camera defines the camera to use for the picking
  118319. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  118320. * @returns a Ray
  118321. */
  118322. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  118323. /**
  118324. * Creates a ray that can be used to pick in the scene
  118325. * @param x defines the x coordinate of the origin (on-screen)
  118326. * @param y defines the y coordinate of the origin (on-screen)
  118327. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  118328. * @param result defines the ray where to store the picking ray
  118329. * @param camera defines the camera to use for the picking
  118330. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  118331. * @returns the current scene
  118332. */
  118333. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  118334. /**
  118335. * Creates a ray that can be used to pick in the scene
  118336. * @param x defines the x coordinate of the origin (on-screen)
  118337. * @param y defines the y coordinate of the origin (on-screen)
  118338. * @param camera defines the camera to use for the picking
  118339. * @returns a Ray
  118340. */
  118341. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  118342. /**
  118343. * Creates a ray that can be used to pick in the scene
  118344. * @param x defines the x coordinate of the origin (on-screen)
  118345. * @param y defines the y coordinate of the origin (on-screen)
  118346. * @param result defines the ray where to store the picking ray
  118347. * @param camera defines the camera to use for the picking
  118348. * @returns the current scene
  118349. */
  118350. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  118351. /** Launch a ray to try to pick a mesh in the scene
  118352. * @param x position on screen
  118353. * @param y position on screen
  118354. * @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
  118355. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118356. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118357. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118358. * @returns a PickingInfo
  118359. */
  118360. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  118361. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  118362. * @param x position on screen
  118363. * @param y position on screen
  118364. * @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
  118365. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118366. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118367. * @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)
  118368. */
  118369. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  118370. /** Use the given ray to pick a mesh in the scene
  118371. * @param ray The ray to use to pick meshes
  118372. * @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
  118373. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118374. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118375. * @returns a PickingInfo
  118376. */
  118377. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  118378. /**
  118379. * Launch a ray to try to pick a mesh in the scene
  118380. * @param x X position on screen
  118381. * @param y Y position on screen
  118382. * @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
  118383. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118384. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118385. * @returns an array of PickingInfo
  118386. */
  118387. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  118388. /**
  118389. * Launch a ray to try to pick a mesh in the scene
  118390. * @param ray Ray to use
  118391. * @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
  118392. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118393. * @returns an array of PickingInfo
  118394. */
  118395. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  118396. /**
  118397. * Force the value of meshUnderPointer
  118398. * @param mesh defines the mesh to use
  118399. */
  118400. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  118401. /**
  118402. * Gets the mesh under the pointer
  118403. * @returns a Mesh or null if no mesh is under the pointer
  118404. */
  118405. getPointerOverMesh(): Nullable<AbstractMesh>;
  118406. /** @hidden */
  118407. _rebuildGeometries(): void;
  118408. /** @hidden */
  118409. _rebuildTextures(): void;
  118410. private _getByTags;
  118411. /**
  118412. * Get a list of meshes by tags
  118413. * @param tagsQuery defines the tags query to use
  118414. * @param forEach defines a predicate used to filter results
  118415. * @returns an array of Mesh
  118416. */
  118417. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  118418. /**
  118419. * Get a list of cameras by tags
  118420. * @param tagsQuery defines the tags query to use
  118421. * @param forEach defines a predicate used to filter results
  118422. * @returns an array of Camera
  118423. */
  118424. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  118425. /**
  118426. * Get a list of lights by tags
  118427. * @param tagsQuery defines the tags query to use
  118428. * @param forEach defines a predicate used to filter results
  118429. * @returns an array of Light
  118430. */
  118431. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  118432. /**
  118433. * Get a list of materials by tags
  118434. * @param tagsQuery defines the tags query to use
  118435. * @param forEach defines a predicate used to filter results
  118436. * @returns an array of Material
  118437. */
  118438. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  118439. /**
  118440. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  118441. * This allowed control for front to back rendering or reversly depending of the special needs.
  118442. *
  118443. * @param renderingGroupId The rendering group id corresponding to its index
  118444. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  118445. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  118446. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  118447. */
  118448. 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;
  118449. /**
  118450. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  118451. *
  118452. * @param renderingGroupId The rendering group id corresponding to its index
  118453. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118454. * @param depth Automatically clears depth between groups if true and autoClear is true.
  118455. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  118456. */
  118457. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  118458. /**
  118459. * Gets the current auto clear configuration for one rendering group of the rendering
  118460. * manager.
  118461. * @param index the rendering group index to get the information for
  118462. * @returns The auto clear setup for the requested rendering group
  118463. */
  118464. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  118465. private _blockMaterialDirtyMechanism;
  118466. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  118467. get blockMaterialDirtyMechanism(): boolean;
  118468. set blockMaterialDirtyMechanism(value: boolean);
  118469. /**
  118470. * Will flag all materials as dirty to trigger new shader compilation
  118471. * @param flag defines the flag used to specify which material part must be marked as dirty
  118472. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  118473. */
  118474. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  118475. /** @hidden */
  118476. _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;
  118477. /** @hidden */
  118478. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118479. /** @hidden */
  118480. _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;
  118481. /** @hidden */
  118482. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  118483. /** @hidden */
  118484. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118485. /** @hidden */
  118486. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118487. }
  118488. }
  118489. declare module BABYLON {
  118490. /**
  118491. * Set of assets to keep when moving a scene into an asset container.
  118492. */
  118493. export class KeepAssets extends AbstractScene {
  118494. }
  118495. /**
  118496. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  118497. */
  118498. export class InstantiatedEntries {
  118499. /**
  118500. * List of new root nodes (eg. nodes with no parent)
  118501. */
  118502. rootNodes: TransformNode[];
  118503. /**
  118504. * List of new skeletons
  118505. */
  118506. skeletons: Skeleton[];
  118507. /**
  118508. * List of new animation groups
  118509. */
  118510. animationGroups: AnimationGroup[];
  118511. }
  118512. /**
  118513. * Container with a set of assets that can be added or removed from a scene.
  118514. */
  118515. export class AssetContainer extends AbstractScene {
  118516. private _wasAddedToScene;
  118517. /**
  118518. * The scene the AssetContainer belongs to.
  118519. */
  118520. scene: Scene;
  118521. /**
  118522. * Instantiates an AssetContainer.
  118523. * @param scene The scene the AssetContainer belongs to.
  118524. */
  118525. constructor(scene: Scene);
  118526. /**
  118527. * Instantiate or clone all meshes and add the new ones to the scene.
  118528. * Skeletons and animation groups will all be cloned
  118529. * @param nameFunction defines an optional function used to get new names for clones
  118530. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  118531. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  118532. */
  118533. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  118534. /**
  118535. * Adds all the assets from the container to the scene.
  118536. */
  118537. addAllToScene(): void;
  118538. /**
  118539. * Removes all the assets in the container from the scene
  118540. */
  118541. removeAllFromScene(): void;
  118542. /**
  118543. * Disposes all the assets in the container
  118544. */
  118545. dispose(): void;
  118546. private _moveAssets;
  118547. /**
  118548. * Removes all the assets contained in the scene and adds them to the container.
  118549. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  118550. */
  118551. moveAllFromScene(keepAssets?: KeepAssets): void;
  118552. /**
  118553. * 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.
  118554. * @returns the root mesh
  118555. */
  118556. createRootMesh(): Mesh;
  118557. /**
  118558. * Merge animations (direct and animation groups) from this asset container into a scene
  118559. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118560. * @param animatables set of animatables to retarget to a node from the scene
  118561. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  118562. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  118563. */
  118564. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  118565. }
  118566. }
  118567. declare module BABYLON {
  118568. /**
  118569. * Defines how the parser contract is defined.
  118570. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  118571. */
  118572. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  118573. /**
  118574. * Defines how the individual parser contract is defined.
  118575. * These parser can parse an individual asset
  118576. */
  118577. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  118578. /**
  118579. * Base class of the scene acting as a container for the different elements composing a scene.
  118580. * This class is dynamically extended by the different components of the scene increasing
  118581. * flexibility and reducing coupling
  118582. */
  118583. export abstract class AbstractScene {
  118584. /**
  118585. * Stores the list of available parsers in the application.
  118586. */
  118587. private static _BabylonFileParsers;
  118588. /**
  118589. * Stores the list of available individual parsers in the application.
  118590. */
  118591. private static _IndividualBabylonFileParsers;
  118592. /**
  118593. * Adds a parser in the list of available ones
  118594. * @param name Defines the name of the parser
  118595. * @param parser Defines the parser to add
  118596. */
  118597. static AddParser(name: string, parser: BabylonFileParser): void;
  118598. /**
  118599. * Gets a general parser from the list of avaialble ones
  118600. * @param name Defines the name of the parser
  118601. * @returns the requested parser or null
  118602. */
  118603. static GetParser(name: string): Nullable<BabylonFileParser>;
  118604. /**
  118605. * Adds n individual parser in the list of available ones
  118606. * @param name Defines the name of the parser
  118607. * @param parser Defines the parser to add
  118608. */
  118609. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  118610. /**
  118611. * Gets an individual parser from the list of avaialble ones
  118612. * @param name Defines the name of the parser
  118613. * @returns the requested parser or null
  118614. */
  118615. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  118616. /**
  118617. * Parser json data and populate both a scene and its associated container object
  118618. * @param jsonData Defines the data to parse
  118619. * @param scene Defines the scene to parse the data for
  118620. * @param container Defines the container attached to the parsing sequence
  118621. * @param rootUrl Defines the root url of the data
  118622. */
  118623. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  118624. /**
  118625. * Gets the list of root nodes (ie. nodes with no parent)
  118626. */
  118627. rootNodes: Node[];
  118628. /** All of the cameras added to this scene
  118629. * @see https://doc.babylonjs.com/babylon101/cameras
  118630. */
  118631. cameras: Camera[];
  118632. /**
  118633. * All of the lights added to this scene
  118634. * @see https://doc.babylonjs.com/babylon101/lights
  118635. */
  118636. lights: Light[];
  118637. /**
  118638. * All of the (abstract) meshes added to this scene
  118639. */
  118640. meshes: AbstractMesh[];
  118641. /**
  118642. * The list of skeletons added to the scene
  118643. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  118644. */
  118645. skeletons: Skeleton[];
  118646. /**
  118647. * All of the particle systems added to this scene
  118648. * @see https://doc.babylonjs.com/babylon101/particles
  118649. */
  118650. particleSystems: IParticleSystem[];
  118651. /**
  118652. * Gets a list of Animations associated with the scene
  118653. */
  118654. animations: Animation[];
  118655. /**
  118656. * All of the animation groups added to this scene
  118657. * @see https://doc.babylonjs.com/how_to/group
  118658. */
  118659. animationGroups: AnimationGroup[];
  118660. /**
  118661. * All of the multi-materials added to this scene
  118662. * @see https://doc.babylonjs.com/how_to/multi_materials
  118663. */
  118664. multiMaterials: MultiMaterial[];
  118665. /**
  118666. * All of the materials added to this scene
  118667. * In the context of a Scene, it is not supposed to be modified manually.
  118668. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  118669. * Note also that the order of the Material within the array is not significant and might change.
  118670. * @see https://doc.babylonjs.com/babylon101/materials
  118671. */
  118672. materials: Material[];
  118673. /**
  118674. * The list of morph target managers added to the scene
  118675. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  118676. */
  118677. morphTargetManagers: MorphTargetManager[];
  118678. /**
  118679. * The list of geometries used in the scene.
  118680. */
  118681. geometries: Geometry[];
  118682. /**
  118683. * All of the tranform nodes added to this scene
  118684. * In the context of a Scene, it is not supposed to be modified manually.
  118685. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  118686. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  118687. * @see https://doc.babylonjs.com/how_to/transformnode
  118688. */
  118689. transformNodes: TransformNode[];
  118690. /**
  118691. * ActionManagers available on the scene.
  118692. */
  118693. actionManagers: AbstractActionManager[];
  118694. /**
  118695. * Textures to keep.
  118696. */
  118697. textures: BaseTexture[];
  118698. /**
  118699. * Environment texture for the scene
  118700. */
  118701. environmentTexture: Nullable<BaseTexture>;
  118702. /**
  118703. * @returns all meshes, lights, cameras, transformNodes and bones
  118704. */
  118705. getNodes(): Array<Node>;
  118706. }
  118707. }
  118708. declare module BABYLON {
  118709. /**
  118710. * Interface used to define options for Sound class
  118711. */
  118712. export interface ISoundOptions {
  118713. /**
  118714. * Does the sound autoplay once loaded.
  118715. */
  118716. autoplay?: boolean;
  118717. /**
  118718. * Does the sound loop after it finishes playing once.
  118719. */
  118720. loop?: boolean;
  118721. /**
  118722. * Sound's volume
  118723. */
  118724. volume?: number;
  118725. /**
  118726. * Is it a spatial sound?
  118727. */
  118728. spatialSound?: boolean;
  118729. /**
  118730. * Maximum distance to hear that sound
  118731. */
  118732. maxDistance?: number;
  118733. /**
  118734. * Uses user defined attenuation function
  118735. */
  118736. useCustomAttenuation?: boolean;
  118737. /**
  118738. * Define the roll off factor of spatial sounds.
  118739. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118740. */
  118741. rolloffFactor?: number;
  118742. /**
  118743. * Define the reference distance the sound should be heard perfectly.
  118744. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118745. */
  118746. refDistance?: number;
  118747. /**
  118748. * Define the distance attenuation model the sound will follow.
  118749. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118750. */
  118751. distanceModel?: string;
  118752. /**
  118753. * Defines the playback speed (1 by default)
  118754. */
  118755. playbackRate?: number;
  118756. /**
  118757. * Defines if the sound is from a streaming source
  118758. */
  118759. streaming?: boolean;
  118760. /**
  118761. * Defines an optional length (in seconds) inside the sound file
  118762. */
  118763. length?: number;
  118764. /**
  118765. * Defines an optional offset (in seconds) inside the sound file
  118766. */
  118767. offset?: number;
  118768. /**
  118769. * If true, URLs will not be required to state the audio file codec to use.
  118770. */
  118771. skipCodecCheck?: boolean;
  118772. }
  118773. /**
  118774. * Defines a sound that can be played in the application.
  118775. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  118776. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118777. */
  118778. export class Sound {
  118779. /**
  118780. * The name of the sound in the scene.
  118781. */
  118782. name: string;
  118783. /**
  118784. * Does the sound autoplay once loaded.
  118785. */
  118786. autoplay: boolean;
  118787. /**
  118788. * Does the sound loop after it finishes playing once.
  118789. */
  118790. loop: boolean;
  118791. /**
  118792. * Does the sound use a custom attenuation curve to simulate the falloff
  118793. * happening when the source gets further away from the camera.
  118794. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118795. */
  118796. useCustomAttenuation: boolean;
  118797. /**
  118798. * The sound track id this sound belongs to.
  118799. */
  118800. soundTrackId: number;
  118801. /**
  118802. * Is this sound currently played.
  118803. */
  118804. isPlaying: boolean;
  118805. /**
  118806. * Is this sound currently paused.
  118807. */
  118808. isPaused: boolean;
  118809. /**
  118810. * Does this sound enables spatial sound.
  118811. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118812. */
  118813. spatialSound: boolean;
  118814. /**
  118815. * Define the reference distance the sound should be heard perfectly.
  118816. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118817. */
  118818. refDistance: number;
  118819. /**
  118820. * Define the roll off factor of spatial sounds.
  118821. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118822. */
  118823. rolloffFactor: number;
  118824. /**
  118825. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  118826. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118827. */
  118828. maxDistance: number;
  118829. /**
  118830. * Define the distance attenuation model the sound will follow.
  118831. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118832. */
  118833. distanceModel: string;
  118834. /**
  118835. * @hidden
  118836. * Back Compat
  118837. **/
  118838. onended: () => any;
  118839. /**
  118840. * Gets or sets an object used to store user defined information for the sound.
  118841. */
  118842. metadata: any;
  118843. /**
  118844. * Observable event when the current playing sound finishes.
  118845. */
  118846. onEndedObservable: Observable<Sound>;
  118847. private _panningModel;
  118848. private _playbackRate;
  118849. private _streaming;
  118850. private _startTime;
  118851. private _startOffset;
  118852. private _position;
  118853. /** @hidden */
  118854. _positionInEmitterSpace: boolean;
  118855. private _localDirection;
  118856. private _volume;
  118857. private _isReadyToPlay;
  118858. private _isDirectional;
  118859. private _readyToPlayCallback;
  118860. private _audioBuffer;
  118861. private _soundSource;
  118862. private _streamingSource;
  118863. private _soundPanner;
  118864. private _soundGain;
  118865. private _inputAudioNode;
  118866. private _outputAudioNode;
  118867. private _coneInnerAngle;
  118868. private _coneOuterAngle;
  118869. private _coneOuterGain;
  118870. private _scene;
  118871. private _connectedTransformNode;
  118872. private _customAttenuationFunction;
  118873. private _registerFunc;
  118874. private _isOutputConnected;
  118875. private _htmlAudioElement;
  118876. private _urlType;
  118877. private _length?;
  118878. private _offset?;
  118879. /** @hidden */
  118880. static _SceneComponentInitialization: (scene: Scene) => void;
  118881. /**
  118882. * Create a sound and attach it to a scene
  118883. * @param name Name of your sound
  118884. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  118885. * @param scene defines the scene the sound belongs to
  118886. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  118887. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  118888. */
  118889. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  118890. /**
  118891. * Release the sound and its associated resources
  118892. */
  118893. dispose(): void;
  118894. /**
  118895. * Gets if the sounds is ready to be played or not.
  118896. * @returns true if ready, otherwise false
  118897. */
  118898. isReady(): boolean;
  118899. private _soundLoaded;
  118900. /**
  118901. * Sets the data of the sound from an audiobuffer
  118902. * @param audioBuffer The audioBuffer containing the data
  118903. */
  118904. setAudioBuffer(audioBuffer: AudioBuffer): void;
  118905. /**
  118906. * Updates the current sounds options such as maxdistance, loop...
  118907. * @param options A JSON object containing values named as the object properties
  118908. */
  118909. updateOptions(options: ISoundOptions): void;
  118910. private _createSpatialParameters;
  118911. private _updateSpatialParameters;
  118912. /**
  118913. * Switch the panning model to HRTF:
  118914. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118915. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118916. */
  118917. switchPanningModelToHRTF(): void;
  118918. /**
  118919. * Switch the panning model to Equal Power:
  118920. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118921. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118922. */
  118923. switchPanningModelToEqualPower(): void;
  118924. private _switchPanningModel;
  118925. /**
  118926. * Connect this sound to a sound track audio node like gain...
  118927. * @param soundTrackAudioNode the sound track audio node to connect to
  118928. */
  118929. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  118930. /**
  118931. * Transform this sound into a directional source
  118932. * @param coneInnerAngle Size of the inner cone in degree
  118933. * @param coneOuterAngle Size of the outer cone in degree
  118934. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  118935. */
  118936. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  118937. /**
  118938. * Gets or sets the inner angle for the directional cone.
  118939. */
  118940. get directionalConeInnerAngle(): number;
  118941. /**
  118942. * Gets or sets the inner angle for the directional cone.
  118943. */
  118944. set directionalConeInnerAngle(value: number);
  118945. /**
  118946. * Gets or sets the outer angle for the directional cone.
  118947. */
  118948. get directionalConeOuterAngle(): number;
  118949. /**
  118950. * Gets or sets the outer angle for the directional cone.
  118951. */
  118952. set directionalConeOuterAngle(value: number);
  118953. /**
  118954. * Sets the position of the emitter if spatial sound is enabled
  118955. * @param newPosition Defines the new posisiton
  118956. */
  118957. setPosition(newPosition: Vector3): void;
  118958. /**
  118959. * Sets the local direction of the emitter if spatial sound is enabled
  118960. * @param newLocalDirection Defines the new local direction
  118961. */
  118962. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  118963. private _updateDirection;
  118964. /** @hidden */
  118965. updateDistanceFromListener(): void;
  118966. /**
  118967. * Sets a new custom attenuation function for the sound.
  118968. * @param callback Defines the function used for the attenuation
  118969. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118970. */
  118971. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  118972. /**
  118973. * Play the sound
  118974. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  118975. * @param offset (optional) Start the sound at a specific time in seconds
  118976. * @param length (optional) Sound duration (in seconds)
  118977. */
  118978. play(time?: number, offset?: number, length?: number): void;
  118979. private _onended;
  118980. /**
  118981. * Stop the sound
  118982. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  118983. */
  118984. stop(time?: number): void;
  118985. /**
  118986. * Put the sound in pause
  118987. */
  118988. pause(): void;
  118989. /**
  118990. * Sets a dedicated volume for this sounds
  118991. * @param newVolume Define the new volume of the sound
  118992. * @param time Define time for gradual change to new volume
  118993. */
  118994. setVolume(newVolume: number, time?: number): void;
  118995. /**
  118996. * Set the sound play back rate
  118997. * @param newPlaybackRate Define the playback rate the sound should be played at
  118998. */
  118999. setPlaybackRate(newPlaybackRate: number): void;
  119000. /**
  119001. * Gets the volume of the sound.
  119002. * @returns the volume of the sound
  119003. */
  119004. getVolume(): number;
  119005. /**
  119006. * Attach the sound to a dedicated mesh
  119007. * @param transformNode The transform node to connect the sound with
  119008. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  119009. */
  119010. attachToMesh(transformNode: TransformNode): void;
  119011. /**
  119012. * Detach the sound from the previously attached mesh
  119013. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  119014. */
  119015. detachFromMesh(): void;
  119016. private _onRegisterAfterWorldMatrixUpdate;
  119017. /**
  119018. * Clone the current sound in the scene.
  119019. * @returns the new sound clone
  119020. */
  119021. clone(): Nullable<Sound>;
  119022. /**
  119023. * Gets the current underlying audio buffer containing the data
  119024. * @returns the audio buffer
  119025. */
  119026. getAudioBuffer(): Nullable<AudioBuffer>;
  119027. /**
  119028. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  119029. * @returns the source node
  119030. */
  119031. getSoundSource(): Nullable<AudioBufferSourceNode>;
  119032. /**
  119033. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  119034. * @returns the gain node
  119035. */
  119036. getSoundGain(): Nullable<GainNode>;
  119037. /**
  119038. * Serializes the Sound in a JSON representation
  119039. * @returns the JSON representation of the sound
  119040. */
  119041. serialize(): any;
  119042. /**
  119043. * Parse a JSON representation of a sound to innstantiate in a given scene
  119044. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  119045. * @param scene Define the scene the new parsed sound should be created in
  119046. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  119047. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  119048. * @returns the newly parsed sound
  119049. */
  119050. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  119051. }
  119052. }
  119053. declare module BABYLON {
  119054. /**
  119055. * This defines an action helpful to play a defined sound on a triggered action.
  119056. */
  119057. export class PlaySoundAction extends Action {
  119058. private _sound;
  119059. /**
  119060. * Instantiate the action
  119061. * @param triggerOptions defines the trigger options
  119062. * @param sound defines the sound to play
  119063. * @param condition defines the trigger related conditions
  119064. */
  119065. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  119066. /** @hidden */
  119067. _prepare(): void;
  119068. /**
  119069. * Execute the action and play the sound.
  119070. */
  119071. execute(): void;
  119072. /**
  119073. * Serializes the actions and its related information.
  119074. * @param parent defines the object to serialize in
  119075. * @returns the serialized object
  119076. */
  119077. serialize(parent: any): any;
  119078. }
  119079. /**
  119080. * This defines an action helpful to stop a defined sound on a triggered action.
  119081. */
  119082. export class StopSoundAction extends Action {
  119083. private _sound;
  119084. /**
  119085. * Instantiate the action
  119086. * @param triggerOptions defines the trigger options
  119087. * @param sound defines the sound to stop
  119088. * @param condition defines the trigger related conditions
  119089. */
  119090. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  119091. /** @hidden */
  119092. _prepare(): void;
  119093. /**
  119094. * Execute the action and stop the sound.
  119095. */
  119096. execute(): void;
  119097. /**
  119098. * Serializes the actions and its related information.
  119099. * @param parent defines the object to serialize in
  119100. * @returns the serialized object
  119101. */
  119102. serialize(parent: any): any;
  119103. }
  119104. }
  119105. declare module BABYLON {
  119106. /**
  119107. * This defines an action responsible to change the value of a property
  119108. * by interpolating between its current value and the newly set one once triggered.
  119109. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  119110. */
  119111. export class InterpolateValueAction extends Action {
  119112. /**
  119113. * Defines the path of the property where the value should be interpolated
  119114. */
  119115. propertyPath: string;
  119116. /**
  119117. * Defines the target value at the end of the interpolation.
  119118. */
  119119. value: any;
  119120. /**
  119121. * Defines the time it will take for the property to interpolate to the value.
  119122. */
  119123. duration: number;
  119124. /**
  119125. * Defines if the other scene animations should be stopped when the action has been triggered
  119126. */
  119127. stopOtherAnimations?: boolean;
  119128. /**
  119129. * Defines a callback raised once the interpolation animation has been done.
  119130. */
  119131. onInterpolationDone?: () => void;
  119132. /**
  119133. * Observable triggered once the interpolation animation has been done.
  119134. */
  119135. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  119136. private _target;
  119137. private _effectiveTarget;
  119138. private _property;
  119139. /**
  119140. * Instantiate the action
  119141. * @param triggerOptions defines the trigger options
  119142. * @param target defines the object containing the value to interpolate
  119143. * @param propertyPath defines the path to the property in the target object
  119144. * @param value defines the target value at the end of the interpolation
  119145. * @param duration deines the time it will take for the property to interpolate to the value.
  119146. * @param condition defines the trigger related conditions
  119147. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  119148. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  119149. */
  119150. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  119151. /** @hidden */
  119152. _prepare(): void;
  119153. /**
  119154. * Execute the action starts the value interpolation.
  119155. */
  119156. execute(): void;
  119157. /**
  119158. * Serializes the actions and its related information.
  119159. * @param parent defines the object to serialize in
  119160. * @returns the serialized object
  119161. */
  119162. serialize(parent: any): any;
  119163. }
  119164. }
  119165. declare module BABYLON {
  119166. /**
  119167. * Options allowed during the creation of a sound track.
  119168. */
  119169. export interface ISoundTrackOptions {
  119170. /**
  119171. * The volume the sound track should take during creation
  119172. */
  119173. volume?: number;
  119174. /**
  119175. * Define if the sound track is the main sound track of the scene
  119176. */
  119177. mainTrack?: boolean;
  119178. }
  119179. /**
  119180. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  119181. * It will be also used in a future release to apply effects on a specific track.
  119182. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  119183. */
  119184. export class SoundTrack {
  119185. /**
  119186. * The unique identifier of the sound track in the scene.
  119187. */
  119188. id: number;
  119189. /**
  119190. * The list of sounds included in the sound track.
  119191. */
  119192. soundCollection: Array<Sound>;
  119193. private _outputAudioNode;
  119194. private _scene;
  119195. private _connectedAnalyser;
  119196. private _options;
  119197. private _isInitialized;
  119198. /**
  119199. * Creates a new sound track.
  119200. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  119201. * @param scene Define the scene the sound track belongs to
  119202. * @param options
  119203. */
  119204. constructor(scene: Scene, options?: ISoundTrackOptions);
  119205. private _initializeSoundTrackAudioGraph;
  119206. /**
  119207. * Release the sound track and its associated resources
  119208. */
  119209. dispose(): void;
  119210. /**
  119211. * Adds a sound to this sound track
  119212. * @param sound define the cound to add
  119213. * @ignoreNaming
  119214. */
  119215. AddSound(sound: Sound): void;
  119216. /**
  119217. * Removes a sound to this sound track
  119218. * @param sound define the cound to remove
  119219. * @ignoreNaming
  119220. */
  119221. RemoveSound(sound: Sound): void;
  119222. /**
  119223. * Set a global volume for the full sound track.
  119224. * @param newVolume Define the new volume of the sound track
  119225. */
  119226. setVolume(newVolume: number): void;
  119227. /**
  119228. * Switch the panning model to HRTF:
  119229. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  119230. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119231. */
  119232. switchPanningModelToHRTF(): void;
  119233. /**
  119234. * Switch the panning model to Equal Power:
  119235. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  119236. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119237. */
  119238. switchPanningModelToEqualPower(): void;
  119239. /**
  119240. * Connect the sound track to an audio analyser allowing some amazing
  119241. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  119242. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  119243. * @param analyser The analyser to connect to the engine
  119244. */
  119245. connectToAnalyser(analyser: Analyser): void;
  119246. }
  119247. }
  119248. declare module BABYLON {
  119249. interface AbstractScene {
  119250. /**
  119251. * The list of sounds used in the scene.
  119252. */
  119253. sounds: Nullable<Array<Sound>>;
  119254. }
  119255. interface Scene {
  119256. /**
  119257. * @hidden
  119258. * Backing field
  119259. */
  119260. _mainSoundTrack: SoundTrack;
  119261. /**
  119262. * The main sound track played by the scene.
  119263. * It cotains your primary collection of sounds.
  119264. */
  119265. mainSoundTrack: SoundTrack;
  119266. /**
  119267. * The list of sound tracks added to the scene
  119268. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119269. */
  119270. soundTracks: Nullable<Array<SoundTrack>>;
  119271. /**
  119272. * Gets a sound using a given name
  119273. * @param name defines the name to search for
  119274. * @return the found sound or null if not found at all.
  119275. */
  119276. getSoundByName(name: string): Nullable<Sound>;
  119277. /**
  119278. * Gets or sets if audio support is enabled
  119279. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119280. */
  119281. audioEnabled: boolean;
  119282. /**
  119283. * Gets or sets if audio will be output to headphones
  119284. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119285. */
  119286. headphone: boolean;
  119287. /**
  119288. * Gets or sets custom audio listener position provider
  119289. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119290. */
  119291. audioListenerPositionProvider: Nullable<() => Vector3>;
  119292. /**
  119293. * Gets or sets a refresh rate when using 3D audio positioning
  119294. */
  119295. audioPositioningRefreshRate: number;
  119296. }
  119297. /**
  119298. * Defines the sound scene component responsible to manage any sounds
  119299. * in a given scene.
  119300. */
  119301. export class AudioSceneComponent implements ISceneSerializableComponent {
  119302. /**
  119303. * The component name helpfull to identify the component in the list of scene components.
  119304. */
  119305. readonly name: string;
  119306. /**
  119307. * The scene the component belongs to.
  119308. */
  119309. scene: Scene;
  119310. private _audioEnabled;
  119311. /**
  119312. * Gets whether audio is enabled or not.
  119313. * Please use related enable/disable method to switch state.
  119314. */
  119315. get audioEnabled(): boolean;
  119316. private _headphone;
  119317. /**
  119318. * Gets whether audio is outputing to headphone or not.
  119319. * Please use the according Switch methods to change output.
  119320. */
  119321. get headphone(): boolean;
  119322. /**
  119323. * Gets or sets a refresh rate when using 3D audio positioning
  119324. */
  119325. audioPositioningRefreshRate: number;
  119326. private _audioListenerPositionProvider;
  119327. /**
  119328. * Gets the current audio listener position provider
  119329. */
  119330. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  119331. /**
  119332. * Sets a custom listener position for all sounds in the scene
  119333. * By default, this is the position of the first active camera
  119334. */
  119335. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  119336. /**
  119337. * Creates a new instance of the component for the given scene
  119338. * @param scene Defines the scene to register the component in
  119339. */
  119340. constructor(scene: Scene);
  119341. /**
  119342. * Registers the component in a given scene
  119343. */
  119344. register(): void;
  119345. /**
  119346. * Rebuilds the elements related to this component in case of
  119347. * context lost for instance.
  119348. */
  119349. rebuild(): void;
  119350. /**
  119351. * Serializes the component data to the specified json object
  119352. * @param serializationObject The object to serialize to
  119353. */
  119354. serialize(serializationObject: any): void;
  119355. /**
  119356. * Adds all the elements from the container to the scene
  119357. * @param container the container holding the elements
  119358. */
  119359. addFromContainer(container: AbstractScene): void;
  119360. /**
  119361. * Removes all the elements in the container from the scene
  119362. * @param container contains the elements to remove
  119363. * @param dispose if the removed element should be disposed (default: false)
  119364. */
  119365. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119366. /**
  119367. * Disposes the component and the associated ressources.
  119368. */
  119369. dispose(): void;
  119370. /**
  119371. * Disables audio in the associated scene.
  119372. */
  119373. disableAudio(): void;
  119374. /**
  119375. * Enables audio in the associated scene.
  119376. */
  119377. enableAudio(): void;
  119378. /**
  119379. * Switch audio to headphone output.
  119380. */
  119381. switchAudioModeForHeadphones(): void;
  119382. /**
  119383. * Switch audio to normal speakers.
  119384. */
  119385. switchAudioModeForNormalSpeakers(): void;
  119386. private _cachedCameraDirection;
  119387. private _cachedCameraPosition;
  119388. private _lastCheck;
  119389. private _afterRender;
  119390. }
  119391. }
  119392. declare module BABYLON {
  119393. /**
  119394. * Wraps one or more Sound objects and selects one with random weight for playback.
  119395. */
  119396. export class WeightedSound {
  119397. /** When true a Sound will be selected and played when the current playing Sound completes. */
  119398. loop: boolean;
  119399. private _coneInnerAngle;
  119400. private _coneOuterAngle;
  119401. private _volume;
  119402. /** A Sound is currently playing. */
  119403. isPlaying: boolean;
  119404. /** A Sound is currently paused. */
  119405. isPaused: boolean;
  119406. private _sounds;
  119407. private _weights;
  119408. private _currentIndex?;
  119409. /**
  119410. * Creates a new WeightedSound from the list of sounds given.
  119411. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  119412. * @param sounds Array of Sounds that will be selected from.
  119413. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  119414. */
  119415. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  119416. /**
  119417. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  119418. */
  119419. get directionalConeInnerAngle(): number;
  119420. /**
  119421. * The size of cone in degress for a directional sound in which there will be no attenuation.
  119422. */
  119423. set directionalConeInnerAngle(value: number);
  119424. /**
  119425. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119426. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119427. */
  119428. get directionalConeOuterAngle(): number;
  119429. /**
  119430. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119431. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119432. */
  119433. set directionalConeOuterAngle(value: number);
  119434. /**
  119435. * Playback volume.
  119436. */
  119437. get volume(): number;
  119438. /**
  119439. * Playback volume.
  119440. */
  119441. set volume(value: number);
  119442. private _onended;
  119443. /**
  119444. * Suspend playback
  119445. */
  119446. pause(): void;
  119447. /**
  119448. * Stop playback
  119449. */
  119450. stop(): void;
  119451. /**
  119452. * Start playback.
  119453. * @param startOffset Position the clip head at a specific time in seconds.
  119454. */
  119455. play(startOffset?: number): void;
  119456. }
  119457. }
  119458. declare module BABYLON {
  119459. /**
  119460. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  119461. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119462. */
  119463. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  119464. /**
  119465. * Gets the name of the behavior.
  119466. */
  119467. get name(): string;
  119468. /**
  119469. * The easing function used by animations
  119470. */
  119471. static EasingFunction: BackEase;
  119472. /**
  119473. * The easing mode used by animations
  119474. */
  119475. static EasingMode: number;
  119476. /**
  119477. * The duration of the animation, in milliseconds
  119478. */
  119479. transitionDuration: number;
  119480. /**
  119481. * Length of the distance animated by the transition when lower radius is reached
  119482. */
  119483. lowerRadiusTransitionRange: number;
  119484. /**
  119485. * Length of the distance animated by the transition when upper radius is reached
  119486. */
  119487. upperRadiusTransitionRange: number;
  119488. private _autoTransitionRange;
  119489. /**
  119490. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119491. */
  119492. get autoTransitionRange(): boolean;
  119493. /**
  119494. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119495. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  119496. */
  119497. set autoTransitionRange(value: boolean);
  119498. private _attachedCamera;
  119499. private _onAfterCheckInputsObserver;
  119500. private _onMeshTargetChangedObserver;
  119501. /**
  119502. * Initializes the behavior.
  119503. */
  119504. init(): void;
  119505. /**
  119506. * Attaches the behavior to its arc rotate camera.
  119507. * @param camera Defines the camera to attach the behavior to
  119508. */
  119509. attach(camera: ArcRotateCamera): void;
  119510. /**
  119511. * Detaches the behavior from its current arc rotate camera.
  119512. */
  119513. detach(): void;
  119514. private _radiusIsAnimating;
  119515. private _radiusBounceTransition;
  119516. private _animatables;
  119517. private _cachedWheelPrecision;
  119518. /**
  119519. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  119520. * @param radiusLimit The limit to check against.
  119521. * @return Bool to indicate if at limit.
  119522. */
  119523. private _isRadiusAtLimit;
  119524. /**
  119525. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  119526. * @param radiusDelta The delta by which to animate to. Can be negative.
  119527. */
  119528. private _applyBoundRadiusAnimation;
  119529. /**
  119530. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  119531. */
  119532. protected _clearAnimationLocks(): void;
  119533. /**
  119534. * Stops and removes all animations that have been applied to the camera
  119535. */
  119536. stopAllAnimations(): void;
  119537. }
  119538. }
  119539. declare module BABYLON {
  119540. /**
  119541. * 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.
  119542. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119543. */
  119544. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  119545. /**
  119546. * Gets the name of the behavior.
  119547. */
  119548. get name(): string;
  119549. private _mode;
  119550. private _radiusScale;
  119551. private _positionScale;
  119552. private _defaultElevation;
  119553. private _elevationReturnTime;
  119554. private _elevationReturnWaitTime;
  119555. private _zoomStopsAnimation;
  119556. private _framingTime;
  119557. /**
  119558. * The easing function used by animations
  119559. */
  119560. static EasingFunction: ExponentialEase;
  119561. /**
  119562. * The easing mode used by animations
  119563. */
  119564. static EasingMode: number;
  119565. /**
  119566. * Sets the current mode used by the behavior
  119567. */
  119568. set mode(mode: number);
  119569. /**
  119570. * Gets current mode used by the behavior.
  119571. */
  119572. get mode(): number;
  119573. /**
  119574. * Sets the scale applied to the radius (1 by default)
  119575. */
  119576. set radiusScale(radius: number);
  119577. /**
  119578. * Gets the scale applied to the radius
  119579. */
  119580. get radiusScale(): number;
  119581. /**
  119582. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119583. */
  119584. set positionScale(scale: number);
  119585. /**
  119586. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119587. */
  119588. get positionScale(): number;
  119589. /**
  119590. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119591. * behaviour is triggered, in radians.
  119592. */
  119593. set defaultElevation(elevation: number);
  119594. /**
  119595. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119596. * behaviour is triggered, in radians.
  119597. */
  119598. get defaultElevation(): number;
  119599. /**
  119600. * Sets the time (in milliseconds) taken to return to the default beta position.
  119601. * Negative value indicates camera should not return to default.
  119602. */
  119603. set elevationReturnTime(speed: number);
  119604. /**
  119605. * Gets the time (in milliseconds) taken to return to the default beta position.
  119606. * Negative value indicates camera should not return to default.
  119607. */
  119608. get elevationReturnTime(): number;
  119609. /**
  119610. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119611. */
  119612. set elevationReturnWaitTime(time: number);
  119613. /**
  119614. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119615. */
  119616. get elevationReturnWaitTime(): number;
  119617. /**
  119618. * Sets the flag that indicates if user zooming should stop animation.
  119619. */
  119620. set zoomStopsAnimation(flag: boolean);
  119621. /**
  119622. * Gets the flag that indicates if user zooming should stop animation.
  119623. */
  119624. get zoomStopsAnimation(): boolean;
  119625. /**
  119626. * Sets the transition time when framing the mesh, in milliseconds
  119627. */
  119628. set framingTime(time: number);
  119629. /**
  119630. * Gets the transition time when framing the mesh, in milliseconds
  119631. */
  119632. get framingTime(): number;
  119633. /**
  119634. * Define if the behavior should automatically change the configured
  119635. * camera limits and sensibilities.
  119636. */
  119637. autoCorrectCameraLimitsAndSensibility: boolean;
  119638. private _onPrePointerObservableObserver;
  119639. private _onAfterCheckInputsObserver;
  119640. private _onMeshTargetChangedObserver;
  119641. private _attachedCamera;
  119642. private _isPointerDown;
  119643. private _lastInteractionTime;
  119644. /**
  119645. * Initializes the behavior.
  119646. */
  119647. init(): void;
  119648. /**
  119649. * Attaches the behavior to its arc rotate camera.
  119650. * @param camera Defines the camera to attach the behavior to
  119651. */
  119652. attach(camera: ArcRotateCamera): void;
  119653. /**
  119654. * Detaches the behavior from its current arc rotate camera.
  119655. */
  119656. detach(): void;
  119657. private _animatables;
  119658. private _betaIsAnimating;
  119659. private _betaTransition;
  119660. private _radiusTransition;
  119661. private _vectorTransition;
  119662. /**
  119663. * Targets the given mesh and updates zoom level accordingly.
  119664. * @param mesh The mesh to target.
  119665. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119666. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119667. */
  119668. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119669. /**
  119670. * Targets the given mesh with its children and updates zoom level accordingly.
  119671. * @param mesh The mesh to target.
  119672. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119673. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119674. */
  119675. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119676. /**
  119677. * Targets the given meshes with their children and updates zoom level accordingly.
  119678. * @param meshes The mesh to target.
  119679. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119680. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119681. */
  119682. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119683. /**
  119684. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  119685. * @param minimumWorld Determines the smaller position of the bounding box extend
  119686. * @param maximumWorld Determines the bigger position of the bounding box extend
  119687. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119688. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119689. */
  119690. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119691. /**
  119692. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  119693. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  119694. * frustum width.
  119695. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  119696. * to fully enclose the mesh in the viewing frustum.
  119697. */
  119698. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  119699. /**
  119700. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  119701. * is automatically returned to its default position (expected to be above ground plane).
  119702. */
  119703. private _maintainCameraAboveGround;
  119704. /**
  119705. * Returns the frustum slope based on the canvas ratio and camera FOV
  119706. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  119707. */
  119708. private _getFrustumSlope;
  119709. /**
  119710. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  119711. */
  119712. private _clearAnimationLocks;
  119713. /**
  119714. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119715. */
  119716. private _applyUserInteraction;
  119717. /**
  119718. * Stops and removes all animations that have been applied to the camera
  119719. */
  119720. stopAllAnimations(): void;
  119721. /**
  119722. * Gets a value indicating if the user is moving the camera
  119723. */
  119724. get isUserIsMoving(): boolean;
  119725. /**
  119726. * The camera can move all the way towards the mesh.
  119727. */
  119728. static IgnoreBoundsSizeMode: number;
  119729. /**
  119730. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  119731. */
  119732. static FitFrustumSidesMode: number;
  119733. }
  119734. }
  119735. declare module BABYLON {
  119736. /**
  119737. * Base class for Camera Pointer Inputs.
  119738. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  119739. * for example usage.
  119740. */
  119741. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  119742. /**
  119743. * Defines the camera the input is attached to.
  119744. */
  119745. abstract camera: Camera;
  119746. /**
  119747. * Whether keyboard modifier keys are pressed at time of last mouse event.
  119748. */
  119749. protected _altKey: boolean;
  119750. protected _ctrlKey: boolean;
  119751. protected _metaKey: boolean;
  119752. protected _shiftKey: boolean;
  119753. /**
  119754. * Which mouse buttons were pressed at time of last mouse event.
  119755. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  119756. */
  119757. protected _buttonsPressed: number;
  119758. /**
  119759. * Defines the buttons associated with the input to handle camera move.
  119760. */
  119761. buttons: number[];
  119762. /**
  119763. * Attach the input controls to a specific dom element to get the input from.
  119764. * @param element Defines the element the controls should be listened from
  119765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119766. */
  119767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119768. /**
  119769. * Detach the current controls from the specified dom element.
  119770. * @param element Defines the element to stop listening the inputs from
  119771. */
  119772. detachControl(element: Nullable<HTMLElement>): void;
  119773. /**
  119774. * Gets the class name of the current input.
  119775. * @returns the class name
  119776. */
  119777. getClassName(): string;
  119778. /**
  119779. * Get the friendly name associated with the input class.
  119780. * @returns the input friendly name
  119781. */
  119782. getSimpleName(): string;
  119783. /**
  119784. * Called on pointer POINTERDOUBLETAP event.
  119785. * Override this method to provide functionality on POINTERDOUBLETAP event.
  119786. */
  119787. protected onDoubleTap(type: string): void;
  119788. /**
  119789. * Called on pointer POINTERMOVE event if only a single touch is active.
  119790. * Override this method to provide functionality.
  119791. */
  119792. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119793. /**
  119794. * Called on pointer POINTERMOVE event if multiple touches are active.
  119795. * Override this method to provide functionality.
  119796. */
  119797. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119798. /**
  119799. * Called on JS contextmenu event.
  119800. * Override this method to provide functionality.
  119801. */
  119802. protected onContextMenu(evt: PointerEvent): void;
  119803. /**
  119804. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119805. * press.
  119806. * Override this method to provide functionality.
  119807. */
  119808. protected onButtonDown(evt: PointerEvent): void;
  119809. /**
  119810. * Called each time a new POINTERUP event occurs. Ie, for each button
  119811. * release.
  119812. * Override this method to provide functionality.
  119813. */
  119814. protected onButtonUp(evt: PointerEvent): void;
  119815. /**
  119816. * Called when window becomes inactive.
  119817. * Override this method to provide functionality.
  119818. */
  119819. protected onLostFocus(): void;
  119820. private _pointerInput;
  119821. private _observer;
  119822. private _onLostFocus;
  119823. private pointA;
  119824. private pointB;
  119825. }
  119826. }
  119827. declare module BABYLON {
  119828. /**
  119829. * Manage the pointers inputs to control an arc rotate camera.
  119830. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  119831. */
  119832. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  119833. /**
  119834. * Defines the camera the input is attached to.
  119835. */
  119836. camera: ArcRotateCamera;
  119837. /**
  119838. * Gets the class name of the current input.
  119839. * @returns the class name
  119840. */
  119841. getClassName(): string;
  119842. /**
  119843. * Defines the buttons associated with the input to handle camera move.
  119844. */
  119845. buttons: number[];
  119846. /**
  119847. * Defines the pointer angular sensibility along the X axis or how fast is
  119848. * the camera rotating.
  119849. */
  119850. angularSensibilityX: number;
  119851. /**
  119852. * Defines the pointer angular sensibility along the Y axis or how fast is
  119853. * the camera rotating.
  119854. */
  119855. angularSensibilityY: number;
  119856. /**
  119857. * Defines the pointer pinch precision or how fast is the camera zooming.
  119858. */
  119859. pinchPrecision: number;
  119860. /**
  119861. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  119862. * from 0.
  119863. * It defines the percentage of current camera.radius to use as delta when
  119864. * pinch zoom is used.
  119865. */
  119866. pinchDeltaPercentage: number;
  119867. /**
  119868. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119869. * that any object in the plane at the camera's target point will scale
  119870. * perfectly with finger motion.
  119871. * Overrides pinchDeltaPercentage and pinchPrecision.
  119872. */
  119873. useNaturalPinchZoom: boolean;
  119874. /**
  119875. * Defines the pointer panning sensibility or how fast is the camera moving.
  119876. */
  119877. panningSensibility: number;
  119878. /**
  119879. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  119880. */
  119881. multiTouchPanning: boolean;
  119882. /**
  119883. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  119884. * zoom (pinch) through multitouch.
  119885. */
  119886. multiTouchPanAndZoom: boolean;
  119887. /**
  119888. * Revers pinch action direction.
  119889. */
  119890. pinchInwards: boolean;
  119891. private _isPanClick;
  119892. private _twoFingerActivityCount;
  119893. private _isPinching;
  119894. /**
  119895. * Called on pointer POINTERMOVE event if only a single touch is active.
  119896. */
  119897. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119898. /**
  119899. * Called on pointer POINTERDOUBLETAP event.
  119900. */
  119901. protected onDoubleTap(type: string): void;
  119902. /**
  119903. * Called on pointer POINTERMOVE event if multiple touches are active.
  119904. */
  119905. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119906. /**
  119907. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119908. * press.
  119909. */
  119910. protected onButtonDown(evt: PointerEvent): void;
  119911. /**
  119912. * Called each time a new POINTERUP event occurs. Ie, for each button
  119913. * release.
  119914. */
  119915. protected onButtonUp(evt: PointerEvent): void;
  119916. /**
  119917. * Called when window becomes inactive.
  119918. */
  119919. protected onLostFocus(): void;
  119920. }
  119921. }
  119922. declare module BABYLON {
  119923. /**
  119924. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  119925. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  119926. */
  119927. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  119928. /**
  119929. * Defines the camera the input is attached to.
  119930. */
  119931. camera: ArcRotateCamera;
  119932. /**
  119933. * Defines the list of key codes associated with the up action (increase alpha)
  119934. */
  119935. keysUp: number[];
  119936. /**
  119937. * Defines the list of key codes associated with the down action (decrease alpha)
  119938. */
  119939. keysDown: number[];
  119940. /**
  119941. * Defines the list of key codes associated with the left action (increase beta)
  119942. */
  119943. keysLeft: number[];
  119944. /**
  119945. * Defines the list of key codes associated with the right action (decrease beta)
  119946. */
  119947. keysRight: number[];
  119948. /**
  119949. * Defines the list of key codes associated with the reset action.
  119950. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  119951. */
  119952. keysReset: number[];
  119953. /**
  119954. * Defines the panning sensibility of the inputs.
  119955. * (How fast is the camera panning)
  119956. */
  119957. panningSensibility: number;
  119958. /**
  119959. * Defines the zooming sensibility of the inputs.
  119960. * (How fast is the camera zooming)
  119961. */
  119962. zoomingSensibility: number;
  119963. /**
  119964. * Defines whether maintaining the alt key down switch the movement mode from
  119965. * orientation to zoom.
  119966. */
  119967. useAltToZoom: boolean;
  119968. /**
  119969. * Rotation speed of the camera
  119970. */
  119971. angularSpeed: number;
  119972. private _keys;
  119973. private _ctrlPressed;
  119974. private _altPressed;
  119975. private _onCanvasBlurObserver;
  119976. private _onKeyboardObserver;
  119977. private _engine;
  119978. private _scene;
  119979. /**
  119980. * Attach the input controls to a specific dom element to get the input from.
  119981. * @param element Defines the element the controls should be listened from
  119982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119983. */
  119984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119985. /**
  119986. * Detach the current controls from the specified dom element.
  119987. * @param element Defines the element to stop listening the inputs from
  119988. */
  119989. detachControl(element: Nullable<HTMLElement>): void;
  119990. /**
  119991. * Update the current camera state depending on the inputs that have been used this frame.
  119992. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119993. */
  119994. checkInputs(): void;
  119995. /**
  119996. * Gets the class name of the current intput.
  119997. * @returns the class name
  119998. */
  119999. getClassName(): string;
  120000. /**
  120001. * Get the friendly name associated with the input class.
  120002. * @returns the input friendly name
  120003. */
  120004. getSimpleName(): string;
  120005. }
  120006. }
  120007. declare module BABYLON {
  120008. /**
  120009. * Manage the mouse wheel inputs to control an arc rotate camera.
  120010. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120011. */
  120012. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  120013. /**
  120014. * Defines the camera the input is attached to.
  120015. */
  120016. camera: ArcRotateCamera;
  120017. /**
  120018. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  120019. */
  120020. wheelPrecision: number;
  120021. /**
  120022. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  120023. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  120024. */
  120025. wheelDeltaPercentage: number;
  120026. private _wheel;
  120027. private _observer;
  120028. private computeDeltaFromMouseWheelLegacyEvent;
  120029. /**
  120030. * Attach the input controls to a specific dom element to get the input from.
  120031. * @param element Defines the element the controls should be listened from
  120032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120033. */
  120034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120035. /**
  120036. * Detach the current controls from the specified dom element.
  120037. * @param element Defines the element to stop listening the inputs from
  120038. */
  120039. detachControl(element: Nullable<HTMLElement>): void;
  120040. /**
  120041. * Gets the class name of the current intput.
  120042. * @returns the class name
  120043. */
  120044. getClassName(): string;
  120045. /**
  120046. * Get the friendly name associated with the input class.
  120047. * @returns the input friendly name
  120048. */
  120049. getSimpleName(): string;
  120050. }
  120051. }
  120052. declare module BABYLON {
  120053. /**
  120054. * Default Inputs manager for the ArcRotateCamera.
  120055. * It groups all the default supported inputs for ease of use.
  120056. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120057. */
  120058. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  120059. /**
  120060. * Instantiates a new ArcRotateCameraInputsManager.
  120061. * @param camera Defines the camera the inputs belong to
  120062. */
  120063. constructor(camera: ArcRotateCamera);
  120064. /**
  120065. * Add mouse wheel input support to the input manager.
  120066. * @returns the current input manager
  120067. */
  120068. addMouseWheel(): ArcRotateCameraInputsManager;
  120069. /**
  120070. * Add pointers input support to the input manager.
  120071. * @returns the current input manager
  120072. */
  120073. addPointers(): ArcRotateCameraInputsManager;
  120074. /**
  120075. * Add keyboard input support to the input manager.
  120076. * @returns the current input manager
  120077. */
  120078. addKeyboard(): ArcRotateCameraInputsManager;
  120079. }
  120080. }
  120081. declare module BABYLON {
  120082. /**
  120083. * This represents an orbital type of camera.
  120084. *
  120085. * 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.
  120086. * 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.
  120087. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  120088. */
  120089. export class ArcRotateCamera extends TargetCamera {
  120090. /**
  120091. * Defines the rotation angle of the camera along the longitudinal axis.
  120092. */
  120093. alpha: number;
  120094. /**
  120095. * Defines the rotation angle of the camera along the latitudinal axis.
  120096. */
  120097. beta: number;
  120098. /**
  120099. * Defines the radius of the camera from it s target point.
  120100. */
  120101. radius: number;
  120102. protected _target: Vector3;
  120103. protected _targetHost: Nullable<AbstractMesh>;
  120104. /**
  120105. * Defines the target point of the camera.
  120106. * The camera looks towards it form the radius distance.
  120107. */
  120108. get target(): Vector3;
  120109. set target(value: Vector3);
  120110. /**
  120111. * Define the current local position of the camera in the scene
  120112. */
  120113. get position(): Vector3;
  120114. set position(newPosition: Vector3);
  120115. protected _upVector: Vector3;
  120116. protected _upToYMatrix: Matrix;
  120117. protected _YToUpMatrix: Matrix;
  120118. /**
  120119. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  120120. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  120121. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  120122. */
  120123. set upVector(vec: Vector3);
  120124. get upVector(): Vector3;
  120125. /**
  120126. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  120127. */
  120128. setMatUp(): void;
  120129. /**
  120130. * Current inertia value on the longitudinal axis.
  120131. * The bigger this number the longer it will take for the camera to stop.
  120132. */
  120133. inertialAlphaOffset: number;
  120134. /**
  120135. * Current inertia value on the latitudinal axis.
  120136. * The bigger this number the longer it will take for the camera to stop.
  120137. */
  120138. inertialBetaOffset: number;
  120139. /**
  120140. * Current inertia value on the radius axis.
  120141. * The bigger this number the longer it will take for the camera to stop.
  120142. */
  120143. inertialRadiusOffset: number;
  120144. /**
  120145. * Minimum allowed angle on the longitudinal axis.
  120146. * This can help limiting how the Camera is able to move in the scene.
  120147. */
  120148. lowerAlphaLimit: Nullable<number>;
  120149. /**
  120150. * Maximum allowed angle on the longitudinal axis.
  120151. * This can help limiting how the Camera is able to move in the scene.
  120152. */
  120153. upperAlphaLimit: Nullable<number>;
  120154. /**
  120155. * Minimum allowed angle on the latitudinal axis.
  120156. * This can help limiting how the Camera is able to move in the scene.
  120157. */
  120158. lowerBetaLimit: number;
  120159. /**
  120160. * Maximum allowed angle on the latitudinal axis.
  120161. * This can help limiting how the Camera is able to move in the scene.
  120162. */
  120163. upperBetaLimit: number;
  120164. /**
  120165. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  120166. * This can help limiting how the Camera is able to move in the scene.
  120167. */
  120168. lowerRadiusLimit: Nullable<number>;
  120169. /**
  120170. * Maximum allowed distance of the camera to the target (The camera can not get further).
  120171. * This can help limiting how the Camera is able to move in the scene.
  120172. */
  120173. upperRadiusLimit: Nullable<number>;
  120174. /**
  120175. * Defines the current inertia value used during panning of the camera along the X axis.
  120176. */
  120177. inertialPanningX: number;
  120178. /**
  120179. * Defines the current inertia value used during panning of the camera along the Y axis.
  120180. */
  120181. inertialPanningY: number;
  120182. /**
  120183. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  120184. * Basically if your fingers moves away from more than this distance you will be considered
  120185. * in pinch mode.
  120186. */
  120187. pinchToPanMaxDistance: number;
  120188. /**
  120189. * Defines the maximum distance the camera can pan.
  120190. * This could help keeping the cammera always in your scene.
  120191. */
  120192. panningDistanceLimit: Nullable<number>;
  120193. /**
  120194. * Defines the target of the camera before paning.
  120195. */
  120196. panningOriginTarget: Vector3;
  120197. /**
  120198. * Defines the value of the inertia used during panning.
  120199. * 0 would mean stop inertia and one would mean no decelleration at all.
  120200. */
  120201. panningInertia: number;
  120202. /**
  120203. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  120204. */
  120205. get angularSensibilityX(): number;
  120206. set angularSensibilityX(value: number);
  120207. /**
  120208. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  120209. */
  120210. get angularSensibilityY(): number;
  120211. set angularSensibilityY(value: number);
  120212. /**
  120213. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  120214. */
  120215. get pinchPrecision(): number;
  120216. set pinchPrecision(value: number);
  120217. /**
  120218. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  120219. * It will be used instead of pinchDeltaPrecision if different from 0.
  120220. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  120221. */
  120222. get pinchDeltaPercentage(): number;
  120223. set pinchDeltaPercentage(value: number);
  120224. /**
  120225. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  120226. * and pinch delta percentage.
  120227. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  120228. * that any object in the plane at the camera's target point will scale
  120229. * perfectly with finger motion.
  120230. */
  120231. get useNaturalPinchZoom(): boolean;
  120232. set useNaturalPinchZoom(value: boolean);
  120233. /**
  120234. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  120235. */
  120236. get panningSensibility(): number;
  120237. set panningSensibility(value: number);
  120238. /**
  120239. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  120240. */
  120241. get keysUp(): number[];
  120242. set keysUp(value: number[]);
  120243. /**
  120244. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  120245. */
  120246. get keysDown(): number[];
  120247. set keysDown(value: number[]);
  120248. /**
  120249. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  120250. */
  120251. get keysLeft(): number[];
  120252. set keysLeft(value: number[]);
  120253. /**
  120254. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  120255. */
  120256. get keysRight(): number[];
  120257. set keysRight(value: number[]);
  120258. /**
  120259. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  120260. */
  120261. get wheelPrecision(): number;
  120262. set wheelPrecision(value: number);
  120263. /**
  120264. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  120265. * It will be used instead of pinchDeltaPrecision if different from 0.
  120266. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  120267. */
  120268. get wheelDeltaPercentage(): number;
  120269. set wheelDeltaPercentage(value: number);
  120270. /**
  120271. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  120272. */
  120273. zoomOnFactor: number;
  120274. /**
  120275. * Defines a screen offset for the camera position.
  120276. */
  120277. targetScreenOffset: Vector2;
  120278. /**
  120279. * Allows the camera to be completely reversed.
  120280. * If false the camera can not arrive upside down.
  120281. */
  120282. allowUpsideDown: boolean;
  120283. /**
  120284. * Define if double tap/click is used to restore the previously saved state of the camera.
  120285. */
  120286. useInputToRestoreState: boolean;
  120287. /** @hidden */
  120288. _viewMatrix: Matrix;
  120289. /** @hidden */
  120290. _useCtrlForPanning: boolean;
  120291. /** @hidden */
  120292. _panningMouseButton: number;
  120293. /**
  120294. * Defines the input associated to the camera.
  120295. */
  120296. inputs: ArcRotateCameraInputsManager;
  120297. /** @hidden */
  120298. _reset: () => void;
  120299. /**
  120300. * Defines the allowed panning axis.
  120301. */
  120302. panningAxis: Vector3;
  120303. protected _localDirection: Vector3;
  120304. protected _transformedDirection: Vector3;
  120305. private _bouncingBehavior;
  120306. /**
  120307. * Gets the bouncing behavior of the camera if it has been enabled.
  120308. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120309. */
  120310. get bouncingBehavior(): Nullable<BouncingBehavior>;
  120311. /**
  120312. * Defines if the bouncing behavior of the camera is enabled on the camera.
  120313. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120314. */
  120315. get useBouncingBehavior(): boolean;
  120316. set useBouncingBehavior(value: boolean);
  120317. private _framingBehavior;
  120318. /**
  120319. * Gets the framing behavior of the camera if it has been enabled.
  120320. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120321. */
  120322. get framingBehavior(): Nullable<FramingBehavior>;
  120323. /**
  120324. * Defines if the framing behavior of the camera is enabled on the camera.
  120325. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120326. */
  120327. get useFramingBehavior(): boolean;
  120328. set useFramingBehavior(value: boolean);
  120329. private _autoRotationBehavior;
  120330. /**
  120331. * Gets the auto rotation behavior of the camera if it has been enabled.
  120332. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120333. */
  120334. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  120335. /**
  120336. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  120337. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120338. */
  120339. get useAutoRotationBehavior(): boolean;
  120340. set useAutoRotationBehavior(value: boolean);
  120341. /**
  120342. * Observable triggered when the mesh target has been changed on the camera.
  120343. */
  120344. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  120345. /**
  120346. * Event raised when the camera is colliding with a mesh.
  120347. */
  120348. onCollide: (collidedMesh: AbstractMesh) => void;
  120349. /**
  120350. * Defines whether the camera should check collision with the objects oh the scene.
  120351. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  120352. */
  120353. checkCollisions: boolean;
  120354. /**
  120355. * Defines the collision radius of the camera.
  120356. * This simulates a sphere around the camera.
  120357. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120358. */
  120359. collisionRadius: Vector3;
  120360. protected _collider: Collider;
  120361. protected _previousPosition: Vector3;
  120362. protected _collisionVelocity: Vector3;
  120363. protected _newPosition: Vector3;
  120364. protected _previousAlpha: number;
  120365. protected _previousBeta: number;
  120366. protected _previousRadius: number;
  120367. protected _collisionTriggered: boolean;
  120368. protected _targetBoundingCenter: Nullable<Vector3>;
  120369. private _computationVector;
  120370. /**
  120371. * Instantiates a new ArcRotateCamera in a given scene
  120372. * @param name Defines the name of the camera
  120373. * @param alpha Defines the camera rotation along the logitudinal axis
  120374. * @param beta Defines the camera rotation along the latitudinal axis
  120375. * @param radius Defines the camera distance from its target
  120376. * @param target Defines the camera target
  120377. * @param scene Defines the scene the camera belongs to
  120378. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  120379. */
  120380. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120381. /** @hidden */
  120382. _initCache(): void;
  120383. /** @hidden */
  120384. _updateCache(ignoreParentClass?: boolean): void;
  120385. protected _getTargetPosition(): Vector3;
  120386. private _storedAlpha;
  120387. private _storedBeta;
  120388. private _storedRadius;
  120389. private _storedTarget;
  120390. private _storedTargetScreenOffset;
  120391. /**
  120392. * Stores the current state of the camera (alpha, beta, radius and target)
  120393. * @returns the camera itself
  120394. */
  120395. storeState(): Camera;
  120396. /**
  120397. * @hidden
  120398. * Restored camera state. You must call storeState() first
  120399. */
  120400. _restoreStateValues(): boolean;
  120401. /** @hidden */
  120402. _isSynchronizedViewMatrix(): boolean;
  120403. /**
  120404. * Attached controls to the current camera.
  120405. * @param element Defines the element the controls should be listened from
  120406. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120407. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  120408. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  120409. */
  120410. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  120411. /**
  120412. * Detach the current controls from the camera.
  120413. * The camera will stop reacting to inputs.
  120414. * @param element Defines the element to stop listening the inputs from
  120415. */
  120416. detachControl(element: HTMLElement): void;
  120417. /** @hidden */
  120418. _checkInputs(): void;
  120419. protected _checkLimits(): void;
  120420. /**
  120421. * Rebuilds angles (alpha, beta) and radius from the give position and target
  120422. */
  120423. rebuildAnglesAndRadius(): void;
  120424. /**
  120425. * Use a position to define the current camera related information like alpha, beta and radius
  120426. * @param position Defines the position to set the camera at
  120427. */
  120428. setPosition(position: Vector3): void;
  120429. /**
  120430. * Defines the target the camera should look at.
  120431. * This will automatically adapt alpha beta and radius to fit within the new target.
  120432. * @param target Defines the new target as a Vector or a mesh
  120433. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  120434. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  120435. */
  120436. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  120437. /** @hidden */
  120438. _getViewMatrix(): Matrix;
  120439. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  120440. /**
  120441. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  120442. * @param meshes Defines the mesh to zoom on
  120443. * @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)
  120444. */
  120445. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  120446. /**
  120447. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  120448. * The target will be changed but the radius
  120449. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  120450. * @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)
  120451. */
  120452. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  120453. min: Vector3;
  120454. max: Vector3;
  120455. distance: number;
  120456. }, doNotUpdateMaxZ?: boolean): void;
  120457. /**
  120458. * @override
  120459. * Override Camera.createRigCamera
  120460. */
  120461. createRigCamera(name: string, cameraIndex: number): Camera;
  120462. /**
  120463. * @hidden
  120464. * @override
  120465. * Override Camera._updateRigCameras
  120466. */
  120467. _updateRigCameras(): void;
  120468. /**
  120469. * Destroy the camera and release the current resources hold by it.
  120470. */
  120471. dispose(): void;
  120472. /**
  120473. * Gets the current object class name.
  120474. * @return the class name
  120475. */
  120476. getClassName(): string;
  120477. }
  120478. }
  120479. declare module BABYLON {
  120480. /**
  120481. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  120482. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120483. */
  120484. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  120485. /**
  120486. * Gets the name of the behavior.
  120487. */
  120488. get name(): string;
  120489. private _zoomStopsAnimation;
  120490. private _idleRotationSpeed;
  120491. private _idleRotationWaitTime;
  120492. private _idleRotationSpinupTime;
  120493. /**
  120494. * Sets the flag that indicates if user zooming should stop animation.
  120495. */
  120496. set zoomStopsAnimation(flag: boolean);
  120497. /**
  120498. * Gets the flag that indicates if user zooming should stop animation.
  120499. */
  120500. get zoomStopsAnimation(): boolean;
  120501. /**
  120502. * Sets the default speed at which the camera rotates around the model.
  120503. */
  120504. set idleRotationSpeed(speed: number);
  120505. /**
  120506. * Gets the default speed at which the camera rotates around the model.
  120507. */
  120508. get idleRotationSpeed(): number;
  120509. /**
  120510. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  120511. */
  120512. set idleRotationWaitTime(time: number);
  120513. /**
  120514. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  120515. */
  120516. get idleRotationWaitTime(): number;
  120517. /**
  120518. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120519. */
  120520. set idleRotationSpinupTime(time: number);
  120521. /**
  120522. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120523. */
  120524. get idleRotationSpinupTime(): number;
  120525. /**
  120526. * Gets a value indicating if the camera is currently rotating because of this behavior
  120527. */
  120528. get rotationInProgress(): boolean;
  120529. private _onPrePointerObservableObserver;
  120530. private _onAfterCheckInputsObserver;
  120531. private _attachedCamera;
  120532. private _isPointerDown;
  120533. private _lastFrameTime;
  120534. private _lastInteractionTime;
  120535. private _cameraRotationSpeed;
  120536. /**
  120537. * Initializes the behavior.
  120538. */
  120539. init(): void;
  120540. /**
  120541. * Attaches the behavior to its arc rotate camera.
  120542. * @param camera Defines the camera to attach the behavior to
  120543. */
  120544. attach(camera: ArcRotateCamera): void;
  120545. /**
  120546. * Detaches the behavior from its current arc rotate camera.
  120547. */
  120548. detach(): void;
  120549. /**
  120550. * Returns true if user is scrolling.
  120551. * @return true if user is scrolling.
  120552. */
  120553. private _userIsZooming;
  120554. private _lastFrameRadius;
  120555. private _shouldAnimationStopForInteraction;
  120556. /**
  120557. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  120558. */
  120559. private _applyUserInteraction;
  120560. private _userIsMoving;
  120561. }
  120562. }
  120563. declare module BABYLON {
  120564. /**
  120565. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  120566. */
  120567. export class AttachToBoxBehavior implements Behavior<Mesh> {
  120568. private ui;
  120569. /**
  120570. * The name of the behavior
  120571. */
  120572. name: string;
  120573. /**
  120574. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  120575. */
  120576. distanceAwayFromFace: number;
  120577. /**
  120578. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  120579. */
  120580. distanceAwayFromBottomOfFace: number;
  120581. private _faceVectors;
  120582. private _target;
  120583. private _scene;
  120584. private _onRenderObserver;
  120585. private _tmpMatrix;
  120586. private _tmpVector;
  120587. /**
  120588. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  120589. * @param ui The transform node that should be attched to the mesh
  120590. */
  120591. constructor(ui: TransformNode);
  120592. /**
  120593. * Initializes the behavior
  120594. */
  120595. init(): void;
  120596. private _closestFace;
  120597. private _zeroVector;
  120598. private _lookAtTmpMatrix;
  120599. private _lookAtToRef;
  120600. /**
  120601. * Attaches the AttachToBoxBehavior to the passed in mesh
  120602. * @param target The mesh that the specified node will be attached to
  120603. */
  120604. attach(target: Mesh): void;
  120605. /**
  120606. * Detaches the behavior from the mesh
  120607. */
  120608. detach(): void;
  120609. }
  120610. }
  120611. declare module BABYLON {
  120612. /**
  120613. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  120614. */
  120615. export class FadeInOutBehavior implements Behavior<Mesh> {
  120616. /**
  120617. * Time in milliseconds to delay before fading in (Default: 0)
  120618. */
  120619. delay: number;
  120620. /**
  120621. * Time in milliseconds for the mesh to fade in (Default: 300)
  120622. */
  120623. fadeInTime: number;
  120624. private _millisecondsPerFrame;
  120625. private _hovered;
  120626. private _hoverValue;
  120627. private _ownerNode;
  120628. /**
  120629. * Instatiates the FadeInOutBehavior
  120630. */
  120631. constructor();
  120632. /**
  120633. * The name of the behavior
  120634. */
  120635. get name(): string;
  120636. /**
  120637. * Initializes the behavior
  120638. */
  120639. init(): void;
  120640. /**
  120641. * Attaches the fade behavior on the passed in mesh
  120642. * @param ownerNode The mesh that will be faded in/out once attached
  120643. */
  120644. attach(ownerNode: Mesh): void;
  120645. /**
  120646. * Detaches the behavior from the mesh
  120647. */
  120648. detach(): void;
  120649. /**
  120650. * Triggers the mesh to begin fading in or out
  120651. * @param value if the object should fade in or out (true to fade in)
  120652. */
  120653. fadeIn(value: boolean): void;
  120654. private _update;
  120655. private _setAllVisibility;
  120656. }
  120657. }
  120658. declare module BABYLON {
  120659. /**
  120660. * Class containing a set of static utilities functions for managing Pivots
  120661. * @hidden
  120662. */
  120663. export class PivotTools {
  120664. private static _PivotCached;
  120665. private static _OldPivotPoint;
  120666. private static _PivotTranslation;
  120667. private static _PivotTmpVector;
  120668. /** @hidden */
  120669. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  120670. /** @hidden */
  120671. static _RestorePivotPoint(mesh: AbstractMesh): void;
  120672. }
  120673. }
  120674. declare module BABYLON {
  120675. /**
  120676. * Class containing static functions to help procedurally build meshes
  120677. */
  120678. export class PlaneBuilder {
  120679. /**
  120680. * Creates a plane mesh
  120681. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120682. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120683. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120685. * * 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
  120686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120687. * @param name defines the name of the mesh
  120688. * @param options defines the options used to create the mesh
  120689. * @param scene defines the hosting scene
  120690. * @returns the plane mesh
  120691. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120692. */
  120693. static CreatePlane(name: string, options: {
  120694. size?: number;
  120695. width?: number;
  120696. height?: number;
  120697. sideOrientation?: number;
  120698. frontUVs?: Vector4;
  120699. backUVs?: Vector4;
  120700. updatable?: boolean;
  120701. sourcePlane?: Plane;
  120702. }, scene?: Nullable<Scene>): Mesh;
  120703. }
  120704. }
  120705. declare module BABYLON {
  120706. /**
  120707. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  120708. */
  120709. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  120710. private static _AnyMouseID;
  120711. /**
  120712. * Abstract mesh the behavior is set on
  120713. */
  120714. attachedNode: AbstractMesh;
  120715. private _dragPlane;
  120716. private _scene;
  120717. private _pointerObserver;
  120718. private _beforeRenderObserver;
  120719. private static _planeScene;
  120720. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  120721. /**
  120722. * 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)
  120723. */
  120724. maxDragAngle: number;
  120725. /**
  120726. * @hidden
  120727. */
  120728. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  120729. /**
  120730. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120731. */
  120732. currentDraggingPointerID: number;
  120733. /**
  120734. * The last position where the pointer hit the drag plane in world space
  120735. */
  120736. lastDragPosition: Vector3;
  120737. /**
  120738. * If the behavior is currently in a dragging state
  120739. */
  120740. dragging: boolean;
  120741. /**
  120742. * 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)
  120743. */
  120744. dragDeltaRatio: number;
  120745. /**
  120746. * If the drag plane orientation should be updated during the dragging (Default: true)
  120747. */
  120748. updateDragPlane: boolean;
  120749. private _debugMode;
  120750. private _moving;
  120751. /**
  120752. * Fires each time the attached mesh is dragged with the pointer
  120753. * * delta between last drag position and current drag position in world space
  120754. * * dragDistance along the drag axis
  120755. * * dragPlaneNormal normal of the current drag plane used during the drag
  120756. * * dragPlanePoint in world space where the drag intersects the drag plane
  120757. */
  120758. onDragObservable: Observable<{
  120759. delta: Vector3;
  120760. dragPlanePoint: Vector3;
  120761. dragPlaneNormal: Vector3;
  120762. dragDistance: number;
  120763. pointerId: number;
  120764. }>;
  120765. /**
  120766. * Fires each time a drag begins (eg. mouse down on mesh)
  120767. */
  120768. onDragStartObservable: Observable<{
  120769. dragPlanePoint: Vector3;
  120770. pointerId: number;
  120771. }>;
  120772. /**
  120773. * Fires each time a drag ends (eg. mouse release after drag)
  120774. */
  120775. onDragEndObservable: Observable<{
  120776. dragPlanePoint: Vector3;
  120777. pointerId: number;
  120778. }>;
  120779. /**
  120780. * If the attached mesh should be moved when dragged
  120781. */
  120782. moveAttached: boolean;
  120783. /**
  120784. * If the drag behavior will react to drag events (Default: true)
  120785. */
  120786. enabled: boolean;
  120787. /**
  120788. * If pointer events should start and release the drag (Default: true)
  120789. */
  120790. startAndReleaseDragOnPointerEvents: boolean;
  120791. /**
  120792. * If camera controls should be detached during the drag
  120793. */
  120794. detachCameraControls: boolean;
  120795. /**
  120796. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  120797. */
  120798. useObjectOrientationForDragging: boolean;
  120799. private _options;
  120800. /**
  120801. * Gets the options used by the behavior
  120802. */
  120803. get options(): {
  120804. dragAxis?: Vector3;
  120805. dragPlaneNormal?: Vector3;
  120806. };
  120807. /**
  120808. * Sets the options used by the behavior
  120809. */
  120810. set options(options: {
  120811. dragAxis?: Vector3;
  120812. dragPlaneNormal?: Vector3;
  120813. });
  120814. /**
  120815. * Creates a pointer drag behavior that can be attached to a mesh
  120816. * @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)
  120817. */
  120818. constructor(options?: {
  120819. dragAxis?: Vector3;
  120820. dragPlaneNormal?: Vector3;
  120821. });
  120822. /**
  120823. * Predicate to determine if it is valid to move the object to a new position when it is moved
  120824. */
  120825. validateDrag: (targetPosition: Vector3) => boolean;
  120826. /**
  120827. * The name of the behavior
  120828. */
  120829. get name(): string;
  120830. /**
  120831. * Initializes the behavior
  120832. */
  120833. init(): void;
  120834. private _tmpVector;
  120835. private _alternatePickedPoint;
  120836. private _worldDragAxis;
  120837. private _targetPosition;
  120838. private _attachedElement;
  120839. /**
  120840. * Attaches the drag behavior the passed in mesh
  120841. * @param ownerNode The mesh that will be dragged around once attached
  120842. * @param predicate Predicate to use for pick filtering
  120843. */
  120844. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  120845. /**
  120846. * Force relase the drag action by code.
  120847. */
  120848. releaseDrag(): void;
  120849. private _startDragRay;
  120850. private _lastPointerRay;
  120851. /**
  120852. * Simulates the start of a pointer drag event on the behavior
  120853. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  120854. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  120855. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  120856. */
  120857. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  120858. private _startDrag;
  120859. private _dragDelta;
  120860. private _moveDrag;
  120861. private _pickWithRayOnDragPlane;
  120862. private _pointA;
  120863. private _pointB;
  120864. private _pointC;
  120865. private _lineA;
  120866. private _lineB;
  120867. private _localAxis;
  120868. private _lookAt;
  120869. private _updateDragPlanePosition;
  120870. /**
  120871. * Detaches the behavior from the mesh
  120872. */
  120873. detach(): void;
  120874. }
  120875. }
  120876. declare module BABYLON {
  120877. /**
  120878. * A behavior that when attached to a mesh will allow the mesh to be scaled
  120879. */
  120880. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  120881. private _dragBehaviorA;
  120882. private _dragBehaviorB;
  120883. private _startDistance;
  120884. private _initialScale;
  120885. private _targetScale;
  120886. private _ownerNode;
  120887. private _sceneRenderObserver;
  120888. /**
  120889. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  120890. */
  120891. constructor();
  120892. /**
  120893. * The name of the behavior
  120894. */
  120895. get name(): string;
  120896. /**
  120897. * Initializes the behavior
  120898. */
  120899. init(): void;
  120900. private _getCurrentDistance;
  120901. /**
  120902. * Attaches the scale behavior the passed in mesh
  120903. * @param ownerNode The mesh that will be scaled around once attached
  120904. */
  120905. attach(ownerNode: Mesh): void;
  120906. /**
  120907. * Detaches the behavior from the mesh
  120908. */
  120909. detach(): void;
  120910. }
  120911. }
  120912. declare module BABYLON {
  120913. /**
  120914. * 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
  120915. */
  120916. export class SixDofDragBehavior implements Behavior<Mesh> {
  120917. private static _virtualScene;
  120918. private _ownerNode;
  120919. private _sceneRenderObserver;
  120920. private _scene;
  120921. private _targetPosition;
  120922. private _virtualOriginMesh;
  120923. private _virtualDragMesh;
  120924. private _pointerObserver;
  120925. private _moving;
  120926. private _startingOrientation;
  120927. private _attachedElement;
  120928. /**
  120929. * 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)
  120930. */
  120931. private zDragFactor;
  120932. /**
  120933. * If the object should rotate to face the drag origin
  120934. */
  120935. rotateDraggedObject: boolean;
  120936. /**
  120937. * If the behavior is currently in a dragging state
  120938. */
  120939. dragging: boolean;
  120940. /**
  120941. * 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)
  120942. */
  120943. dragDeltaRatio: number;
  120944. /**
  120945. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120946. */
  120947. currentDraggingPointerID: number;
  120948. /**
  120949. * If camera controls should be detached during the drag
  120950. */
  120951. detachCameraControls: boolean;
  120952. /**
  120953. * Fires each time a drag starts
  120954. */
  120955. onDragStartObservable: Observable<{}>;
  120956. /**
  120957. * Fires each time a drag ends (eg. mouse release after drag)
  120958. */
  120959. onDragEndObservable: Observable<{}>;
  120960. /**
  120961. * 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
  120962. */
  120963. constructor();
  120964. /**
  120965. * The name of the behavior
  120966. */
  120967. get name(): string;
  120968. /**
  120969. * Initializes the behavior
  120970. */
  120971. init(): void;
  120972. /**
  120973. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  120974. */
  120975. private get _pointerCamera();
  120976. /**
  120977. * Attaches the scale behavior the passed in mesh
  120978. * @param ownerNode The mesh that will be scaled around once attached
  120979. */
  120980. attach(ownerNode: Mesh): void;
  120981. /**
  120982. * Detaches the behavior from the mesh
  120983. */
  120984. detach(): void;
  120985. }
  120986. }
  120987. declare module BABYLON {
  120988. /**
  120989. * Class used to apply inverse kinematics to bones
  120990. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  120991. */
  120992. export class BoneIKController {
  120993. private static _tmpVecs;
  120994. private static _tmpQuat;
  120995. private static _tmpMats;
  120996. /**
  120997. * Gets or sets the target mesh
  120998. */
  120999. targetMesh: AbstractMesh;
  121000. /** Gets or sets the mesh used as pole */
  121001. poleTargetMesh: AbstractMesh;
  121002. /**
  121003. * Gets or sets the bone used as pole
  121004. */
  121005. poleTargetBone: Nullable<Bone>;
  121006. /**
  121007. * Gets or sets the target position
  121008. */
  121009. targetPosition: Vector3;
  121010. /**
  121011. * Gets or sets the pole target position
  121012. */
  121013. poleTargetPosition: Vector3;
  121014. /**
  121015. * Gets or sets the pole target local offset
  121016. */
  121017. poleTargetLocalOffset: Vector3;
  121018. /**
  121019. * Gets or sets the pole angle
  121020. */
  121021. poleAngle: number;
  121022. /**
  121023. * Gets or sets the mesh associated with the controller
  121024. */
  121025. mesh: AbstractMesh;
  121026. /**
  121027. * 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)
  121028. */
  121029. slerpAmount: number;
  121030. private _bone1Quat;
  121031. private _bone1Mat;
  121032. private _bone2Ang;
  121033. private _bone1;
  121034. private _bone2;
  121035. private _bone1Length;
  121036. private _bone2Length;
  121037. private _maxAngle;
  121038. private _maxReach;
  121039. private _rightHandedSystem;
  121040. private _bendAxis;
  121041. private _slerping;
  121042. private _adjustRoll;
  121043. /**
  121044. * Gets or sets maximum allowed angle
  121045. */
  121046. get maxAngle(): number;
  121047. set maxAngle(value: number);
  121048. /**
  121049. * Creates a new BoneIKController
  121050. * @param mesh defines the mesh to control
  121051. * @param bone defines the bone to control
  121052. * @param options defines options to set up the controller
  121053. */
  121054. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  121055. targetMesh?: AbstractMesh;
  121056. poleTargetMesh?: AbstractMesh;
  121057. poleTargetBone?: Bone;
  121058. poleTargetLocalOffset?: Vector3;
  121059. poleAngle?: number;
  121060. bendAxis?: Vector3;
  121061. maxAngle?: number;
  121062. slerpAmount?: number;
  121063. });
  121064. private _setMaxAngle;
  121065. /**
  121066. * Force the controller to update the bones
  121067. */
  121068. update(): void;
  121069. }
  121070. }
  121071. declare module BABYLON {
  121072. /**
  121073. * Class used to make a bone look toward a point in space
  121074. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  121075. */
  121076. export class BoneLookController {
  121077. private static _tmpVecs;
  121078. private static _tmpQuat;
  121079. private static _tmpMats;
  121080. /**
  121081. * The target Vector3 that the bone will look at
  121082. */
  121083. target: Vector3;
  121084. /**
  121085. * The mesh that the bone is attached to
  121086. */
  121087. mesh: AbstractMesh;
  121088. /**
  121089. * The bone that will be looking to the target
  121090. */
  121091. bone: Bone;
  121092. /**
  121093. * The up axis of the coordinate system that is used when the bone is rotated
  121094. */
  121095. upAxis: Vector3;
  121096. /**
  121097. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  121098. */
  121099. upAxisSpace: Space;
  121100. /**
  121101. * Used to make an adjustment to the yaw of the bone
  121102. */
  121103. adjustYaw: number;
  121104. /**
  121105. * Used to make an adjustment to the pitch of the bone
  121106. */
  121107. adjustPitch: number;
  121108. /**
  121109. * Used to make an adjustment to the roll of the bone
  121110. */
  121111. adjustRoll: number;
  121112. /**
  121113. * 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)
  121114. */
  121115. slerpAmount: number;
  121116. private _minYaw;
  121117. private _maxYaw;
  121118. private _minPitch;
  121119. private _maxPitch;
  121120. private _minYawSin;
  121121. private _minYawCos;
  121122. private _maxYawSin;
  121123. private _maxYawCos;
  121124. private _midYawConstraint;
  121125. private _minPitchTan;
  121126. private _maxPitchTan;
  121127. private _boneQuat;
  121128. private _slerping;
  121129. private _transformYawPitch;
  121130. private _transformYawPitchInv;
  121131. private _firstFrameSkipped;
  121132. private _yawRange;
  121133. private _fowardAxis;
  121134. /**
  121135. * Gets or sets the minimum yaw angle that the bone can look to
  121136. */
  121137. get minYaw(): number;
  121138. set minYaw(value: number);
  121139. /**
  121140. * Gets or sets the maximum yaw angle that the bone can look to
  121141. */
  121142. get maxYaw(): number;
  121143. set maxYaw(value: number);
  121144. /**
  121145. * Gets or sets the minimum pitch angle that the bone can look to
  121146. */
  121147. get minPitch(): number;
  121148. set minPitch(value: number);
  121149. /**
  121150. * Gets or sets the maximum pitch angle that the bone can look to
  121151. */
  121152. get maxPitch(): number;
  121153. set maxPitch(value: number);
  121154. /**
  121155. * Create a BoneLookController
  121156. * @param mesh the mesh that the bone belongs to
  121157. * @param bone the bone that will be looking to the target
  121158. * @param target the target Vector3 to look at
  121159. * @param options optional settings:
  121160. * * maxYaw: the maximum angle the bone will yaw to
  121161. * * minYaw: the minimum angle the bone will yaw to
  121162. * * maxPitch: the maximum angle the bone will pitch to
  121163. * * minPitch: the minimum angle the bone will yaw to
  121164. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  121165. * * upAxis: the up axis of the coordinate system
  121166. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  121167. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  121168. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  121169. * * adjustYaw: used to make an adjustment to the yaw of the bone
  121170. * * adjustPitch: used to make an adjustment to the pitch of the bone
  121171. * * adjustRoll: used to make an adjustment to the roll of the bone
  121172. **/
  121173. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  121174. maxYaw?: number;
  121175. minYaw?: number;
  121176. maxPitch?: number;
  121177. minPitch?: number;
  121178. slerpAmount?: number;
  121179. upAxis?: Vector3;
  121180. upAxisSpace?: Space;
  121181. yawAxis?: Vector3;
  121182. pitchAxis?: Vector3;
  121183. adjustYaw?: number;
  121184. adjustPitch?: number;
  121185. adjustRoll?: number;
  121186. });
  121187. /**
  121188. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  121189. */
  121190. update(): void;
  121191. private _getAngleDiff;
  121192. private _getAngleBetween;
  121193. private _isAngleBetween;
  121194. }
  121195. }
  121196. declare module BABYLON {
  121197. /**
  121198. * Manage the gamepad inputs to control an arc rotate camera.
  121199. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121200. */
  121201. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  121202. /**
  121203. * Defines the camera the input is attached to.
  121204. */
  121205. camera: ArcRotateCamera;
  121206. /**
  121207. * Defines the gamepad the input is gathering event from.
  121208. */
  121209. gamepad: Nullable<Gamepad>;
  121210. /**
  121211. * Defines the gamepad rotation sensiblity.
  121212. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121213. */
  121214. gamepadRotationSensibility: number;
  121215. /**
  121216. * Defines the gamepad move sensiblity.
  121217. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121218. */
  121219. gamepadMoveSensibility: number;
  121220. private _yAxisScale;
  121221. /**
  121222. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  121223. */
  121224. get invertYAxis(): boolean;
  121225. set invertYAxis(value: boolean);
  121226. private _onGamepadConnectedObserver;
  121227. private _onGamepadDisconnectedObserver;
  121228. /**
  121229. * Attach the input controls to a specific dom element to get the input from.
  121230. * @param element Defines the element the controls should be listened from
  121231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121232. */
  121233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121234. /**
  121235. * Detach the current controls from the specified dom element.
  121236. * @param element Defines the element to stop listening the inputs from
  121237. */
  121238. detachControl(element: Nullable<HTMLElement>): void;
  121239. /**
  121240. * Update the current camera state depending on the inputs that have been used this frame.
  121241. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121242. */
  121243. checkInputs(): void;
  121244. /**
  121245. * Gets the class name of the current intput.
  121246. * @returns the class name
  121247. */
  121248. getClassName(): string;
  121249. /**
  121250. * Get the friendly name associated with the input class.
  121251. * @returns the input friendly name
  121252. */
  121253. getSimpleName(): string;
  121254. }
  121255. }
  121256. declare module BABYLON {
  121257. interface ArcRotateCameraInputsManager {
  121258. /**
  121259. * Add orientation input support to the input manager.
  121260. * @returns the current input manager
  121261. */
  121262. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  121263. }
  121264. /**
  121265. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  121266. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121267. */
  121268. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  121269. /**
  121270. * Defines the camera the input is attached to.
  121271. */
  121272. camera: ArcRotateCamera;
  121273. /**
  121274. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  121275. */
  121276. alphaCorrection: number;
  121277. /**
  121278. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  121279. */
  121280. gammaCorrection: number;
  121281. private _alpha;
  121282. private _gamma;
  121283. private _dirty;
  121284. private _deviceOrientationHandler;
  121285. /**
  121286. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  121287. */
  121288. constructor();
  121289. /**
  121290. * Attach the input controls to a specific dom element to get the input from.
  121291. * @param element Defines the element the controls should be listened from
  121292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121293. */
  121294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121295. /** @hidden */
  121296. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  121297. /**
  121298. * Update the current camera state depending on the inputs that have been used this frame.
  121299. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121300. */
  121301. checkInputs(): void;
  121302. /**
  121303. * Detach the current controls from the specified dom element.
  121304. * @param element Defines the element to stop listening the inputs from
  121305. */
  121306. detachControl(element: Nullable<HTMLElement>): void;
  121307. /**
  121308. * Gets the class name of the current intput.
  121309. * @returns the class name
  121310. */
  121311. getClassName(): string;
  121312. /**
  121313. * Get the friendly name associated with the input class.
  121314. * @returns the input friendly name
  121315. */
  121316. getSimpleName(): string;
  121317. }
  121318. }
  121319. declare module BABYLON {
  121320. /**
  121321. * Listen to mouse events to control the camera.
  121322. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121323. */
  121324. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  121325. /**
  121326. * Defines the camera the input is attached to.
  121327. */
  121328. camera: FlyCamera;
  121329. /**
  121330. * Defines if touch is enabled. (Default is true.)
  121331. */
  121332. touchEnabled: boolean;
  121333. /**
  121334. * Defines the buttons associated with the input to handle camera rotation.
  121335. */
  121336. buttons: number[];
  121337. /**
  121338. * Assign buttons for Yaw control.
  121339. */
  121340. buttonsYaw: number[];
  121341. /**
  121342. * Assign buttons for Pitch control.
  121343. */
  121344. buttonsPitch: number[];
  121345. /**
  121346. * Assign buttons for Roll control.
  121347. */
  121348. buttonsRoll: number[];
  121349. /**
  121350. * Detect if any button is being pressed while mouse is moved.
  121351. * -1 = Mouse locked.
  121352. * 0 = Left button.
  121353. * 1 = Middle Button.
  121354. * 2 = Right Button.
  121355. */
  121356. activeButton: number;
  121357. /**
  121358. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  121359. * Higher values reduce its sensitivity.
  121360. */
  121361. angularSensibility: number;
  121362. private _mousemoveCallback;
  121363. private _observer;
  121364. private _rollObserver;
  121365. private previousPosition;
  121366. private noPreventDefault;
  121367. private element;
  121368. /**
  121369. * Listen to mouse events to control the camera.
  121370. * @param touchEnabled Define if touch is enabled. (Default is true.)
  121371. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121372. */
  121373. constructor(touchEnabled?: boolean);
  121374. /**
  121375. * Attach the mouse control to the HTML DOM element.
  121376. * @param element Defines the element that listens to the input events.
  121377. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  121378. */
  121379. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121380. /**
  121381. * Detach the current controls from the specified dom element.
  121382. * @param element Defines the element to stop listening the inputs from
  121383. */
  121384. detachControl(element: Nullable<HTMLElement>): void;
  121385. /**
  121386. * Gets the class name of the current input.
  121387. * @returns the class name.
  121388. */
  121389. getClassName(): string;
  121390. /**
  121391. * Get the friendly name associated with the input class.
  121392. * @returns the input's friendly name.
  121393. */
  121394. getSimpleName(): string;
  121395. private _pointerInput;
  121396. private _onMouseMove;
  121397. /**
  121398. * Rotate camera by mouse offset.
  121399. */
  121400. private rotateCamera;
  121401. }
  121402. }
  121403. declare module BABYLON {
  121404. /**
  121405. * Default Inputs manager for the FlyCamera.
  121406. * It groups all the default supported inputs for ease of use.
  121407. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121408. */
  121409. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  121410. /**
  121411. * Instantiates a new FlyCameraInputsManager.
  121412. * @param camera Defines the camera the inputs belong to.
  121413. */
  121414. constructor(camera: FlyCamera);
  121415. /**
  121416. * Add keyboard input support to the input manager.
  121417. * @returns the new FlyCameraKeyboardMoveInput().
  121418. */
  121419. addKeyboard(): FlyCameraInputsManager;
  121420. /**
  121421. * Add mouse input support to the input manager.
  121422. * @param touchEnabled Enable touch screen support.
  121423. * @returns the new FlyCameraMouseInput().
  121424. */
  121425. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  121426. }
  121427. }
  121428. declare module BABYLON {
  121429. /**
  121430. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121431. * such as in a 3D Space Shooter or a Flight Simulator.
  121432. */
  121433. export class FlyCamera extends TargetCamera {
  121434. /**
  121435. * Define the collision ellipsoid of the camera.
  121436. * This is helpful for simulating a camera body, like a player's body.
  121437. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121438. */
  121439. ellipsoid: Vector3;
  121440. /**
  121441. * Define an offset for the position of the ellipsoid around the camera.
  121442. * This can be helpful if the camera is attached away from the player's body center,
  121443. * such as at its head.
  121444. */
  121445. ellipsoidOffset: Vector3;
  121446. /**
  121447. * Enable or disable collisions of the camera with the rest of the scene objects.
  121448. */
  121449. checkCollisions: boolean;
  121450. /**
  121451. * Enable or disable gravity on the camera.
  121452. */
  121453. applyGravity: boolean;
  121454. /**
  121455. * Define the current direction the camera is moving to.
  121456. */
  121457. cameraDirection: Vector3;
  121458. /**
  121459. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  121460. * This overrides and empties cameraRotation.
  121461. */
  121462. rotationQuaternion: Quaternion;
  121463. /**
  121464. * Track Roll to maintain the wanted Rolling when looking around.
  121465. */
  121466. _trackRoll: number;
  121467. /**
  121468. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  121469. */
  121470. rollCorrect: number;
  121471. /**
  121472. * Mimic a banked turn, Rolling the camera when Yawing.
  121473. * It's recommended to use rollCorrect = 10 for faster banking correction.
  121474. */
  121475. bankedTurn: boolean;
  121476. /**
  121477. * Limit in radians for how much Roll banking will add. (Default: 90°)
  121478. */
  121479. bankedTurnLimit: number;
  121480. /**
  121481. * Value of 0 disables the banked Roll.
  121482. * Value of 1 is equal to the Yaw angle in radians.
  121483. */
  121484. bankedTurnMultiplier: number;
  121485. /**
  121486. * The inputs manager loads all the input sources, such as keyboard and mouse.
  121487. */
  121488. inputs: FlyCameraInputsManager;
  121489. /**
  121490. * Gets the input sensibility for mouse input.
  121491. * Higher values reduce sensitivity.
  121492. */
  121493. get angularSensibility(): number;
  121494. /**
  121495. * Sets the input sensibility for a mouse input.
  121496. * Higher values reduce sensitivity.
  121497. */
  121498. set angularSensibility(value: number);
  121499. /**
  121500. * Get the keys for camera movement forward.
  121501. */
  121502. get keysForward(): number[];
  121503. /**
  121504. * Set the keys for camera movement forward.
  121505. */
  121506. set keysForward(value: number[]);
  121507. /**
  121508. * Get the keys for camera movement backward.
  121509. */
  121510. get keysBackward(): number[];
  121511. set keysBackward(value: number[]);
  121512. /**
  121513. * Get the keys for camera movement up.
  121514. */
  121515. get keysUp(): number[];
  121516. /**
  121517. * Set the keys for camera movement up.
  121518. */
  121519. set keysUp(value: number[]);
  121520. /**
  121521. * Get the keys for camera movement down.
  121522. */
  121523. get keysDown(): number[];
  121524. /**
  121525. * Set the keys for camera movement down.
  121526. */
  121527. set keysDown(value: number[]);
  121528. /**
  121529. * Get the keys for camera movement left.
  121530. */
  121531. get keysLeft(): number[];
  121532. /**
  121533. * Set the keys for camera movement left.
  121534. */
  121535. set keysLeft(value: number[]);
  121536. /**
  121537. * Set the keys for camera movement right.
  121538. */
  121539. get keysRight(): number[];
  121540. /**
  121541. * Set the keys for camera movement right.
  121542. */
  121543. set keysRight(value: number[]);
  121544. /**
  121545. * Event raised when the camera collides with a mesh in the scene.
  121546. */
  121547. onCollide: (collidedMesh: AbstractMesh) => void;
  121548. private _collider;
  121549. private _needMoveForGravity;
  121550. private _oldPosition;
  121551. private _diffPosition;
  121552. private _newPosition;
  121553. /** @hidden */
  121554. _localDirection: Vector3;
  121555. /** @hidden */
  121556. _transformedDirection: Vector3;
  121557. /**
  121558. * Instantiates a FlyCamera.
  121559. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121560. * such as in a 3D Space Shooter or a Flight Simulator.
  121561. * @param name Define the name of the camera in the scene.
  121562. * @param position Define the starting position of the camera in the scene.
  121563. * @param scene Define the scene the camera belongs to.
  121564. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  121565. */
  121566. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121567. /**
  121568. * Attach a control to the HTML DOM element.
  121569. * @param element Defines the element that listens to the input events.
  121570. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  121571. */
  121572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121573. /**
  121574. * Detach a control from the HTML DOM element.
  121575. * The camera will stop reacting to that input.
  121576. * @param element Defines the element that listens to the input events.
  121577. */
  121578. detachControl(element: HTMLElement): void;
  121579. private _collisionMask;
  121580. /**
  121581. * Get the mask that the camera ignores in collision events.
  121582. */
  121583. get collisionMask(): number;
  121584. /**
  121585. * Set the mask that the camera ignores in collision events.
  121586. */
  121587. set collisionMask(mask: number);
  121588. /** @hidden */
  121589. _collideWithWorld(displacement: Vector3): void;
  121590. /** @hidden */
  121591. private _onCollisionPositionChange;
  121592. /** @hidden */
  121593. _checkInputs(): void;
  121594. /** @hidden */
  121595. _decideIfNeedsToMove(): boolean;
  121596. /** @hidden */
  121597. _updatePosition(): void;
  121598. /**
  121599. * Restore the Roll to its target value at the rate specified.
  121600. * @param rate - Higher means slower restoring.
  121601. * @hidden
  121602. */
  121603. restoreRoll(rate: number): void;
  121604. /**
  121605. * Destroy the camera and release the current resources held by it.
  121606. */
  121607. dispose(): void;
  121608. /**
  121609. * Get the current object class name.
  121610. * @returns the class name.
  121611. */
  121612. getClassName(): string;
  121613. }
  121614. }
  121615. declare module BABYLON {
  121616. /**
  121617. * Listen to keyboard events to control the camera.
  121618. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121619. */
  121620. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  121621. /**
  121622. * Defines the camera the input is attached to.
  121623. */
  121624. camera: FlyCamera;
  121625. /**
  121626. * The list of keyboard keys used to control the forward move of the camera.
  121627. */
  121628. keysForward: number[];
  121629. /**
  121630. * The list of keyboard keys used to control the backward move of the camera.
  121631. */
  121632. keysBackward: number[];
  121633. /**
  121634. * The list of keyboard keys used to control the forward move of the camera.
  121635. */
  121636. keysUp: number[];
  121637. /**
  121638. * The list of keyboard keys used to control the backward move of the camera.
  121639. */
  121640. keysDown: number[];
  121641. /**
  121642. * The list of keyboard keys used to control the right strafe move of the camera.
  121643. */
  121644. keysRight: number[];
  121645. /**
  121646. * The list of keyboard keys used to control the left strafe move of the camera.
  121647. */
  121648. keysLeft: number[];
  121649. private _keys;
  121650. private _onCanvasBlurObserver;
  121651. private _onKeyboardObserver;
  121652. private _engine;
  121653. private _scene;
  121654. /**
  121655. * Attach the input controls to a specific dom element to get the input from.
  121656. * @param element Defines the element the controls should be listened from
  121657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121658. */
  121659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121660. /**
  121661. * Detach the current controls from the specified dom element.
  121662. * @param element Defines the element to stop listening the inputs from
  121663. */
  121664. detachControl(element: Nullable<HTMLElement>): void;
  121665. /**
  121666. * Gets the class name of the current intput.
  121667. * @returns the class name
  121668. */
  121669. getClassName(): string;
  121670. /** @hidden */
  121671. _onLostFocus(e: FocusEvent): void;
  121672. /**
  121673. * Get the friendly name associated with the input class.
  121674. * @returns the input friendly name
  121675. */
  121676. getSimpleName(): string;
  121677. /**
  121678. * Update the current camera state depending on the inputs that have been used this frame.
  121679. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121680. */
  121681. checkInputs(): void;
  121682. }
  121683. }
  121684. declare module BABYLON {
  121685. /**
  121686. * Manage the mouse wheel inputs to control a follow camera.
  121687. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121688. */
  121689. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  121690. /**
  121691. * Defines the camera the input is attached to.
  121692. */
  121693. camera: FollowCamera;
  121694. /**
  121695. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  121696. */
  121697. axisControlRadius: boolean;
  121698. /**
  121699. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  121700. */
  121701. axisControlHeight: boolean;
  121702. /**
  121703. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  121704. */
  121705. axisControlRotation: boolean;
  121706. /**
  121707. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  121708. * relation to mouseWheel events.
  121709. */
  121710. wheelPrecision: number;
  121711. /**
  121712. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121713. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121714. */
  121715. wheelDeltaPercentage: number;
  121716. private _wheel;
  121717. private _observer;
  121718. /**
  121719. * Attach the input controls to a specific dom element to get the input from.
  121720. * @param element Defines the element the controls should be listened from
  121721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121722. */
  121723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121724. /**
  121725. * Detach the current controls from the specified dom element.
  121726. * @param element Defines the element to stop listening the inputs from
  121727. */
  121728. detachControl(element: Nullable<HTMLElement>): void;
  121729. /**
  121730. * Gets the class name of the current intput.
  121731. * @returns the class name
  121732. */
  121733. getClassName(): string;
  121734. /**
  121735. * Get the friendly name associated with the input class.
  121736. * @returns the input friendly name
  121737. */
  121738. getSimpleName(): string;
  121739. }
  121740. }
  121741. declare module BABYLON {
  121742. /**
  121743. * Manage the pointers inputs to control an follow camera.
  121744. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121745. */
  121746. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  121747. /**
  121748. * Defines the camera the input is attached to.
  121749. */
  121750. camera: FollowCamera;
  121751. /**
  121752. * Gets the class name of the current input.
  121753. * @returns the class name
  121754. */
  121755. getClassName(): string;
  121756. /**
  121757. * Defines the pointer angular sensibility along the X axis or how fast is
  121758. * the camera rotating.
  121759. * A negative number will reverse the axis direction.
  121760. */
  121761. angularSensibilityX: number;
  121762. /**
  121763. * Defines the pointer angular sensibility along the Y axis or how fast is
  121764. * the camera rotating.
  121765. * A negative number will reverse the axis direction.
  121766. */
  121767. angularSensibilityY: number;
  121768. /**
  121769. * Defines the pointer pinch precision or how fast is the camera zooming.
  121770. * A negative number will reverse the axis direction.
  121771. */
  121772. pinchPrecision: number;
  121773. /**
  121774. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121775. * from 0.
  121776. * It defines the percentage of current camera.radius to use as delta when
  121777. * pinch zoom is used.
  121778. */
  121779. pinchDeltaPercentage: number;
  121780. /**
  121781. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  121782. */
  121783. axisXControlRadius: boolean;
  121784. /**
  121785. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  121786. */
  121787. axisXControlHeight: boolean;
  121788. /**
  121789. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  121790. */
  121791. axisXControlRotation: boolean;
  121792. /**
  121793. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  121794. */
  121795. axisYControlRadius: boolean;
  121796. /**
  121797. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  121798. */
  121799. axisYControlHeight: boolean;
  121800. /**
  121801. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  121802. */
  121803. axisYControlRotation: boolean;
  121804. /**
  121805. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  121806. */
  121807. axisPinchControlRadius: boolean;
  121808. /**
  121809. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  121810. */
  121811. axisPinchControlHeight: boolean;
  121812. /**
  121813. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  121814. */
  121815. axisPinchControlRotation: boolean;
  121816. /**
  121817. * Log error messages if basic misconfiguration has occurred.
  121818. */
  121819. warningEnable: boolean;
  121820. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121821. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121822. private _warningCounter;
  121823. private _warning;
  121824. }
  121825. }
  121826. declare module BABYLON {
  121827. /**
  121828. * Default Inputs manager for the FollowCamera.
  121829. * It groups all the default supported inputs for ease of use.
  121830. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121831. */
  121832. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  121833. /**
  121834. * Instantiates a new FollowCameraInputsManager.
  121835. * @param camera Defines the camera the inputs belong to
  121836. */
  121837. constructor(camera: FollowCamera);
  121838. /**
  121839. * Add keyboard input support to the input manager.
  121840. * @returns the current input manager
  121841. */
  121842. addKeyboard(): FollowCameraInputsManager;
  121843. /**
  121844. * Add mouse wheel input support to the input manager.
  121845. * @returns the current input manager
  121846. */
  121847. addMouseWheel(): FollowCameraInputsManager;
  121848. /**
  121849. * Add pointers input support to the input manager.
  121850. * @returns the current input manager
  121851. */
  121852. addPointers(): FollowCameraInputsManager;
  121853. /**
  121854. * Add orientation input support to the input manager.
  121855. * @returns the current input manager
  121856. */
  121857. addVRDeviceOrientation(): FollowCameraInputsManager;
  121858. }
  121859. }
  121860. declare module BABYLON {
  121861. /**
  121862. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  121863. * an arc rotate version arcFollowCamera are available.
  121864. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121865. */
  121866. export class FollowCamera extends TargetCamera {
  121867. /**
  121868. * Distance the follow camera should follow an object at
  121869. */
  121870. radius: number;
  121871. /**
  121872. * Minimum allowed distance of the camera to the axis of rotation
  121873. * (The camera can not get closer).
  121874. * This can help limiting how the Camera is able to move in the scene.
  121875. */
  121876. lowerRadiusLimit: Nullable<number>;
  121877. /**
  121878. * Maximum allowed distance of the camera to the axis of rotation
  121879. * (The camera can not get further).
  121880. * This can help limiting how the Camera is able to move in the scene.
  121881. */
  121882. upperRadiusLimit: Nullable<number>;
  121883. /**
  121884. * Define a rotation offset between the camera and the object it follows
  121885. */
  121886. rotationOffset: number;
  121887. /**
  121888. * Minimum allowed angle to camera position relative to target object.
  121889. * This can help limiting how the Camera is able to move in the scene.
  121890. */
  121891. lowerRotationOffsetLimit: Nullable<number>;
  121892. /**
  121893. * Maximum allowed angle to camera position relative to target object.
  121894. * This can help limiting how the Camera is able to move in the scene.
  121895. */
  121896. upperRotationOffsetLimit: Nullable<number>;
  121897. /**
  121898. * Define a height offset between the camera and the object it follows.
  121899. * It can help following an object from the top (like a car chaing a plane)
  121900. */
  121901. heightOffset: number;
  121902. /**
  121903. * Minimum allowed height of camera position relative to target object.
  121904. * This can help limiting how the Camera is able to move in the scene.
  121905. */
  121906. lowerHeightOffsetLimit: Nullable<number>;
  121907. /**
  121908. * Maximum allowed height of camera position relative to target object.
  121909. * This can help limiting how the Camera is able to move in the scene.
  121910. */
  121911. upperHeightOffsetLimit: Nullable<number>;
  121912. /**
  121913. * Define how fast the camera can accelerate to follow it s target.
  121914. */
  121915. cameraAcceleration: number;
  121916. /**
  121917. * Define the speed limit of the camera following an object.
  121918. */
  121919. maxCameraSpeed: number;
  121920. /**
  121921. * Define the target of the camera.
  121922. */
  121923. lockedTarget: Nullable<AbstractMesh>;
  121924. /**
  121925. * Defines the input associated with the camera.
  121926. */
  121927. inputs: FollowCameraInputsManager;
  121928. /**
  121929. * Instantiates the follow camera.
  121930. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121931. * @param name Define the name of the camera in the scene
  121932. * @param position Define the position of the camera
  121933. * @param scene Define the scene the camera belong to
  121934. * @param lockedTarget Define the target of the camera
  121935. */
  121936. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  121937. private _follow;
  121938. /**
  121939. * Attached controls to the current camera.
  121940. * @param element Defines the element the controls should be listened from
  121941. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121942. */
  121943. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121944. /**
  121945. * Detach the current controls from the camera.
  121946. * The camera will stop reacting to inputs.
  121947. * @param element Defines the element to stop listening the inputs from
  121948. */
  121949. detachControl(element: HTMLElement): void;
  121950. /** @hidden */
  121951. _checkInputs(): void;
  121952. private _checkLimits;
  121953. /**
  121954. * Gets the camera class name.
  121955. * @returns the class name
  121956. */
  121957. getClassName(): string;
  121958. }
  121959. /**
  121960. * Arc Rotate version of the follow camera.
  121961. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  121962. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121963. */
  121964. export class ArcFollowCamera extends TargetCamera {
  121965. /** The longitudinal angle of the camera */
  121966. alpha: number;
  121967. /** The latitudinal angle of the camera */
  121968. beta: number;
  121969. /** The radius of the camera from its target */
  121970. radius: number;
  121971. /** Define the camera target (the mesh it should follow) */
  121972. target: Nullable<AbstractMesh>;
  121973. private _cartesianCoordinates;
  121974. /**
  121975. * Instantiates a new ArcFollowCamera
  121976. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121977. * @param name Define the name of the camera
  121978. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  121979. * @param beta Define the rotation angle of the camera around the elevation axis
  121980. * @param radius Define the radius of the camera from its target point
  121981. * @param target Define the target of the camera
  121982. * @param scene Define the scene the camera belongs to
  121983. */
  121984. constructor(name: string,
  121985. /** The longitudinal angle of the camera */
  121986. alpha: number,
  121987. /** The latitudinal angle of the camera */
  121988. beta: number,
  121989. /** The radius of the camera from its target */
  121990. radius: number,
  121991. /** Define the camera target (the mesh it should follow) */
  121992. target: Nullable<AbstractMesh>, scene: Scene);
  121993. private _follow;
  121994. /** @hidden */
  121995. _checkInputs(): void;
  121996. /**
  121997. * Returns the class name of the object.
  121998. * It is mostly used internally for serialization purposes.
  121999. */
  122000. getClassName(): string;
  122001. }
  122002. }
  122003. declare module BABYLON {
  122004. /**
  122005. * Manage the keyboard inputs to control the movement of a follow camera.
  122006. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122007. */
  122008. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  122009. /**
  122010. * Defines the camera the input is attached to.
  122011. */
  122012. camera: FollowCamera;
  122013. /**
  122014. * Defines the list of key codes associated with the up action (increase heightOffset)
  122015. */
  122016. keysHeightOffsetIncr: number[];
  122017. /**
  122018. * Defines the list of key codes associated with the down action (decrease heightOffset)
  122019. */
  122020. keysHeightOffsetDecr: number[];
  122021. /**
  122022. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  122023. */
  122024. keysHeightOffsetModifierAlt: boolean;
  122025. /**
  122026. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  122027. */
  122028. keysHeightOffsetModifierCtrl: boolean;
  122029. /**
  122030. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  122031. */
  122032. keysHeightOffsetModifierShift: boolean;
  122033. /**
  122034. * Defines the list of key codes associated with the left action (increase rotationOffset)
  122035. */
  122036. keysRotationOffsetIncr: number[];
  122037. /**
  122038. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  122039. */
  122040. keysRotationOffsetDecr: number[];
  122041. /**
  122042. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  122043. */
  122044. keysRotationOffsetModifierAlt: boolean;
  122045. /**
  122046. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  122047. */
  122048. keysRotationOffsetModifierCtrl: boolean;
  122049. /**
  122050. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  122051. */
  122052. keysRotationOffsetModifierShift: boolean;
  122053. /**
  122054. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  122055. */
  122056. keysRadiusIncr: number[];
  122057. /**
  122058. * Defines the list of key codes associated with the zoom-out action (increase radius)
  122059. */
  122060. keysRadiusDecr: number[];
  122061. /**
  122062. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  122063. */
  122064. keysRadiusModifierAlt: boolean;
  122065. /**
  122066. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  122067. */
  122068. keysRadiusModifierCtrl: boolean;
  122069. /**
  122070. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  122071. */
  122072. keysRadiusModifierShift: boolean;
  122073. /**
  122074. * Defines the rate of change of heightOffset.
  122075. */
  122076. heightSensibility: number;
  122077. /**
  122078. * Defines the rate of change of rotationOffset.
  122079. */
  122080. rotationSensibility: number;
  122081. /**
  122082. * Defines the rate of change of radius.
  122083. */
  122084. radiusSensibility: number;
  122085. private _keys;
  122086. private _ctrlPressed;
  122087. private _altPressed;
  122088. private _shiftPressed;
  122089. private _onCanvasBlurObserver;
  122090. private _onKeyboardObserver;
  122091. private _engine;
  122092. private _scene;
  122093. /**
  122094. * Attach the input controls to a specific dom element to get the input from.
  122095. * @param element Defines the element the controls should be listened from
  122096. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122097. */
  122098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122099. /**
  122100. * Detach the current controls from the specified dom element.
  122101. * @param element Defines the element to stop listening the inputs from
  122102. */
  122103. detachControl(element: Nullable<HTMLElement>): void;
  122104. /**
  122105. * Update the current camera state depending on the inputs that have been used this frame.
  122106. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122107. */
  122108. checkInputs(): void;
  122109. /**
  122110. * Gets the class name of the current input.
  122111. * @returns the class name
  122112. */
  122113. getClassName(): string;
  122114. /**
  122115. * Get the friendly name associated with the input class.
  122116. * @returns the input friendly name
  122117. */
  122118. getSimpleName(): string;
  122119. /**
  122120. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122121. * allow modification of the heightOffset value.
  122122. */
  122123. private _modifierHeightOffset;
  122124. /**
  122125. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122126. * allow modification of the rotationOffset value.
  122127. */
  122128. private _modifierRotationOffset;
  122129. /**
  122130. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122131. * allow modification of the radius value.
  122132. */
  122133. private _modifierRadius;
  122134. }
  122135. }
  122136. declare module BABYLON {
  122137. interface FreeCameraInputsManager {
  122138. /**
  122139. * @hidden
  122140. */
  122141. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  122142. /**
  122143. * Add orientation input support to the input manager.
  122144. * @returns the current input manager
  122145. */
  122146. addDeviceOrientation(): FreeCameraInputsManager;
  122147. }
  122148. /**
  122149. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  122150. * Screen rotation is taken into account.
  122151. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122152. */
  122153. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  122154. private _camera;
  122155. private _screenOrientationAngle;
  122156. private _constantTranform;
  122157. private _screenQuaternion;
  122158. private _alpha;
  122159. private _beta;
  122160. private _gamma;
  122161. /**
  122162. * Can be used to detect if a device orientation sensor is available on a device
  122163. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  122164. * @returns a promise that will resolve on orientation change
  122165. */
  122166. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  122167. /**
  122168. * @hidden
  122169. */
  122170. _onDeviceOrientationChangedObservable: Observable<void>;
  122171. /**
  122172. * Instantiates a new input
  122173. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122174. */
  122175. constructor();
  122176. /**
  122177. * Define the camera controlled by the input.
  122178. */
  122179. get camera(): FreeCamera;
  122180. set camera(camera: FreeCamera);
  122181. /**
  122182. * Attach the input controls to a specific dom element to get the input from.
  122183. * @param element Defines the element the controls should be listened from
  122184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122185. */
  122186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122187. private _orientationChanged;
  122188. private _deviceOrientation;
  122189. /**
  122190. * Detach the current controls from the specified dom element.
  122191. * @param element Defines the element to stop listening the inputs from
  122192. */
  122193. detachControl(element: Nullable<HTMLElement>): void;
  122194. /**
  122195. * Update the current camera state depending on the inputs that have been used this frame.
  122196. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122197. */
  122198. checkInputs(): void;
  122199. /**
  122200. * Gets the class name of the current intput.
  122201. * @returns the class name
  122202. */
  122203. getClassName(): string;
  122204. /**
  122205. * Get the friendly name associated with the input class.
  122206. * @returns the input friendly name
  122207. */
  122208. getSimpleName(): string;
  122209. }
  122210. }
  122211. declare module BABYLON {
  122212. /**
  122213. * Manage the gamepad inputs to control a free camera.
  122214. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122215. */
  122216. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  122217. /**
  122218. * Define the camera the input is attached to.
  122219. */
  122220. camera: FreeCamera;
  122221. /**
  122222. * Define the Gamepad controlling the input
  122223. */
  122224. gamepad: Nullable<Gamepad>;
  122225. /**
  122226. * Defines the gamepad rotation sensiblity.
  122227. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122228. */
  122229. gamepadAngularSensibility: number;
  122230. /**
  122231. * Defines the gamepad move sensiblity.
  122232. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122233. */
  122234. gamepadMoveSensibility: number;
  122235. private _yAxisScale;
  122236. /**
  122237. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122238. */
  122239. get invertYAxis(): boolean;
  122240. set invertYAxis(value: boolean);
  122241. private _onGamepadConnectedObserver;
  122242. private _onGamepadDisconnectedObserver;
  122243. private _cameraTransform;
  122244. private _deltaTransform;
  122245. private _vector3;
  122246. private _vector2;
  122247. /**
  122248. * Attach the input controls to a specific dom element to get the input from.
  122249. * @param element Defines the element the controls should be listened from
  122250. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122251. */
  122252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122253. /**
  122254. * Detach the current controls from the specified dom element.
  122255. * @param element Defines the element to stop listening the inputs from
  122256. */
  122257. detachControl(element: Nullable<HTMLElement>): void;
  122258. /**
  122259. * Update the current camera state depending on the inputs that have been used this frame.
  122260. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122261. */
  122262. checkInputs(): void;
  122263. /**
  122264. * Gets the class name of the current intput.
  122265. * @returns the class name
  122266. */
  122267. getClassName(): string;
  122268. /**
  122269. * Get the friendly name associated with the input class.
  122270. * @returns the input friendly name
  122271. */
  122272. getSimpleName(): string;
  122273. }
  122274. }
  122275. declare module BABYLON {
  122276. /**
  122277. * Defines the potential axis of a Joystick
  122278. */
  122279. export enum JoystickAxis {
  122280. /** X axis */
  122281. X = 0,
  122282. /** Y axis */
  122283. Y = 1,
  122284. /** Z axis */
  122285. Z = 2
  122286. }
  122287. /**
  122288. * Represents the different customization options available
  122289. * for VirtualJoystick
  122290. */
  122291. interface VirtualJoystickCustomizations {
  122292. /**
  122293. * Size of the joystick's puck
  122294. */
  122295. puckSize: number;
  122296. /**
  122297. * Size of the joystick's container
  122298. */
  122299. containerSize: number;
  122300. /**
  122301. * Color of the joystick && puck
  122302. */
  122303. color: string;
  122304. /**
  122305. * Image URL for the joystick's puck
  122306. */
  122307. puckImage?: string;
  122308. /**
  122309. * Image URL for the joystick's container
  122310. */
  122311. containerImage?: string;
  122312. /**
  122313. * Defines the unmoving position of the joystick container
  122314. */
  122315. position?: {
  122316. x: number;
  122317. y: number;
  122318. };
  122319. /**
  122320. * Defines whether or not the joystick container is always visible
  122321. */
  122322. alwaysVisible: boolean;
  122323. /**
  122324. * Defines whether or not to limit the movement of the puck to the joystick's container
  122325. */
  122326. limitToContainer: boolean;
  122327. }
  122328. /**
  122329. * Class used to define virtual joystick (used in touch mode)
  122330. */
  122331. export class VirtualJoystick {
  122332. /**
  122333. * Gets or sets a boolean indicating that left and right values must be inverted
  122334. */
  122335. reverseLeftRight: boolean;
  122336. /**
  122337. * Gets or sets a boolean indicating that up and down values must be inverted
  122338. */
  122339. reverseUpDown: boolean;
  122340. /**
  122341. * Gets the offset value for the position (ie. the change of the position value)
  122342. */
  122343. deltaPosition: Vector3;
  122344. /**
  122345. * Gets a boolean indicating if the virtual joystick was pressed
  122346. */
  122347. pressed: boolean;
  122348. /**
  122349. * Canvas the virtual joystick will render onto, default z-index of this is 5
  122350. */
  122351. static Canvas: Nullable<HTMLCanvasElement>;
  122352. /**
  122353. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  122354. */
  122355. limitToContainer: boolean;
  122356. private static _globalJoystickIndex;
  122357. private static _alwaysVisibleSticks;
  122358. private static vjCanvasContext;
  122359. private static vjCanvasWidth;
  122360. private static vjCanvasHeight;
  122361. private static halfWidth;
  122362. private static _GetDefaultOptions;
  122363. private _action;
  122364. private _axisTargetedByLeftAndRight;
  122365. private _axisTargetedByUpAndDown;
  122366. private _joystickSensibility;
  122367. private _inversedSensibility;
  122368. private _joystickPointerID;
  122369. private _joystickColor;
  122370. private _joystickPointerPos;
  122371. private _joystickPreviousPointerPos;
  122372. private _joystickPointerStartPos;
  122373. private _deltaJoystickVector;
  122374. private _leftJoystick;
  122375. private _touches;
  122376. private _joystickPosition;
  122377. private _alwaysVisible;
  122378. private _puckImage;
  122379. private _containerImage;
  122380. private _joystickPuckSize;
  122381. private _joystickContainerSize;
  122382. private _clearPuckSize;
  122383. private _clearContainerSize;
  122384. private _clearPuckSizeOffset;
  122385. private _clearContainerSizeOffset;
  122386. private _onPointerDownHandlerRef;
  122387. private _onPointerMoveHandlerRef;
  122388. private _onPointerUpHandlerRef;
  122389. private _onResize;
  122390. /**
  122391. * Creates a new virtual joystick
  122392. * @param leftJoystick defines that the joystick is for left hand (false by default)
  122393. * @param customizations Defines the options we want to customize the VirtualJoystick
  122394. */
  122395. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  122396. /**
  122397. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  122398. * @param newJoystickSensibility defines the new sensibility
  122399. */
  122400. setJoystickSensibility(newJoystickSensibility: number): void;
  122401. private _onPointerDown;
  122402. private _onPointerMove;
  122403. private _onPointerUp;
  122404. /**
  122405. * Change the color of the virtual joystick
  122406. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  122407. */
  122408. setJoystickColor(newColor: string): void;
  122409. /**
  122410. * Size of the joystick's container
  122411. */
  122412. set containerSize(newSize: number);
  122413. get containerSize(): number;
  122414. /**
  122415. * Size of the joystick's puck
  122416. */
  122417. set puckSize(newSize: number);
  122418. get puckSize(): number;
  122419. /**
  122420. * Clears the set position of the joystick
  122421. */
  122422. clearPosition(): void;
  122423. /**
  122424. * Defines whether or not the joystick container is always visible
  122425. */
  122426. set alwaysVisible(value: boolean);
  122427. get alwaysVisible(): boolean;
  122428. /**
  122429. * Sets the constant position of the Joystick container
  122430. * @param x X axis coordinate
  122431. * @param y Y axis coordinate
  122432. */
  122433. setPosition(x: number, y: number): void;
  122434. /**
  122435. * Defines a callback to call when the joystick is touched
  122436. * @param action defines the callback
  122437. */
  122438. setActionOnTouch(action: () => any): void;
  122439. /**
  122440. * Defines which axis you'd like to control for left & right
  122441. * @param axis defines the axis to use
  122442. */
  122443. setAxisForLeftRight(axis: JoystickAxis): void;
  122444. /**
  122445. * Defines which axis you'd like to control for up & down
  122446. * @param axis defines the axis to use
  122447. */
  122448. setAxisForUpDown(axis: JoystickAxis): void;
  122449. /**
  122450. * Clears the canvas from the previous puck / container draw
  122451. */
  122452. private _clearPreviousDraw;
  122453. /**
  122454. * Loads `urlPath` to be used for the container's image
  122455. * @param urlPath defines the urlPath of an image to use
  122456. */
  122457. setContainerImage(urlPath: string): void;
  122458. /**
  122459. * Loads `urlPath` to be used for the puck's image
  122460. * @param urlPath defines the urlPath of an image to use
  122461. */
  122462. setPuckImage(urlPath: string): void;
  122463. /**
  122464. * Draws the Virtual Joystick's container
  122465. */
  122466. private _drawContainer;
  122467. /**
  122468. * Draws the Virtual Joystick's puck
  122469. */
  122470. private _drawPuck;
  122471. private _drawVirtualJoystick;
  122472. /**
  122473. * Release internal HTML canvas
  122474. */
  122475. releaseCanvas(): void;
  122476. }
  122477. }
  122478. declare module BABYLON {
  122479. interface FreeCameraInputsManager {
  122480. /**
  122481. * Add virtual joystick input support to the input manager.
  122482. * @returns the current input manager
  122483. */
  122484. addVirtualJoystick(): FreeCameraInputsManager;
  122485. }
  122486. /**
  122487. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  122488. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122489. */
  122490. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  122491. /**
  122492. * Defines the camera the input is attached to.
  122493. */
  122494. camera: FreeCamera;
  122495. private _leftjoystick;
  122496. private _rightjoystick;
  122497. /**
  122498. * Gets the left stick of the virtual joystick.
  122499. * @returns The virtual Joystick
  122500. */
  122501. getLeftJoystick(): VirtualJoystick;
  122502. /**
  122503. * Gets the right stick of the virtual joystick.
  122504. * @returns The virtual Joystick
  122505. */
  122506. getRightJoystick(): VirtualJoystick;
  122507. /**
  122508. * Update the current camera state depending on the inputs that have been used this frame.
  122509. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122510. */
  122511. checkInputs(): void;
  122512. /**
  122513. * Attach the input controls to a specific dom element to get the input from.
  122514. * @param element Defines the element the controls should be listened from
  122515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122516. */
  122517. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122518. /**
  122519. * Detach the current controls from the specified dom element.
  122520. * @param element Defines the element to stop listening the inputs from
  122521. */
  122522. detachControl(element: Nullable<HTMLElement>): void;
  122523. /**
  122524. * Gets the class name of the current intput.
  122525. * @returns the class name
  122526. */
  122527. getClassName(): string;
  122528. /**
  122529. * Get the friendly name associated with the input class.
  122530. * @returns the input friendly name
  122531. */
  122532. getSimpleName(): string;
  122533. }
  122534. }
  122535. declare module BABYLON {
  122536. /**
  122537. * This represents a FPS type of camera controlled by touch.
  122538. * This is like a universal camera minus the Gamepad controls.
  122539. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  122540. */
  122541. export class TouchCamera extends FreeCamera {
  122542. /**
  122543. * Defines the touch sensibility for rotation.
  122544. * The higher the faster.
  122545. */
  122546. get touchAngularSensibility(): number;
  122547. set touchAngularSensibility(value: number);
  122548. /**
  122549. * Defines the touch sensibility for move.
  122550. * The higher the faster.
  122551. */
  122552. get touchMoveSensibility(): number;
  122553. set touchMoveSensibility(value: number);
  122554. /**
  122555. * Instantiates a new touch camera.
  122556. * This represents a FPS type of camera controlled by touch.
  122557. * This is like a universal camera minus the Gamepad controls.
  122558. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  122559. * @param name Define the name of the camera in the scene
  122560. * @param position Define the start position of the camera in the scene
  122561. * @param scene Define the scene the camera belongs to
  122562. */
  122563. constructor(name: string, position: Vector3, scene: Scene);
  122564. /**
  122565. * Gets the current object class name.
  122566. * @return the class name
  122567. */
  122568. getClassName(): string;
  122569. /** @hidden */
  122570. _setupInputs(): void;
  122571. }
  122572. }
  122573. declare module BABYLON {
  122574. /**
  122575. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  122576. * being tilted forward or back and left or right.
  122577. */
  122578. export class DeviceOrientationCamera extends FreeCamera {
  122579. private _initialQuaternion;
  122580. private _quaternionCache;
  122581. private _tmpDragQuaternion;
  122582. private _disablePointerInputWhenUsingDeviceOrientation;
  122583. /**
  122584. * Creates a new device orientation camera
  122585. * @param name The name of the camera
  122586. * @param position The start position camera
  122587. * @param scene The scene the camera belongs to
  122588. */
  122589. constructor(name: string, position: Vector3, scene: Scene);
  122590. /**
  122591. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  122592. */
  122593. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  122594. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  122595. private _dragFactor;
  122596. /**
  122597. * Enabled turning on the y axis when the orientation sensor is active
  122598. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  122599. */
  122600. enableHorizontalDragging(dragFactor?: number): void;
  122601. /**
  122602. * Gets the current instance class name ("DeviceOrientationCamera").
  122603. * This helps avoiding instanceof at run time.
  122604. * @returns the class name
  122605. */
  122606. getClassName(): string;
  122607. /**
  122608. * @hidden
  122609. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  122610. */
  122611. _checkInputs(): void;
  122612. /**
  122613. * Reset the camera to its default orientation on the specified axis only.
  122614. * @param axis The axis to reset
  122615. */
  122616. resetToCurrentRotation(axis?: Axis): void;
  122617. }
  122618. }
  122619. declare module BABYLON {
  122620. /**
  122621. * Defines supported buttons for XBox360 compatible gamepads
  122622. */
  122623. export enum Xbox360Button {
  122624. /** A */
  122625. A = 0,
  122626. /** B */
  122627. B = 1,
  122628. /** X */
  122629. X = 2,
  122630. /** Y */
  122631. Y = 3,
  122632. /** Left button */
  122633. LB = 4,
  122634. /** Right button */
  122635. RB = 5,
  122636. /** Back */
  122637. Back = 8,
  122638. /** Start */
  122639. Start = 9,
  122640. /** Left stick */
  122641. LeftStick = 10,
  122642. /** Right stick */
  122643. RightStick = 11
  122644. }
  122645. /** Defines values for XBox360 DPad */
  122646. export enum Xbox360Dpad {
  122647. /** Up */
  122648. Up = 12,
  122649. /** Down */
  122650. Down = 13,
  122651. /** Left */
  122652. Left = 14,
  122653. /** Right */
  122654. Right = 15
  122655. }
  122656. /**
  122657. * Defines a XBox360 gamepad
  122658. */
  122659. export class Xbox360Pad extends Gamepad {
  122660. private _leftTrigger;
  122661. private _rightTrigger;
  122662. private _onlefttriggerchanged;
  122663. private _onrighttriggerchanged;
  122664. private _onbuttondown;
  122665. private _onbuttonup;
  122666. private _ondpaddown;
  122667. private _ondpadup;
  122668. /** Observable raised when a button is pressed */
  122669. onButtonDownObservable: Observable<Xbox360Button>;
  122670. /** Observable raised when a button is released */
  122671. onButtonUpObservable: Observable<Xbox360Button>;
  122672. /** Observable raised when a pad is pressed */
  122673. onPadDownObservable: Observable<Xbox360Dpad>;
  122674. /** Observable raised when a pad is released */
  122675. onPadUpObservable: Observable<Xbox360Dpad>;
  122676. private _buttonA;
  122677. private _buttonB;
  122678. private _buttonX;
  122679. private _buttonY;
  122680. private _buttonBack;
  122681. private _buttonStart;
  122682. private _buttonLB;
  122683. private _buttonRB;
  122684. private _buttonLeftStick;
  122685. private _buttonRightStick;
  122686. private _dPadUp;
  122687. private _dPadDown;
  122688. private _dPadLeft;
  122689. private _dPadRight;
  122690. private _isXboxOnePad;
  122691. /**
  122692. * Creates a new XBox360 gamepad object
  122693. * @param id defines the id of this gamepad
  122694. * @param index defines its index
  122695. * @param gamepad defines the internal HTML gamepad object
  122696. * @param xboxOne defines if it is a XBox One gamepad
  122697. */
  122698. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  122699. /**
  122700. * Defines the callback to call when left trigger is pressed
  122701. * @param callback defines the callback to use
  122702. */
  122703. onlefttriggerchanged(callback: (value: number) => void): void;
  122704. /**
  122705. * Defines the callback to call when right trigger is pressed
  122706. * @param callback defines the callback to use
  122707. */
  122708. onrighttriggerchanged(callback: (value: number) => void): void;
  122709. /**
  122710. * Gets the left trigger value
  122711. */
  122712. get leftTrigger(): number;
  122713. /**
  122714. * Sets the left trigger value
  122715. */
  122716. set leftTrigger(newValue: number);
  122717. /**
  122718. * Gets the right trigger value
  122719. */
  122720. get rightTrigger(): number;
  122721. /**
  122722. * Sets the right trigger value
  122723. */
  122724. set rightTrigger(newValue: number);
  122725. /**
  122726. * Defines the callback to call when a button is pressed
  122727. * @param callback defines the callback to use
  122728. */
  122729. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  122730. /**
  122731. * Defines the callback to call when a button is released
  122732. * @param callback defines the callback to use
  122733. */
  122734. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  122735. /**
  122736. * Defines the callback to call when a pad is pressed
  122737. * @param callback defines the callback to use
  122738. */
  122739. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  122740. /**
  122741. * Defines the callback to call when a pad is released
  122742. * @param callback defines the callback to use
  122743. */
  122744. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  122745. private _setButtonValue;
  122746. private _setDPadValue;
  122747. /**
  122748. * Gets the value of the `A` button
  122749. */
  122750. get buttonA(): number;
  122751. /**
  122752. * Sets the value of the `A` button
  122753. */
  122754. set buttonA(value: number);
  122755. /**
  122756. * Gets the value of the `B` button
  122757. */
  122758. get buttonB(): number;
  122759. /**
  122760. * Sets the value of the `B` button
  122761. */
  122762. set buttonB(value: number);
  122763. /**
  122764. * Gets the value of the `X` button
  122765. */
  122766. get buttonX(): number;
  122767. /**
  122768. * Sets the value of the `X` button
  122769. */
  122770. set buttonX(value: number);
  122771. /**
  122772. * Gets the value of the `Y` button
  122773. */
  122774. get buttonY(): number;
  122775. /**
  122776. * Sets the value of the `Y` button
  122777. */
  122778. set buttonY(value: number);
  122779. /**
  122780. * Gets the value of the `Start` button
  122781. */
  122782. get buttonStart(): number;
  122783. /**
  122784. * Sets the value of the `Start` button
  122785. */
  122786. set buttonStart(value: number);
  122787. /**
  122788. * Gets the value of the `Back` button
  122789. */
  122790. get buttonBack(): number;
  122791. /**
  122792. * Sets the value of the `Back` button
  122793. */
  122794. set buttonBack(value: number);
  122795. /**
  122796. * Gets the value of the `Left` button
  122797. */
  122798. get buttonLB(): number;
  122799. /**
  122800. * Sets the value of the `Left` button
  122801. */
  122802. set buttonLB(value: number);
  122803. /**
  122804. * Gets the value of the `Right` button
  122805. */
  122806. get buttonRB(): number;
  122807. /**
  122808. * Sets the value of the `Right` button
  122809. */
  122810. set buttonRB(value: number);
  122811. /**
  122812. * Gets the value of the Left joystick
  122813. */
  122814. get buttonLeftStick(): number;
  122815. /**
  122816. * Sets the value of the Left joystick
  122817. */
  122818. set buttonLeftStick(value: number);
  122819. /**
  122820. * Gets the value of the Right joystick
  122821. */
  122822. get buttonRightStick(): number;
  122823. /**
  122824. * Sets the value of the Right joystick
  122825. */
  122826. set buttonRightStick(value: number);
  122827. /**
  122828. * Gets the value of D-pad up
  122829. */
  122830. get dPadUp(): number;
  122831. /**
  122832. * Sets the value of D-pad up
  122833. */
  122834. set dPadUp(value: number);
  122835. /**
  122836. * Gets the value of D-pad down
  122837. */
  122838. get dPadDown(): number;
  122839. /**
  122840. * Sets the value of D-pad down
  122841. */
  122842. set dPadDown(value: number);
  122843. /**
  122844. * Gets the value of D-pad left
  122845. */
  122846. get dPadLeft(): number;
  122847. /**
  122848. * Sets the value of D-pad left
  122849. */
  122850. set dPadLeft(value: number);
  122851. /**
  122852. * Gets the value of D-pad right
  122853. */
  122854. get dPadRight(): number;
  122855. /**
  122856. * Sets the value of D-pad right
  122857. */
  122858. set dPadRight(value: number);
  122859. /**
  122860. * Force the gamepad to synchronize with device values
  122861. */
  122862. update(): void;
  122863. /**
  122864. * Disposes the gamepad
  122865. */
  122866. dispose(): void;
  122867. }
  122868. }
  122869. declare module BABYLON {
  122870. /**
  122871. * Defines supported buttons for DualShock compatible gamepads
  122872. */
  122873. export enum DualShockButton {
  122874. /** Cross */
  122875. Cross = 0,
  122876. /** Circle */
  122877. Circle = 1,
  122878. /** Square */
  122879. Square = 2,
  122880. /** Triangle */
  122881. Triangle = 3,
  122882. /** L1 */
  122883. L1 = 4,
  122884. /** R1 */
  122885. R1 = 5,
  122886. /** Share */
  122887. Share = 8,
  122888. /** Options */
  122889. Options = 9,
  122890. /** Left stick */
  122891. LeftStick = 10,
  122892. /** Right stick */
  122893. RightStick = 11
  122894. }
  122895. /** Defines values for DualShock DPad */
  122896. export enum DualShockDpad {
  122897. /** Up */
  122898. Up = 12,
  122899. /** Down */
  122900. Down = 13,
  122901. /** Left */
  122902. Left = 14,
  122903. /** Right */
  122904. Right = 15
  122905. }
  122906. /**
  122907. * Defines a DualShock gamepad
  122908. */
  122909. export class DualShockPad extends Gamepad {
  122910. private _leftTrigger;
  122911. private _rightTrigger;
  122912. private _onlefttriggerchanged;
  122913. private _onrighttriggerchanged;
  122914. private _onbuttondown;
  122915. private _onbuttonup;
  122916. private _ondpaddown;
  122917. private _ondpadup;
  122918. /** Observable raised when a button is pressed */
  122919. onButtonDownObservable: Observable<DualShockButton>;
  122920. /** Observable raised when a button is released */
  122921. onButtonUpObservable: Observable<DualShockButton>;
  122922. /** Observable raised when a pad is pressed */
  122923. onPadDownObservable: Observable<DualShockDpad>;
  122924. /** Observable raised when a pad is released */
  122925. onPadUpObservable: Observable<DualShockDpad>;
  122926. private _buttonCross;
  122927. private _buttonCircle;
  122928. private _buttonSquare;
  122929. private _buttonTriangle;
  122930. private _buttonShare;
  122931. private _buttonOptions;
  122932. private _buttonL1;
  122933. private _buttonR1;
  122934. private _buttonLeftStick;
  122935. private _buttonRightStick;
  122936. private _dPadUp;
  122937. private _dPadDown;
  122938. private _dPadLeft;
  122939. private _dPadRight;
  122940. /**
  122941. * Creates a new DualShock gamepad object
  122942. * @param id defines the id of this gamepad
  122943. * @param index defines its index
  122944. * @param gamepad defines the internal HTML gamepad object
  122945. */
  122946. constructor(id: string, index: number, gamepad: any);
  122947. /**
  122948. * Defines the callback to call when left trigger is pressed
  122949. * @param callback defines the callback to use
  122950. */
  122951. onlefttriggerchanged(callback: (value: number) => void): void;
  122952. /**
  122953. * Defines the callback to call when right trigger is pressed
  122954. * @param callback defines the callback to use
  122955. */
  122956. onrighttriggerchanged(callback: (value: number) => void): void;
  122957. /**
  122958. * Gets the left trigger value
  122959. */
  122960. get leftTrigger(): number;
  122961. /**
  122962. * Sets the left trigger value
  122963. */
  122964. set leftTrigger(newValue: number);
  122965. /**
  122966. * Gets the right trigger value
  122967. */
  122968. get rightTrigger(): number;
  122969. /**
  122970. * Sets the right trigger value
  122971. */
  122972. set rightTrigger(newValue: number);
  122973. /**
  122974. * Defines the callback to call when a button is pressed
  122975. * @param callback defines the callback to use
  122976. */
  122977. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  122978. /**
  122979. * Defines the callback to call when a button is released
  122980. * @param callback defines the callback to use
  122981. */
  122982. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  122983. /**
  122984. * Defines the callback to call when a pad is pressed
  122985. * @param callback defines the callback to use
  122986. */
  122987. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  122988. /**
  122989. * Defines the callback to call when a pad is released
  122990. * @param callback defines the callback to use
  122991. */
  122992. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  122993. private _setButtonValue;
  122994. private _setDPadValue;
  122995. /**
  122996. * Gets the value of the `Cross` button
  122997. */
  122998. get buttonCross(): number;
  122999. /**
  123000. * Sets the value of the `Cross` button
  123001. */
  123002. set buttonCross(value: number);
  123003. /**
  123004. * Gets the value of the `Circle` button
  123005. */
  123006. get buttonCircle(): number;
  123007. /**
  123008. * Sets the value of the `Circle` button
  123009. */
  123010. set buttonCircle(value: number);
  123011. /**
  123012. * Gets the value of the `Square` button
  123013. */
  123014. get buttonSquare(): number;
  123015. /**
  123016. * Sets the value of the `Square` button
  123017. */
  123018. set buttonSquare(value: number);
  123019. /**
  123020. * Gets the value of the `Triangle` button
  123021. */
  123022. get buttonTriangle(): number;
  123023. /**
  123024. * Sets the value of the `Triangle` button
  123025. */
  123026. set buttonTriangle(value: number);
  123027. /**
  123028. * Gets the value of the `Options` button
  123029. */
  123030. get buttonOptions(): number;
  123031. /**
  123032. * Sets the value of the `Options` button
  123033. */
  123034. set buttonOptions(value: number);
  123035. /**
  123036. * Gets the value of the `Share` button
  123037. */
  123038. get buttonShare(): number;
  123039. /**
  123040. * Sets the value of the `Share` button
  123041. */
  123042. set buttonShare(value: number);
  123043. /**
  123044. * Gets the value of the `L1` button
  123045. */
  123046. get buttonL1(): number;
  123047. /**
  123048. * Sets the value of the `L1` button
  123049. */
  123050. set buttonL1(value: number);
  123051. /**
  123052. * Gets the value of the `R1` button
  123053. */
  123054. get buttonR1(): number;
  123055. /**
  123056. * Sets the value of the `R1` button
  123057. */
  123058. set buttonR1(value: number);
  123059. /**
  123060. * Gets the value of the Left joystick
  123061. */
  123062. get buttonLeftStick(): number;
  123063. /**
  123064. * Sets the value of the Left joystick
  123065. */
  123066. set buttonLeftStick(value: number);
  123067. /**
  123068. * Gets the value of the Right joystick
  123069. */
  123070. get buttonRightStick(): number;
  123071. /**
  123072. * Sets the value of the Right joystick
  123073. */
  123074. set buttonRightStick(value: number);
  123075. /**
  123076. * Gets the value of D-pad up
  123077. */
  123078. get dPadUp(): number;
  123079. /**
  123080. * Sets the value of D-pad up
  123081. */
  123082. set dPadUp(value: number);
  123083. /**
  123084. * Gets the value of D-pad down
  123085. */
  123086. get dPadDown(): number;
  123087. /**
  123088. * Sets the value of D-pad down
  123089. */
  123090. set dPadDown(value: number);
  123091. /**
  123092. * Gets the value of D-pad left
  123093. */
  123094. get dPadLeft(): number;
  123095. /**
  123096. * Sets the value of D-pad left
  123097. */
  123098. set dPadLeft(value: number);
  123099. /**
  123100. * Gets the value of D-pad right
  123101. */
  123102. get dPadRight(): number;
  123103. /**
  123104. * Sets the value of D-pad right
  123105. */
  123106. set dPadRight(value: number);
  123107. /**
  123108. * Force the gamepad to synchronize with device values
  123109. */
  123110. update(): void;
  123111. /**
  123112. * Disposes the gamepad
  123113. */
  123114. dispose(): void;
  123115. }
  123116. }
  123117. declare module BABYLON {
  123118. /**
  123119. * Manager for handling gamepads
  123120. */
  123121. export class GamepadManager {
  123122. private _scene?;
  123123. private _babylonGamepads;
  123124. private _oneGamepadConnected;
  123125. /** @hidden */
  123126. _isMonitoring: boolean;
  123127. private _gamepadEventSupported;
  123128. private _gamepadSupport?;
  123129. /**
  123130. * observable to be triggered when the gamepad controller has been connected
  123131. */
  123132. onGamepadConnectedObservable: Observable<Gamepad>;
  123133. /**
  123134. * observable to be triggered when the gamepad controller has been disconnected
  123135. */
  123136. onGamepadDisconnectedObservable: Observable<Gamepad>;
  123137. private _onGamepadConnectedEvent;
  123138. private _onGamepadDisconnectedEvent;
  123139. /**
  123140. * Initializes the gamepad manager
  123141. * @param _scene BabylonJS scene
  123142. */
  123143. constructor(_scene?: Scene | undefined);
  123144. /**
  123145. * The gamepads in the game pad manager
  123146. */
  123147. get gamepads(): Gamepad[];
  123148. /**
  123149. * Get the gamepad controllers based on type
  123150. * @param type The type of gamepad controller
  123151. * @returns Nullable gamepad
  123152. */
  123153. getGamepadByType(type?: number): Nullable<Gamepad>;
  123154. /**
  123155. * Disposes the gamepad manager
  123156. */
  123157. dispose(): void;
  123158. private _addNewGamepad;
  123159. private _startMonitoringGamepads;
  123160. private _stopMonitoringGamepads;
  123161. /** @hidden */
  123162. _checkGamepadsStatus(): void;
  123163. private _updateGamepadObjects;
  123164. }
  123165. }
  123166. declare module BABYLON {
  123167. interface Scene {
  123168. /** @hidden */
  123169. _gamepadManager: Nullable<GamepadManager>;
  123170. /**
  123171. * Gets the gamepad manager associated with the scene
  123172. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  123173. */
  123174. gamepadManager: GamepadManager;
  123175. }
  123176. /**
  123177. * Interface representing a free camera inputs manager
  123178. */
  123179. interface FreeCameraInputsManager {
  123180. /**
  123181. * Adds gamepad input support to the FreeCameraInputsManager.
  123182. * @returns the FreeCameraInputsManager
  123183. */
  123184. addGamepad(): FreeCameraInputsManager;
  123185. }
  123186. /**
  123187. * Interface representing an arc rotate camera inputs manager
  123188. */
  123189. interface ArcRotateCameraInputsManager {
  123190. /**
  123191. * Adds gamepad input support to the ArcRotateCamera InputManager.
  123192. * @returns the camera inputs manager
  123193. */
  123194. addGamepad(): ArcRotateCameraInputsManager;
  123195. }
  123196. /**
  123197. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  123198. */
  123199. export class GamepadSystemSceneComponent implements ISceneComponent {
  123200. /**
  123201. * The component name helpfull to identify the component in the list of scene components.
  123202. */
  123203. readonly name: string;
  123204. /**
  123205. * The scene the component belongs to.
  123206. */
  123207. scene: Scene;
  123208. /**
  123209. * Creates a new instance of the component for the given scene
  123210. * @param scene Defines the scene to register the component in
  123211. */
  123212. constructor(scene: Scene);
  123213. /**
  123214. * Registers the component in a given scene
  123215. */
  123216. register(): void;
  123217. /**
  123218. * Rebuilds the elements related to this component in case of
  123219. * context lost for instance.
  123220. */
  123221. rebuild(): void;
  123222. /**
  123223. * Disposes the component and the associated ressources
  123224. */
  123225. dispose(): void;
  123226. private _beforeCameraUpdate;
  123227. }
  123228. }
  123229. declare module BABYLON {
  123230. /**
  123231. * 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,
  123232. * which still works and will still be found in many Playgrounds.
  123233. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123234. */
  123235. export class UniversalCamera extends TouchCamera {
  123236. /**
  123237. * Defines the gamepad rotation sensiblity.
  123238. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123239. */
  123240. get gamepadAngularSensibility(): number;
  123241. set gamepadAngularSensibility(value: number);
  123242. /**
  123243. * Defines the gamepad move sensiblity.
  123244. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123245. */
  123246. get gamepadMoveSensibility(): number;
  123247. set gamepadMoveSensibility(value: number);
  123248. /**
  123249. * 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,
  123250. * which still works and will still be found in many Playgrounds.
  123251. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123252. * @param name Define the name of the camera in the scene
  123253. * @param position Define the start position of the camera in the scene
  123254. * @param scene Define the scene the camera belongs to
  123255. */
  123256. constructor(name: string, position: Vector3, scene: Scene);
  123257. /**
  123258. * Gets the current object class name.
  123259. * @return the class name
  123260. */
  123261. getClassName(): string;
  123262. }
  123263. }
  123264. declare module BABYLON {
  123265. /**
  123266. * This represents a FPS type of camera. This is only here for back compat purpose.
  123267. * Please use the UniversalCamera instead as both are identical.
  123268. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123269. */
  123270. export class GamepadCamera extends UniversalCamera {
  123271. /**
  123272. * Instantiates a new Gamepad Camera
  123273. * This represents a FPS type of camera. This is only here for back compat purpose.
  123274. * Please use the UniversalCamera instead as both are identical.
  123275. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123276. * @param name Define the name of the camera in the scene
  123277. * @param position Define the start position of the camera in the scene
  123278. * @param scene Define the scene the camera belongs to
  123279. */
  123280. constructor(name: string, position: Vector3, scene: Scene);
  123281. /**
  123282. * Gets the current object class name.
  123283. * @return the class name
  123284. */
  123285. getClassName(): string;
  123286. }
  123287. }
  123288. declare module BABYLON {
  123289. /** @hidden */
  123290. export var passPixelShader: {
  123291. name: string;
  123292. shader: string;
  123293. };
  123294. }
  123295. declare module BABYLON {
  123296. /** @hidden */
  123297. export var passCubePixelShader: {
  123298. name: string;
  123299. shader: string;
  123300. };
  123301. }
  123302. declare module BABYLON {
  123303. /**
  123304. * PassPostProcess which produces an output the same as it's input
  123305. */
  123306. export class PassPostProcess extends PostProcess {
  123307. /**
  123308. * Creates the PassPostProcess
  123309. * @param name The name of the effect.
  123310. * @param options The required width/height ratio to downsize to before computing the render pass.
  123311. * @param camera The camera to apply the render pass to.
  123312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123313. * @param engine The engine which the post process will be applied. (default: current engine)
  123314. * @param reusable If the post process can be reused on the same frame. (default: false)
  123315. * @param textureType The type of texture to be used when performing the post processing.
  123316. * @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)
  123317. */
  123318. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123319. }
  123320. /**
  123321. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  123322. */
  123323. export class PassCubePostProcess extends PostProcess {
  123324. private _face;
  123325. /**
  123326. * Gets or sets the cube face to display.
  123327. * * 0 is +X
  123328. * * 1 is -X
  123329. * * 2 is +Y
  123330. * * 3 is -Y
  123331. * * 4 is +Z
  123332. * * 5 is -Z
  123333. */
  123334. get face(): number;
  123335. set face(value: number);
  123336. /**
  123337. * Creates the PassCubePostProcess
  123338. * @param name The name of the effect.
  123339. * @param options The required width/height ratio to downsize to before computing the render pass.
  123340. * @param camera The camera to apply the render pass to.
  123341. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123342. * @param engine The engine which the post process will be applied. (default: current engine)
  123343. * @param reusable If the post process can be reused on the same frame. (default: false)
  123344. * @param textureType The type of texture to be used when performing the post processing.
  123345. * @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)
  123346. */
  123347. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123348. }
  123349. }
  123350. declare module BABYLON {
  123351. /** @hidden */
  123352. export var anaglyphPixelShader: {
  123353. name: string;
  123354. shader: string;
  123355. };
  123356. }
  123357. declare module BABYLON {
  123358. /**
  123359. * Postprocess used to generate anaglyphic rendering
  123360. */
  123361. export class AnaglyphPostProcess extends PostProcess {
  123362. private _passedProcess;
  123363. /**
  123364. * Creates a new AnaglyphPostProcess
  123365. * @param name defines postprocess name
  123366. * @param options defines creation options or target ratio scale
  123367. * @param rigCameras defines cameras using this postprocess
  123368. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  123369. * @param engine defines hosting engine
  123370. * @param reusable defines if the postprocess will be reused multiple times per frame
  123371. */
  123372. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  123373. }
  123374. }
  123375. declare module BABYLON {
  123376. /**
  123377. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  123378. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123379. */
  123380. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  123381. /**
  123382. * Creates a new AnaglyphArcRotateCamera
  123383. * @param name defines camera name
  123384. * @param alpha defines alpha angle (in radians)
  123385. * @param beta defines beta angle (in radians)
  123386. * @param radius defines radius
  123387. * @param target defines camera target
  123388. * @param interaxialDistance defines distance between each color axis
  123389. * @param scene defines the hosting scene
  123390. */
  123391. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  123392. /**
  123393. * Gets camera class name
  123394. * @returns AnaglyphArcRotateCamera
  123395. */
  123396. getClassName(): string;
  123397. }
  123398. }
  123399. declare module BABYLON {
  123400. /**
  123401. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  123402. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123403. */
  123404. export class AnaglyphFreeCamera extends FreeCamera {
  123405. /**
  123406. * Creates a new AnaglyphFreeCamera
  123407. * @param name defines camera name
  123408. * @param position defines initial position
  123409. * @param interaxialDistance defines distance between each color axis
  123410. * @param scene defines the hosting scene
  123411. */
  123412. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123413. /**
  123414. * Gets camera class name
  123415. * @returns AnaglyphFreeCamera
  123416. */
  123417. getClassName(): string;
  123418. }
  123419. }
  123420. declare module BABYLON {
  123421. /**
  123422. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  123423. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123424. */
  123425. export class AnaglyphGamepadCamera extends GamepadCamera {
  123426. /**
  123427. * Creates a new AnaglyphGamepadCamera
  123428. * @param name defines camera name
  123429. * @param position defines initial position
  123430. * @param interaxialDistance defines distance between each color axis
  123431. * @param scene defines the hosting scene
  123432. */
  123433. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123434. /**
  123435. * Gets camera class name
  123436. * @returns AnaglyphGamepadCamera
  123437. */
  123438. getClassName(): string;
  123439. }
  123440. }
  123441. declare module BABYLON {
  123442. /**
  123443. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  123444. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123445. */
  123446. export class AnaglyphUniversalCamera extends UniversalCamera {
  123447. /**
  123448. * Creates a new AnaglyphUniversalCamera
  123449. * @param name defines camera name
  123450. * @param position defines initial position
  123451. * @param interaxialDistance defines distance between each color axis
  123452. * @param scene defines the hosting scene
  123453. */
  123454. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123455. /**
  123456. * Gets camera class name
  123457. * @returns AnaglyphUniversalCamera
  123458. */
  123459. getClassName(): string;
  123460. }
  123461. }
  123462. declare module BABYLON {
  123463. /**
  123464. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  123465. * @see https://doc.babylonjs.com/features/cameras
  123466. */
  123467. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  123468. /**
  123469. * Creates a new StereoscopicArcRotateCamera
  123470. * @param name defines camera name
  123471. * @param alpha defines alpha angle (in radians)
  123472. * @param beta defines beta angle (in radians)
  123473. * @param radius defines radius
  123474. * @param target defines camera target
  123475. * @param interaxialDistance defines distance between each color axis
  123476. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123477. * @param scene defines the hosting scene
  123478. */
  123479. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123480. /**
  123481. * Gets camera class name
  123482. * @returns StereoscopicArcRotateCamera
  123483. */
  123484. getClassName(): string;
  123485. }
  123486. }
  123487. declare module BABYLON {
  123488. /**
  123489. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  123490. * @see https://doc.babylonjs.com/features/cameras
  123491. */
  123492. export class StereoscopicFreeCamera extends FreeCamera {
  123493. /**
  123494. * Creates a new StereoscopicFreeCamera
  123495. * @param name defines camera name
  123496. * @param position defines initial position
  123497. * @param interaxialDistance defines distance between each color axis
  123498. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123499. * @param scene defines the hosting scene
  123500. */
  123501. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123502. /**
  123503. * Gets camera class name
  123504. * @returns StereoscopicFreeCamera
  123505. */
  123506. getClassName(): string;
  123507. }
  123508. }
  123509. declare module BABYLON {
  123510. /**
  123511. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  123512. * @see https://doc.babylonjs.com/features/cameras
  123513. */
  123514. export class StereoscopicGamepadCamera extends GamepadCamera {
  123515. /**
  123516. * Creates a new StereoscopicGamepadCamera
  123517. * @param name defines camera name
  123518. * @param position defines initial position
  123519. * @param interaxialDistance defines distance between each color axis
  123520. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123521. * @param scene defines the hosting scene
  123522. */
  123523. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123524. /**
  123525. * Gets camera class name
  123526. * @returns StereoscopicGamepadCamera
  123527. */
  123528. getClassName(): string;
  123529. }
  123530. }
  123531. declare module BABYLON {
  123532. /**
  123533. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  123534. * @see https://doc.babylonjs.com/features/cameras
  123535. */
  123536. export class StereoscopicUniversalCamera extends UniversalCamera {
  123537. /**
  123538. * Creates a new StereoscopicUniversalCamera
  123539. * @param name defines camera name
  123540. * @param position defines initial position
  123541. * @param interaxialDistance defines distance between each color axis
  123542. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123543. * @param scene defines the hosting scene
  123544. */
  123545. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123546. /**
  123547. * Gets camera class name
  123548. * @returns StereoscopicUniversalCamera
  123549. */
  123550. getClassName(): string;
  123551. }
  123552. }
  123553. declare module BABYLON {
  123554. /**
  123555. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  123556. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123557. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123558. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123559. */
  123560. export class VirtualJoysticksCamera extends FreeCamera {
  123561. /**
  123562. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  123563. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123564. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123565. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123566. * @param name Define the name of the camera in the scene
  123567. * @param position Define the start position of the camera in the scene
  123568. * @param scene Define the scene the camera belongs to
  123569. */
  123570. constructor(name: string, position: Vector3, scene: Scene);
  123571. /**
  123572. * Gets the current object class name.
  123573. * @return the class name
  123574. */
  123575. getClassName(): string;
  123576. }
  123577. }
  123578. declare module BABYLON {
  123579. /**
  123580. * This represents all the required metrics to create a VR camera.
  123581. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  123582. */
  123583. export class VRCameraMetrics {
  123584. /**
  123585. * Define the horizontal resolution off the screen.
  123586. */
  123587. hResolution: number;
  123588. /**
  123589. * Define the vertical resolution off the screen.
  123590. */
  123591. vResolution: number;
  123592. /**
  123593. * Define the horizontal screen size.
  123594. */
  123595. hScreenSize: number;
  123596. /**
  123597. * Define the vertical screen size.
  123598. */
  123599. vScreenSize: number;
  123600. /**
  123601. * Define the vertical screen center position.
  123602. */
  123603. vScreenCenter: number;
  123604. /**
  123605. * Define the distance of the eyes to the screen.
  123606. */
  123607. eyeToScreenDistance: number;
  123608. /**
  123609. * Define the distance between both lenses
  123610. */
  123611. lensSeparationDistance: number;
  123612. /**
  123613. * Define the distance between both viewer's eyes.
  123614. */
  123615. interpupillaryDistance: number;
  123616. /**
  123617. * Define the distortion factor of the VR postprocess.
  123618. * Please, touch with care.
  123619. */
  123620. distortionK: number[];
  123621. /**
  123622. * Define the chromatic aberration correction factors for the VR post process.
  123623. */
  123624. chromaAbCorrection: number[];
  123625. /**
  123626. * Define the scale factor of the post process.
  123627. * The smaller the better but the slower.
  123628. */
  123629. postProcessScaleFactor: number;
  123630. /**
  123631. * Define an offset for the lens center.
  123632. */
  123633. lensCenterOffset: number;
  123634. /**
  123635. * Define if the current vr camera should compensate the distortion of the lense or not.
  123636. */
  123637. compensateDistortion: boolean;
  123638. /**
  123639. * Defines if multiview should be enabled when rendering (Default: false)
  123640. */
  123641. multiviewEnabled: boolean;
  123642. /**
  123643. * Gets the rendering aspect ratio based on the provided resolutions.
  123644. */
  123645. get aspectRatio(): number;
  123646. /**
  123647. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  123648. */
  123649. get aspectRatioFov(): number;
  123650. /**
  123651. * @hidden
  123652. */
  123653. get leftHMatrix(): Matrix;
  123654. /**
  123655. * @hidden
  123656. */
  123657. get rightHMatrix(): Matrix;
  123658. /**
  123659. * @hidden
  123660. */
  123661. get leftPreViewMatrix(): Matrix;
  123662. /**
  123663. * @hidden
  123664. */
  123665. get rightPreViewMatrix(): Matrix;
  123666. /**
  123667. * Get the default VRMetrics based on the most generic setup.
  123668. * @returns the default vr metrics
  123669. */
  123670. static GetDefault(): VRCameraMetrics;
  123671. }
  123672. }
  123673. declare module BABYLON {
  123674. /** @hidden */
  123675. export var vrDistortionCorrectionPixelShader: {
  123676. name: string;
  123677. shader: string;
  123678. };
  123679. }
  123680. declare module BABYLON {
  123681. /**
  123682. * VRDistortionCorrectionPostProcess used for mobile VR
  123683. */
  123684. export class VRDistortionCorrectionPostProcess extends PostProcess {
  123685. private _isRightEye;
  123686. private _distortionFactors;
  123687. private _postProcessScaleFactor;
  123688. private _lensCenterOffset;
  123689. private _scaleIn;
  123690. private _scaleFactor;
  123691. private _lensCenter;
  123692. /**
  123693. * Initializes the VRDistortionCorrectionPostProcess
  123694. * @param name The name of the effect.
  123695. * @param camera The camera to apply the render pass to.
  123696. * @param isRightEye If this is for the right eye distortion
  123697. * @param vrMetrics All the required metrics for the VR camera
  123698. */
  123699. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  123700. }
  123701. }
  123702. declare module BABYLON {
  123703. /**
  123704. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  123705. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123706. */
  123707. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  123708. /**
  123709. * Creates a new VRDeviceOrientationArcRotateCamera
  123710. * @param name defines camera name
  123711. * @param alpha defines the camera rotation along the logitudinal axis
  123712. * @param beta defines the camera rotation along the latitudinal axis
  123713. * @param radius defines the camera distance from its target
  123714. * @param target defines the camera target
  123715. * @param scene defines the scene the camera belongs to
  123716. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123717. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123718. */
  123719. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123720. /**
  123721. * Gets camera class name
  123722. * @returns VRDeviceOrientationArcRotateCamera
  123723. */
  123724. getClassName(): string;
  123725. }
  123726. }
  123727. declare module BABYLON {
  123728. /**
  123729. * Camera used to simulate VR rendering (based on FreeCamera)
  123730. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123731. */
  123732. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  123733. /**
  123734. * Creates a new VRDeviceOrientationFreeCamera
  123735. * @param name defines camera name
  123736. * @param position defines the start position of the camera
  123737. * @param scene defines the scene the camera belongs to
  123738. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123739. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123740. */
  123741. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123742. /**
  123743. * Gets camera class name
  123744. * @returns VRDeviceOrientationFreeCamera
  123745. */
  123746. getClassName(): string;
  123747. }
  123748. }
  123749. declare module BABYLON {
  123750. /**
  123751. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  123752. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123753. */
  123754. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  123755. /**
  123756. * Creates a new VRDeviceOrientationGamepadCamera
  123757. * @param name defines camera name
  123758. * @param position defines the start position of the camera
  123759. * @param scene defines the scene the camera belongs to
  123760. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123761. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123762. */
  123763. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123764. /**
  123765. * Gets camera class name
  123766. * @returns VRDeviceOrientationGamepadCamera
  123767. */
  123768. getClassName(): string;
  123769. }
  123770. }
  123771. declare module BABYLON {
  123772. /**
  123773. * A class extending Texture allowing drawing on a texture
  123774. * @see https://doc.babylonjs.com/how_to/dynamictexture
  123775. */
  123776. export class DynamicTexture extends Texture {
  123777. private _generateMipMaps;
  123778. private _canvas;
  123779. private _context;
  123780. /**
  123781. * Creates a DynamicTexture
  123782. * @param name defines the name of the texture
  123783. * @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
  123784. * @param scene defines the scene where you want the texture
  123785. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  123786. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123787. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  123788. */
  123789. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  123790. /**
  123791. * Get the current class name of the texture useful for serialization or dynamic coding.
  123792. * @returns "DynamicTexture"
  123793. */
  123794. getClassName(): string;
  123795. /**
  123796. * Gets the current state of canRescale
  123797. */
  123798. get canRescale(): boolean;
  123799. private _recreate;
  123800. /**
  123801. * Scales the texture
  123802. * @param ratio the scale factor to apply to both width and height
  123803. */
  123804. scale(ratio: number): void;
  123805. /**
  123806. * Resizes the texture
  123807. * @param width the new width
  123808. * @param height the new height
  123809. */
  123810. scaleTo(width: number, height: number): void;
  123811. /**
  123812. * Gets the context of the canvas used by the texture
  123813. * @returns the canvas context of the dynamic texture
  123814. */
  123815. getContext(): CanvasRenderingContext2D;
  123816. /**
  123817. * Clears the texture
  123818. */
  123819. clear(): void;
  123820. /**
  123821. * Updates the texture
  123822. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  123823. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  123824. */
  123825. update(invertY?: boolean, premulAlpha?: boolean): void;
  123826. /**
  123827. * Draws text onto the texture
  123828. * @param text defines the text to be drawn
  123829. * @param x defines the placement of the text from the left
  123830. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  123831. * @param font defines the font to be used with font-style, font-size, font-name
  123832. * @param color defines the color used for the text
  123833. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  123834. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  123835. * @param update defines whether texture is immediately update (default is true)
  123836. */
  123837. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  123838. /**
  123839. * Clones the texture
  123840. * @returns the clone of the texture.
  123841. */
  123842. clone(): DynamicTexture;
  123843. /**
  123844. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  123845. * @returns a serialized dynamic texture object
  123846. */
  123847. serialize(): any;
  123848. private _IsCanvasElement;
  123849. /** @hidden */
  123850. _rebuild(): void;
  123851. }
  123852. }
  123853. declare module BABYLON {
  123854. /** @hidden */
  123855. export var imageProcessingPixelShader: {
  123856. name: string;
  123857. shader: string;
  123858. };
  123859. }
  123860. declare module BABYLON {
  123861. /**
  123862. * ImageProcessingPostProcess
  123863. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  123864. */
  123865. export class ImageProcessingPostProcess extends PostProcess {
  123866. /**
  123867. * Default configuration related to image processing available in the PBR Material.
  123868. */
  123869. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123870. /**
  123871. * Gets the image processing configuration used either in this material.
  123872. */
  123873. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123874. /**
  123875. * Sets the Default image processing configuration used either in the this material.
  123876. *
  123877. * If sets to null, the scene one is in use.
  123878. */
  123879. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  123880. /**
  123881. * Keep track of the image processing observer to allow dispose and replace.
  123882. */
  123883. private _imageProcessingObserver;
  123884. /**
  123885. * Attaches a new image processing configuration to the PBR Material.
  123886. * @param configuration
  123887. */
  123888. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  123889. /**
  123890. * If the post process is supported.
  123891. */
  123892. get isSupported(): boolean;
  123893. /**
  123894. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123895. */
  123896. get colorCurves(): Nullable<ColorCurves>;
  123897. /**
  123898. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123899. */
  123900. set colorCurves(value: Nullable<ColorCurves>);
  123901. /**
  123902. * Gets wether the color curves effect is enabled.
  123903. */
  123904. get colorCurvesEnabled(): boolean;
  123905. /**
  123906. * Sets wether the color curves effect is enabled.
  123907. */
  123908. set colorCurvesEnabled(value: boolean);
  123909. /**
  123910. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123911. */
  123912. get colorGradingTexture(): Nullable<BaseTexture>;
  123913. /**
  123914. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123915. */
  123916. set colorGradingTexture(value: Nullable<BaseTexture>);
  123917. /**
  123918. * Gets wether the color grading effect is enabled.
  123919. */
  123920. get colorGradingEnabled(): boolean;
  123921. /**
  123922. * Gets wether the color grading effect is enabled.
  123923. */
  123924. set colorGradingEnabled(value: boolean);
  123925. /**
  123926. * Gets exposure used in the effect.
  123927. */
  123928. get exposure(): number;
  123929. /**
  123930. * Sets exposure used in the effect.
  123931. */
  123932. set exposure(value: number);
  123933. /**
  123934. * Gets wether tonemapping is enabled or not.
  123935. */
  123936. get toneMappingEnabled(): boolean;
  123937. /**
  123938. * Sets wether tonemapping is enabled or not
  123939. */
  123940. set toneMappingEnabled(value: boolean);
  123941. /**
  123942. * Gets the type of tone mapping effect.
  123943. */
  123944. get toneMappingType(): number;
  123945. /**
  123946. * Sets the type of tone mapping effect.
  123947. */
  123948. set toneMappingType(value: number);
  123949. /**
  123950. * Gets contrast used in the effect.
  123951. */
  123952. get contrast(): number;
  123953. /**
  123954. * Sets contrast used in the effect.
  123955. */
  123956. set contrast(value: number);
  123957. /**
  123958. * Gets Vignette stretch size.
  123959. */
  123960. get vignetteStretch(): number;
  123961. /**
  123962. * Sets Vignette stretch size.
  123963. */
  123964. set vignetteStretch(value: number);
  123965. /**
  123966. * Gets Vignette centre X Offset.
  123967. */
  123968. get vignetteCentreX(): number;
  123969. /**
  123970. * Sets Vignette centre X Offset.
  123971. */
  123972. set vignetteCentreX(value: number);
  123973. /**
  123974. * Gets Vignette centre Y Offset.
  123975. */
  123976. get vignetteCentreY(): number;
  123977. /**
  123978. * Sets Vignette centre Y Offset.
  123979. */
  123980. set vignetteCentreY(value: number);
  123981. /**
  123982. * Gets Vignette weight or intensity of the vignette effect.
  123983. */
  123984. get vignetteWeight(): number;
  123985. /**
  123986. * Sets Vignette weight or intensity of the vignette effect.
  123987. */
  123988. set vignetteWeight(value: number);
  123989. /**
  123990. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123991. * if vignetteEnabled is set to true.
  123992. */
  123993. get vignetteColor(): Color4;
  123994. /**
  123995. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123996. * if vignetteEnabled is set to true.
  123997. */
  123998. set vignetteColor(value: Color4);
  123999. /**
  124000. * Gets Camera field of view used by the Vignette effect.
  124001. */
  124002. get vignetteCameraFov(): number;
  124003. /**
  124004. * Sets Camera field of view used by the Vignette effect.
  124005. */
  124006. set vignetteCameraFov(value: number);
  124007. /**
  124008. * Gets the vignette blend mode allowing different kind of effect.
  124009. */
  124010. get vignetteBlendMode(): number;
  124011. /**
  124012. * Sets the vignette blend mode allowing different kind of effect.
  124013. */
  124014. set vignetteBlendMode(value: number);
  124015. /**
  124016. * Gets wether the vignette effect is enabled.
  124017. */
  124018. get vignetteEnabled(): boolean;
  124019. /**
  124020. * Sets wether the vignette effect is enabled.
  124021. */
  124022. set vignetteEnabled(value: boolean);
  124023. private _fromLinearSpace;
  124024. /**
  124025. * Gets wether the input of the processing is in Gamma or Linear Space.
  124026. */
  124027. get fromLinearSpace(): boolean;
  124028. /**
  124029. * Sets wether the input of the processing is in Gamma or Linear Space.
  124030. */
  124031. set fromLinearSpace(value: boolean);
  124032. /**
  124033. * Defines cache preventing GC.
  124034. */
  124035. private _defines;
  124036. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  124037. /**
  124038. * "ImageProcessingPostProcess"
  124039. * @returns "ImageProcessingPostProcess"
  124040. */
  124041. getClassName(): string;
  124042. protected _updateParameters(): void;
  124043. dispose(camera?: Camera): void;
  124044. }
  124045. }
  124046. declare module BABYLON {
  124047. /**
  124048. * Class containing static functions to help procedurally build meshes
  124049. */
  124050. export class GroundBuilder {
  124051. /**
  124052. * Creates a ground mesh
  124053. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124054. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124056. * @param name defines the name of the mesh
  124057. * @param options defines the options used to create the mesh
  124058. * @param scene defines the hosting scene
  124059. * @returns the ground mesh
  124060. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124061. */
  124062. static CreateGround(name: string, options: {
  124063. width?: number;
  124064. height?: number;
  124065. subdivisions?: number;
  124066. subdivisionsX?: number;
  124067. subdivisionsY?: number;
  124068. updatable?: boolean;
  124069. }, scene: any): Mesh;
  124070. /**
  124071. * Creates a tiled ground mesh
  124072. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124073. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124074. * * 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
  124075. * * 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
  124076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124077. * @param name defines the name of the mesh
  124078. * @param options defines the options used to create the mesh
  124079. * @param scene defines the hosting scene
  124080. * @returns the tiled ground mesh
  124081. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124082. */
  124083. static CreateTiledGround(name: string, options: {
  124084. xmin: number;
  124085. zmin: number;
  124086. xmax: number;
  124087. zmax: number;
  124088. subdivisions?: {
  124089. w: number;
  124090. h: number;
  124091. };
  124092. precision?: {
  124093. w: number;
  124094. h: number;
  124095. };
  124096. updatable?: boolean;
  124097. }, scene?: Nullable<Scene>): Mesh;
  124098. /**
  124099. * Creates a ground mesh from a height map
  124100. * * The parameter `url` sets the URL of the height map image resource.
  124101. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124102. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124103. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124104. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124105. * * 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.
  124106. * * 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).
  124107. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124109. * @param name defines the name of the mesh
  124110. * @param url defines the url to the height map
  124111. * @param options defines the options used to create the mesh
  124112. * @param scene defines the hosting scene
  124113. * @returns the ground mesh
  124114. * @see https://doc.babylonjs.com/babylon101/height_map
  124115. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124116. */
  124117. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124118. width?: number;
  124119. height?: number;
  124120. subdivisions?: number;
  124121. minHeight?: number;
  124122. maxHeight?: number;
  124123. colorFilter?: Color3;
  124124. alphaFilter?: number;
  124125. updatable?: boolean;
  124126. onReady?: (mesh: GroundMesh) => void;
  124127. }, scene?: Nullable<Scene>): GroundMesh;
  124128. }
  124129. }
  124130. declare module BABYLON {
  124131. /**
  124132. * Class containing static functions to help procedurally build meshes
  124133. */
  124134. export class TorusBuilder {
  124135. /**
  124136. * Creates a torus mesh
  124137. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124138. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124139. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124141. * * 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
  124142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124143. * @param name defines the name of the mesh
  124144. * @param options defines the options used to create the mesh
  124145. * @param scene defines the hosting scene
  124146. * @returns the torus mesh
  124147. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  124148. */
  124149. static CreateTorus(name: string, options: {
  124150. diameter?: number;
  124151. thickness?: number;
  124152. tessellation?: number;
  124153. updatable?: boolean;
  124154. sideOrientation?: number;
  124155. frontUVs?: Vector4;
  124156. backUVs?: Vector4;
  124157. }, scene: any): Mesh;
  124158. }
  124159. }
  124160. declare module BABYLON {
  124161. /**
  124162. * Class containing static functions to help procedurally build meshes
  124163. */
  124164. export class CylinderBuilder {
  124165. /**
  124166. * Creates a cylinder or a cone mesh
  124167. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  124168. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  124169. * * 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.
  124170. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  124171. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  124172. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  124173. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  124174. * * 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).
  124175. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  124176. * * 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).
  124177. * * 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
  124178. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124179. * * 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
  124180. * * 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.
  124181. * * If `enclose` is false, a ring surface is one element.
  124182. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124183. * * 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
  124184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124185. * * 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
  124186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124187. * @param name defines the name of the mesh
  124188. * @param options defines the options used to create the mesh
  124189. * @param scene defines the hosting scene
  124190. * @returns the cylinder mesh
  124191. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124192. */
  124193. static CreateCylinder(name: string, options: {
  124194. height?: number;
  124195. diameterTop?: number;
  124196. diameterBottom?: number;
  124197. diameter?: number;
  124198. tessellation?: number;
  124199. subdivisions?: number;
  124200. arc?: number;
  124201. faceColors?: Color4[];
  124202. faceUV?: Vector4[];
  124203. updatable?: boolean;
  124204. hasRings?: boolean;
  124205. enclose?: boolean;
  124206. cap?: number;
  124207. sideOrientation?: number;
  124208. frontUVs?: Vector4;
  124209. backUVs?: Vector4;
  124210. }, scene: any): Mesh;
  124211. }
  124212. }
  124213. declare module BABYLON {
  124214. /**
  124215. * States of the webXR experience
  124216. */
  124217. export enum WebXRState {
  124218. /**
  124219. * Transitioning to being in XR mode
  124220. */
  124221. ENTERING_XR = 0,
  124222. /**
  124223. * Transitioning to non XR mode
  124224. */
  124225. EXITING_XR = 1,
  124226. /**
  124227. * In XR mode and presenting
  124228. */
  124229. IN_XR = 2,
  124230. /**
  124231. * Not entered XR mode
  124232. */
  124233. NOT_IN_XR = 3
  124234. }
  124235. /**
  124236. * Abstraction of the XR render target
  124237. */
  124238. export interface WebXRRenderTarget extends IDisposable {
  124239. /**
  124240. * xrpresent context of the canvas which can be used to display/mirror xr content
  124241. */
  124242. canvasContext: WebGLRenderingContext;
  124243. /**
  124244. * xr layer for the canvas
  124245. */
  124246. xrLayer: Nullable<XRWebGLLayer>;
  124247. /**
  124248. * Initializes the xr layer for the session
  124249. * @param xrSession xr session
  124250. * @returns a promise that will resolve once the XR Layer has been created
  124251. */
  124252. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  124253. }
  124254. }
  124255. declare module BABYLON {
  124256. /**
  124257. * COnfiguration object for WebXR output canvas
  124258. */
  124259. export class WebXRManagedOutputCanvasOptions {
  124260. /**
  124261. * An optional canvas in case you wish to create it yourself and provide it here.
  124262. * If not provided, a new canvas will be created
  124263. */
  124264. canvasElement?: HTMLCanvasElement;
  124265. /**
  124266. * Options for this XR Layer output
  124267. */
  124268. canvasOptions?: XRWebGLLayerOptions;
  124269. /**
  124270. * CSS styling for a newly created canvas (if not provided)
  124271. */
  124272. newCanvasCssStyle?: string;
  124273. /**
  124274. * Get the default values of the configuration object
  124275. * @returns default values of this configuration object
  124276. */
  124277. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  124278. }
  124279. /**
  124280. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  124281. */
  124282. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  124283. private _options;
  124284. private _canvas;
  124285. private _engine;
  124286. private _originalCanvasSize;
  124287. /**
  124288. * Rendering context of the canvas which can be used to display/mirror xr content
  124289. */
  124290. canvasContext: WebGLRenderingContext;
  124291. /**
  124292. * xr layer for the canvas
  124293. */
  124294. xrLayer: Nullable<XRWebGLLayer>;
  124295. /**
  124296. * Obseervers registered here will be triggered when the xr layer was initialized
  124297. */
  124298. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  124299. /**
  124300. * Initializes the canvas to be added/removed upon entering/exiting xr
  124301. * @param _xrSessionManager The XR Session manager
  124302. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  124303. */
  124304. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  124305. /**
  124306. * Disposes of the object
  124307. */
  124308. dispose(): void;
  124309. /**
  124310. * Initializes the xr layer for the session
  124311. * @param xrSession xr session
  124312. * @returns a promise that will resolve once the XR Layer has been created
  124313. */
  124314. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  124315. private _addCanvas;
  124316. private _removeCanvas;
  124317. private _setCanvasSize;
  124318. private _setManagedOutputCanvas;
  124319. }
  124320. }
  124321. declare module BABYLON {
  124322. /**
  124323. * Manages an XRSession to work with Babylon's engine
  124324. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  124325. */
  124326. export class WebXRSessionManager implements IDisposable {
  124327. /** The scene which the session should be created for */
  124328. scene: Scene;
  124329. private _referenceSpace;
  124330. private _rttProvider;
  124331. private _sessionEnded;
  124332. private _xrNavigator;
  124333. private baseLayer;
  124334. /**
  124335. * The base reference space from which the session started. good if you want to reset your
  124336. * reference space
  124337. */
  124338. baseReferenceSpace: XRReferenceSpace;
  124339. /**
  124340. * Current XR frame
  124341. */
  124342. currentFrame: Nullable<XRFrame>;
  124343. /** WebXR timestamp updated every frame */
  124344. currentTimestamp: number;
  124345. /**
  124346. * Used just in case of a failure to initialize an immersive session.
  124347. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  124348. */
  124349. defaultHeightCompensation: number;
  124350. /**
  124351. * Fires every time a new xrFrame arrives which can be used to update the camera
  124352. */
  124353. onXRFrameObservable: Observable<XRFrame>;
  124354. /**
  124355. * Fires when the reference space changed
  124356. */
  124357. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  124358. /**
  124359. * Fires when the xr session is ended either by the device or manually done
  124360. */
  124361. onXRSessionEnded: Observable<any>;
  124362. /**
  124363. * Fires when the xr session is ended either by the device or manually done
  124364. */
  124365. onXRSessionInit: Observable<XRSession>;
  124366. /**
  124367. * Underlying xr session
  124368. */
  124369. session: XRSession;
  124370. /**
  124371. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  124372. * or get the offset the player is currently at.
  124373. */
  124374. viewerReferenceSpace: XRReferenceSpace;
  124375. /**
  124376. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  124377. * @param scene The scene which the session should be created for
  124378. */
  124379. constructor(
  124380. /** The scene which the session should be created for */
  124381. scene: Scene);
  124382. /**
  124383. * The current reference space used in this session. This reference space can constantly change!
  124384. * It is mainly used to offset the camera's position.
  124385. */
  124386. get referenceSpace(): XRReferenceSpace;
  124387. /**
  124388. * Set a new reference space and triggers the observable
  124389. */
  124390. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  124391. /**
  124392. * Disposes of the session manager
  124393. */
  124394. dispose(): void;
  124395. /**
  124396. * Stops the xrSession and restores the render loop
  124397. * @returns Promise which resolves after it exits XR
  124398. */
  124399. exitXRAsync(): Promise<void>;
  124400. /**
  124401. * Gets the correct render target texture to be rendered this frame for this eye
  124402. * @param eye the eye for which to get the render target
  124403. * @returns the render target for the specified eye
  124404. */
  124405. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  124406. /**
  124407. * Creates a WebXRRenderTarget object for the XR session
  124408. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  124409. * @param options optional options to provide when creating a new render target
  124410. * @returns a WebXR render target to which the session can render
  124411. */
  124412. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  124413. /**
  124414. * Initializes the manager
  124415. * After initialization enterXR can be called to start an XR session
  124416. * @returns Promise which resolves after it is initialized
  124417. */
  124418. initializeAsync(): Promise<void>;
  124419. /**
  124420. * Initializes an xr session
  124421. * @param xrSessionMode mode to initialize
  124422. * @param xrSessionInit defines optional and required values to pass to the session builder
  124423. * @returns a promise which will resolve once the session has been initialized
  124424. */
  124425. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  124426. /**
  124427. * Checks if a session would be supported for the creation options specified
  124428. * @param sessionMode session mode to check if supported eg. immersive-vr
  124429. * @returns A Promise that resolves to true if supported and false if not
  124430. */
  124431. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124432. /**
  124433. * Resets the reference space to the one started the session
  124434. */
  124435. resetReferenceSpace(): void;
  124436. /**
  124437. * Starts rendering to the xr layer
  124438. */
  124439. runXRRenderLoop(): void;
  124440. /**
  124441. * Sets the reference space on the xr session
  124442. * @param referenceSpaceType space to set
  124443. * @returns a promise that will resolve once the reference space has been set
  124444. */
  124445. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  124446. /**
  124447. * Updates the render state of the session
  124448. * @param state state to set
  124449. * @returns a promise that resolves once the render state has been updated
  124450. */
  124451. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  124452. /**
  124453. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  124454. * @param sessionMode defines the session to test
  124455. * @returns a promise with boolean as final value
  124456. */
  124457. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124458. private _createRenderTargetTexture;
  124459. }
  124460. }
  124461. declare module BABYLON {
  124462. /**
  124463. * WebXR Camera which holds the views for the xrSession
  124464. * @see https://doc.babylonjs.com/how_to/webxr_camera
  124465. */
  124466. export class WebXRCamera extends FreeCamera {
  124467. private _xrSessionManager;
  124468. private _firstFrame;
  124469. private _referenceQuaternion;
  124470. private _referencedPosition;
  124471. private _xrInvPositionCache;
  124472. private _xrInvQuaternionCache;
  124473. /**
  124474. * Should position compensation execute on first frame.
  124475. * This is used when copying the position from a native (non XR) camera
  124476. */
  124477. compensateOnFirstFrame: boolean;
  124478. /**
  124479. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  124480. * @param name the name of the camera
  124481. * @param scene the scene to add the camera to
  124482. * @param _xrSessionManager a constructed xr session manager
  124483. */
  124484. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  124485. /**
  124486. * Return the user's height, unrelated to the current ground.
  124487. * This will be the y position of this camera, when ground level is 0.
  124488. */
  124489. get realWorldHeight(): number;
  124490. /** @hidden */
  124491. _updateForDualEyeDebugging(): void;
  124492. /**
  124493. * Sets this camera's transformation based on a non-vr camera
  124494. * @param otherCamera the non-vr camera to copy the transformation from
  124495. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  124496. */
  124497. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  124498. /**
  124499. * Gets the current instance class name ("WebXRCamera").
  124500. * @returns the class name
  124501. */
  124502. getClassName(): string;
  124503. /**
  124504. * Overriding the _getViewMatrix function, as it is computed by WebXR
  124505. */
  124506. _getViewMatrix(): Matrix;
  124507. private _rotate180;
  124508. private _updateFromXRSession;
  124509. private _updateNumberOfRigCameras;
  124510. private _updateReferenceSpace;
  124511. private _updateReferenceSpaceOffset;
  124512. }
  124513. }
  124514. declare module BABYLON {
  124515. /**
  124516. * Defining the interface required for a (webxr) feature
  124517. */
  124518. export interface IWebXRFeature extends IDisposable {
  124519. /**
  124520. * Is this feature attached
  124521. */
  124522. attached: boolean;
  124523. /**
  124524. * Should auto-attach be disabled?
  124525. */
  124526. disableAutoAttach: boolean;
  124527. /**
  124528. * Attach the feature to the session
  124529. * Will usually be called by the features manager
  124530. *
  124531. * @param force should attachment be forced (even when already attached)
  124532. * @returns true if successful.
  124533. */
  124534. attach(force?: boolean): boolean;
  124535. /**
  124536. * Detach the feature from the session
  124537. * Will usually be called by the features manager
  124538. *
  124539. * @returns true if successful.
  124540. */
  124541. detach(): boolean;
  124542. }
  124543. /**
  124544. * A list of the currently available features without referencing them
  124545. */
  124546. export class WebXRFeatureName {
  124547. /**
  124548. * The name of the anchor system feature
  124549. */
  124550. static ANCHOR_SYSTEM: string;
  124551. /**
  124552. * The name of the background remover feature
  124553. */
  124554. static BACKGROUND_REMOVER: string;
  124555. /**
  124556. * The name of the hit test feature
  124557. */
  124558. static HIT_TEST: string;
  124559. /**
  124560. * physics impostors for xr controllers feature
  124561. */
  124562. static PHYSICS_CONTROLLERS: string;
  124563. /**
  124564. * The name of the plane detection feature
  124565. */
  124566. static PLANE_DETECTION: string;
  124567. /**
  124568. * The name of the pointer selection feature
  124569. */
  124570. static POINTER_SELECTION: string;
  124571. /**
  124572. * The name of the teleportation feature
  124573. */
  124574. static TELEPORTATION: string;
  124575. }
  124576. /**
  124577. * Defining the constructor of a feature. Used to register the modules.
  124578. */
  124579. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  124580. /**
  124581. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  124582. * It is mainly used in AR sessions.
  124583. *
  124584. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  124585. */
  124586. export class WebXRFeaturesManager implements IDisposable {
  124587. private _xrSessionManager;
  124588. private static readonly _AvailableFeatures;
  124589. private _features;
  124590. /**
  124591. * constructs a new features manages.
  124592. *
  124593. * @param _xrSessionManager an instance of WebXRSessionManager
  124594. */
  124595. constructor(_xrSessionManager: WebXRSessionManager);
  124596. /**
  124597. * Used to register a module. After calling this function a developer can use this feature in the scene.
  124598. * Mainly used internally.
  124599. *
  124600. * @param featureName the name of the feature to register
  124601. * @param constructorFunction the function used to construct the module
  124602. * @param version the (babylon) version of the module
  124603. * @param stable is that a stable version of this module
  124604. */
  124605. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  124606. /**
  124607. * Returns a constructor of a specific feature.
  124608. *
  124609. * @param featureName the name of the feature to construct
  124610. * @param version the version of the feature to load
  124611. * @param xrSessionManager the xrSessionManager. Used to construct the module
  124612. * @param options optional options provided to the module.
  124613. * @returns a function that, when called, will return a new instance of this feature
  124614. */
  124615. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  124616. /**
  124617. * Can be used to return the list of features currently registered
  124618. *
  124619. * @returns an Array of available features
  124620. */
  124621. static GetAvailableFeatures(): string[];
  124622. /**
  124623. * Gets the versions available for a specific feature
  124624. * @param featureName the name of the feature
  124625. * @returns an array with the available versions
  124626. */
  124627. static GetAvailableVersions(featureName: string): string[];
  124628. /**
  124629. * Return the latest unstable version of this feature
  124630. * @param featureName the name of the feature to search
  124631. * @returns the version number. if not found will return -1
  124632. */
  124633. static GetLatestVersionOfFeature(featureName: string): number;
  124634. /**
  124635. * Return the latest stable version of this feature
  124636. * @param featureName the name of the feature to search
  124637. * @returns the version number. if not found will return -1
  124638. */
  124639. static GetStableVersionOfFeature(featureName: string): number;
  124640. /**
  124641. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  124642. * Can be used during a session to start a feature
  124643. * @param featureName the name of feature to attach
  124644. */
  124645. attachFeature(featureName: string): void;
  124646. /**
  124647. * Can be used inside a session or when the session ends to detach a specific feature
  124648. * @param featureName the name of the feature to detach
  124649. */
  124650. detachFeature(featureName: string): void;
  124651. /**
  124652. * Used to disable an already-enabled feature
  124653. * The feature will be disposed and will be recreated once enabled.
  124654. * @param featureName the feature to disable
  124655. * @returns true if disable was successful
  124656. */
  124657. disableFeature(featureName: string | {
  124658. Name: string;
  124659. }): boolean;
  124660. /**
  124661. * dispose this features manager
  124662. */
  124663. dispose(): void;
  124664. /**
  124665. * 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.
  124666. * 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.
  124667. *
  124668. * @param featureName the name of the feature to load or the class of the feature
  124669. * @param version optional version to load. if not provided the latest version will be enabled
  124670. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  124671. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  124672. * @returns a new constructed feature or throws an error if feature not found.
  124673. */
  124674. enableFeature(featureName: string | {
  124675. Name: string;
  124676. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  124677. /**
  124678. * get the implementation of an enabled feature.
  124679. * @param featureName the name of the feature to load
  124680. * @returns the feature class, if found
  124681. */
  124682. getEnabledFeature(featureName: string): IWebXRFeature;
  124683. /**
  124684. * Get the list of enabled features
  124685. * @returns an array of enabled features
  124686. */
  124687. getEnabledFeatures(): string[];
  124688. }
  124689. }
  124690. declare module BABYLON {
  124691. /**
  124692. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  124693. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  124694. */
  124695. export class WebXRExperienceHelper implements IDisposable {
  124696. private scene;
  124697. private _nonVRCamera;
  124698. private _originalSceneAutoClear;
  124699. private _supported;
  124700. /**
  124701. * Camera used to render xr content
  124702. */
  124703. camera: WebXRCamera;
  124704. /** A features manager for this xr session */
  124705. featuresManager: WebXRFeaturesManager;
  124706. /**
  124707. * Observers registered here will be triggered after the camera's initial transformation is set
  124708. * This can be used to set a different ground level or an extra rotation.
  124709. *
  124710. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  124711. * to the position set after this observable is done executing.
  124712. */
  124713. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  124714. /**
  124715. * Fires when the state of the experience helper has changed
  124716. */
  124717. onStateChangedObservable: Observable<WebXRState>;
  124718. /** Session manager used to keep track of xr session */
  124719. sessionManager: WebXRSessionManager;
  124720. /**
  124721. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  124722. */
  124723. state: WebXRState;
  124724. /**
  124725. * Creates a WebXRExperienceHelper
  124726. * @param scene The scene the helper should be created in
  124727. */
  124728. private constructor();
  124729. /**
  124730. * Creates the experience helper
  124731. * @param scene the scene to attach the experience helper to
  124732. * @returns a promise for the experience helper
  124733. */
  124734. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  124735. /**
  124736. * Disposes of the experience helper
  124737. */
  124738. dispose(): void;
  124739. /**
  124740. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  124741. * @param sessionMode options for the XR session
  124742. * @param referenceSpaceType frame of reference of the XR session
  124743. * @param renderTarget the output canvas that will be used to enter XR mode
  124744. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  124745. * @returns promise that resolves after xr mode has entered
  124746. */
  124747. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  124748. /**
  124749. * Exits XR mode and returns the scene to its original state
  124750. * @returns promise that resolves after xr mode has exited
  124751. */
  124752. exitXRAsync(): Promise<void>;
  124753. private _nonXRToXRCamera;
  124754. private _setState;
  124755. }
  124756. }
  124757. declare module BABYLON {
  124758. /**
  124759. * X-Y values for axes in WebXR
  124760. */
  124761. export interface IWebXRMotionControllerAxesValue {
  124762. /**
  124763. * The value of the x axis
  124764. */
  124765. x: number;
  124766. /**
  124767. * The value of the y-axis
  124768. */
  124769. y: number;
  124770. }
  124771. /**
  124772. * changed / previous values for the values of this component
  124773. */
  124774. export interface IWebXRMotionControllerComponentChangesValues<T> {
  124775. /**
  124776. * current (this frame) value
  124777. */
  124778. current: T;
  124779. /**
  124780. * previous (last change) value
  124781. */
  124782. previous: T;
  124783. }
  124784. /**
  124785. * Represents changes in the component between current frame and last values recorded
  124786. */
  124787. export interface IWebXRMotionControllerComponentChanges {
  124788. /**
  124789. * will be populated with previous and current values if axes changed
  124790. */
  124791. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  124792. /**
  124793. * will be populated with previous and current values if pressed changed
  124794. */
  124795. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124796. /**
  124797. * will be populated with previous and current values if touched changed
  124798. */
  124799. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124800. /**
  124801. * will be populated with previous and current values if value changed
  124802. */
  124803. value?: IWebXRMotionControllerComponentChangesValues<number>;
  124804. }
  124805. /**
  124806. * This class represents a single component (for example button or thumbstick) of a motion controller
  124807. */
  124808. export class WebXRControllerComponent implements IDisposable {
  124809. /**
  124810. * the id of this component
  124811. */
  124812. id: string;
  124813. /**
  124814. * the type of the component
  124815. */
  124816. type: MotionControllerComponentType;
  124817. private _buttonIndex;
  124818. private _axesIndices;
  124819. private _axes;
  124820. private _changes;
  124821. private _currentValue;
  124822. private _hasChanges;
  124823. private _pressed;
  124824. private _touched;
  124825. /**
  124826. * button component type
  124827. */
  124828. static BUTTON_TYPE: MotionControllerComponentType;
  124829. /**
  124830. * squeeze component type
  124831. */
  124832. static SQUEEZE_TYPE: MotionControllerComponentType;
  124833. /**
  124834. * Thumbstick component type
  124835. */
  124836. static THUMBSTICK_TYPE: MotionControllerComponentType;
  124837. /**
  124838. * Touchpad component type
  124839. */
  124840. static TOUCHPAD_TYPE: MotionControllerComponentType;
  124841. /**
  124842. * trigger component type
  124843. */
  124844. static TRIGGER_TYPE: MotionControllerComponentType;
  124845. /**
  124846. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  124847. * the axes data changes
  124848. */
  124849. onAxisValueChangedObservable: Observable<{
  124850. x: number;
  124851. y: number;
  124852. }>;
  124853. /**
  124854. * Observers registered here will be triggered when the state of a button changes
  124855. * State change is either pressed / touched / value
  124856. */
  124857. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  124858. /**
  124859. * Creates a new component for a motion controller.
  124860. * It is created by the motion controller itself
  124861. *
  124862. * @param id the id of this component
  124863. * @param type the type of the component
  124864. * @param _buttonIndex index in the buttons array of the gamepad
  124865. * @param _axesIndices indices of the values in the axes array of the gamepad
  124866. */
  124867. constructor(
  124868. /**
  124869. * the id of this component
  124870. */
  124871. id: string,
  124872. /**
  124873. * the type of the component
  124874. */
  124875. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  124876. /**
  124877. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  124878. */
  124879. get axes(): IWebXRMotionControllerAxesValue;
  124880. /**
  124881. * Get the changes. Elements will be populated only if they changed with their previous and current value
  124882. */
  124883. get changes(): IWebXRMotionControllerComponentChanges;
  124884. /**
  124885. * Return whether or not the component changed the last frame
  124886. */
  124887. get hasChanges(): boolean;
  124888. /**
  124889. * is the button currently pressed
  124890. */
  124891. get pressed(): boolean;
  124892. /**
  124893. * is the button currently touched
  124894. */
  124895. get touched(): boolean;
  124896. /**
  124897. * Get the current value of this component
  124898. */
  124899. get value(): number;
  124900. /**
  124901. * Dispose this component
  124902. */
  124903. dispose(): void;
  124904. /**
  124905. * Are there axes correlating to this component
  124906. * @return true is axes data is available
  124907. */
  124908. isAxes(): boolean;
  124909. /**
  124910. * Is this component a button (hence - pressable)
  124911. * @returns true if can be pressed
  124912. */
  124913. isButton(): boolean;
  124914. /**
  124915. * update this component using the gamepad object it is in. Called on every frame
  124916. * @param nativeController the native gamepad controller object
  124917. */
  124918. update(nativeController: IMinimalMotionControllerObject): void;
  124919. }
  124920. }
  124921. declare module BABYLON {
  124922. /**
  124923. * Interface used to represent data loading progression
  124924. */
  124925. export interface ISceneLoaderProgressEvent {
  124926. /**
  124927. * Defines if data length to load can be evaluated
  124928. */
  124929. readonly lengthComputable: boolean;
  124930. /**
  124931. * Defines the loaded data length
  124932. */
  124933. readonly loaded: number;
  124934. /**
  124935. * Defines the data length to load
  124936. */
  124937. readonly total: number;
  124938. }
  124939. /**
  124940. * Interface used by SceneLoader plugins to define supported file extensions
  124941. */
  124942. export interface ISceneLoaderPluginExtensions {
  124943. /**
  124944. * Defines the list of supported extensions
  124945. */
  124946. [extension: string]: {
  124947. isBinary: boolean;
  124948. };
  124949. }
  124950. /**
  124951. * Interface used by SceneLoader plugin factory
  124952. */
  124953. export interface ISceneLoaderPluginFactory {
  124954. /**
  124955. * Defines the name of the factory
  124956. */
  124957. name: string;
  124958. /**
  124959. * Function called to create a new plugin
  124960. * @return the new plugin
  124961. */
  124962. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  124963. /**
  124964. * The callback that returns true if the data can be directly loaded.
  124965. * @param data string containing the file data
  124966. * @returns if the data can be loaded directly
  124967. */
  124968. canDirectLoad?(data: string): boolean;
  124969. }
  124970. /**
  124971. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  124972. */
  124973. export interface ISceneLoaderPluginBase {
  124974. /**
  124975. * The friendly name of this plugin.
  124976. */
  124977. name: string;
  124978. /**
  124979. * The file extensions supported by this plugin.
  124980. */
  124981. extensions: string | ISceneLoaderPluginExtensions;
  124982. /**
  124983. * The callback called when loading from a url.
  124984. * @param scene scene loading this url
  124985. * @param url url to load
  124986. * @param onSuccess callback called when the file successfully loads
  124987. * @param onProgress callback called while file is loading (if the server supports this mode)
  124988. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  124989. * @param onError callback called when the file fails to load
  124990. * @returns a file request object
  124991. */
  124992. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124993. /**
  124994. * The callback called when loading from a file object.
  124995. * @param scene scene loading this file
  124996. * @param file defines the file to load
  124997. * @param onSuccess defines the callback to call when data is loaded
  124998. * @param onProgress defines the callback to call during loading process
  124999. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  125000. * @param onError defines the callback to call when an error occurs
  125001. * @returns a file request object
  125002. */
  125003. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  125004. /**
  125005. * The callback that returns true if the data can be directly loaded.
  125006. * @param data string containing the file data
  125007. * @returns if the data can be loaded directly
  125008. */
  125009. canDirectLoad?(data: string): boolean;
  125010. /**
  125011. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  125012. * @param scene scene loading this data
  125013. * @param data string containing the data
  125014. * @returns data to pass to the plugin
  125015. */
  125016. directLoad?(scene: Scene, data: string): any;
  125017. /**
  125018. * The callback that allows custom handling of the root url based on the response url.
  125019. * @param rootUrl the original root url
  125020. * @param responseURL the response url if available
  125021. * @returns the new root url
  125022. */
  125023. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  125024. }
  125025. /**
  125026. * Interface used to define a SceneLoader plugin
  125027. */
  125028. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  125029. /**
  125030. * Import meshes into a scene.
  125031. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125032. * @param scene The scene to import into
  125033. * @param data The data to import
  125034. * @param rootUrl The root url for scene and resources
  125035. * @param meshes The meshes array to import into
  125036. * @param particleSystems The particle systems array to import into
  125037. * @param skeletons The skeletons array to import into
  125038. * @param onError The callback when import fails
  125039. * @returns True if successful or false otherwise
  125040. */
  125041. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  125042. /**
  125043. * Load into a scene.
  125044. * @param scene The scene to load into
  125045. * @param data The data to import
  125046. * @param rootUrl The root url for scene and resources
  125047. * @param onError The callback when import fails
  125048. * @returns True if successful or false otherwise
  125049. */
  125050. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  125051. /**
  125052. * Load into an asset container.
  125053. * @param scene The scene to load into
  125054. * @param data The data to import
  125055. * @param rootUrl The root url for scene and resources
  125056. * @param onError The callback when import fails
  125057. * @returns The loaded asset container
  125058. */
  125059. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  125060. }
  125061. /**
  125062. * Interface used to define an async SceneLoader plugin
  125063. */
  125064. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  125065. /**
  125066. * Import meshes into a scene.
  125067. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125068. * @param scene The scene to import into
  125069. * @param data The data to import
  125070. * @param rootUrl The root url for scene and resources
  125071. * @param onProgress The callback when the load progresses
  125072. * @param fileName Defines the name of the file to load
  125073. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  125074. */
  125075. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  125076. meshes: AbstractMesh[];
  125077. particleSystems: IParticleSystem[];
  125078. skeletons: Skeleton[];
  125079. animationGroups: AnimationGroup[];
  125080. }>;
  125081. /**
  125082. * Load into a scene.
  125083. * @param scene The scene to load into
  125084. * @param data The data to import
  125085. * @param rootUrl The root url for scene and resources
  125086. * @param onProgress The callback when the load progresses
  125087. * @param fileName Defines the name of the file to load
  125088. * @returns Nothing
  125089. */
  125090. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  125091. /**
  125092. * Load into an asset container.
  125093. * @param scene The scene to load into
  125094. * @param data The data to import
  125095. * @param rootUrl The root url for scene and resources
  125096. * @param onProgress The callback when the load progresses
  125097. * @param fileName Defines the name of the file to load
  125098. * @returns The loaded asset container
  125099. */
  125100. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  125101. }
  125102. /**
  125103. * Mode that determines how to handle old animation groups before loading new ones.
  125104. */
  125105. export enum SceneLoaderAnimationGroupLoadingMode {
  125106. /**
  125107. * Reset all old animations to initial state then dispose them.
  125108. */
  125109. Clean = 0,
  125110. /**
  125111. * Stop all old animations.
  125112. */
  125113. Stop = 1,
  125114. /**
  125115. * Restart old animations from first frame.
  125116. */
  125117. Sync = 2,
  125118. /**
  125119. * Old animations remains untouched.
  125120. */
  125121. NoSync = 3
  125122. }
  125123. /**
  125124. * Class used to load scene from various file formats using registered plugins
  125125. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  125126. */
  125127. export class SceneLoader {
  125128. /**
  125129. * No logging while loading
  125130. */
  125131. static readonly NO_LOGGING: number;
  125132. /**
  125133. * Minimal logging while loading
  125134. */
  125135. static readonly MINIMAL_LOGGING: number;
  125136. /**
  125137. * Summary logging while loading
  125138. */
  125139. static readonly SUMMARY_LOGGING: number;
  125140. /**
  125141. * Detailled logging while loading
  125142. */
  125143. static readonly DETAILED_LOGGING: number;
  125144. /**
  125145. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  125146. */
  125147. static get ForceFullSceneLoadingForIncremental(): boolean;
  125148. static set ForceFullSceneLoadingForIncremental(value: boolean);
  125149. /**
  125150. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  125151. */
  125152. static get ShowLoadingScreen(): boolean;
  125153. static set ShowLoadingScreen(value: boolean);
  125154. /**
  125155. * Defines the current logging level (while loading the scene)
  125156. * @ignorenaming
  125157. */
  125158. static get loggingLevel(): number;
  125159. static set loggingLevel(value: number);
  125160. /**
  125161. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  125162. */
  125163. static get CleanBoneMatrixWeights(): boolean;
  125164. static set CleanBoneMatrixWeights(value: boolean);
  125165. /**
  125166. * Event raised when a plugin is used to load a scene
  125167. */
  125168. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  125169. private static _registeredPlugins;
  125170. private static _getDefaultPlugin;
  125171. private static _getPluginForExtension;
  125172. private static _getPluginForDirectLoad;
  125173. private static _getPluginForFilename;
  125174. private static _getDirectLoad;
  125175. private static _loadData;
  125176. private static _getFileInfo;
  125177. /**
  125178. * Gets a plugin that can load the given extension
  125179. * @param extension defines the extension to load
  125180. * @returns a plugin or null if none works
  125181. */
  125182. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  125183. /**
  125184. * Gets a boolean indicating that the given extension can be loaded
  125185. * @param extension defines the extension to load
  125186. * @returns true if the extension is supported
  125187. */
  125188. static IsPluginForExtensionAvailable(extension: string): boolean;
  125189. /**
  125190. * Adds a new plugin to the list of registered plugins
  125191. * @param plugin defines the plugin to add
  125192. */
  125193. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  125194. /**
  125195. * Import meshes into a scene
  125196. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125197. * @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)
  125198. * @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)
  125199. * @param scene the instance of BABYLON.Scene to append to
  125200. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  125201. * @param onProgress a callback with a progress event for each file being loaded
  125202. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125203. * @param pluginExtension the extension used to determine the plugin
  125204. * @returns The loaded plugin
  125205. */
  125206. 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>;
  125207. /**
  125208. * Import meshes into a scene
  125209. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125210. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  125211. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  125212. * @param scene the instance of BABYLON.Scene to append to
  125213. * @param onProgress a callback with a progress event for each file being loaded
  125214. * @param pluginExtension the extension used to determine the plugin
  125215. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  125216. */
  125217. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  125218. meshes: AbstractMesh[];
  125219. particleSystems: IParticleSystem[];
  125220. skeletons: Skeleton[];
  125221. animationGroups: AnimationGroup[];
  125222. }>;
  125223. /**
  125224. * Load a scene
  125225. * @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)
  125226. * @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)
  125227. * @param engine is the instance of BABYLON.Engine to use to create the scene
  125228. * @param onSuccess a callback with the scene when import succeeds
  125229. * @param onProgress a callback with a progress event for each file being loaded
  125230. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125231. * @param pluginExtension the extension used to determine the plugin
  125232. * @returns The loaded plugin
  125233. */
  125234. 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>;
  125235. /**
  125236. * Load a scene
  125237. * @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)
  125238. * @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)
  125239. * @param engine is the instance of BABYLON.Engine to use to create the scene
  125240. * @param onProgress a callback with a progress event for each file being loaded
  125241. * @param pluginExtension the extension used to determine the plugin
  125242. * @returns The loaded scene
  125243. */
  125244. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125245. /**
  125246. * Append a scene
  125247. * @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)
  125248. * @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)
  125249. * @param scene is the instance of BABYLON.Scene to append to
  125250. * @param onSuccess a callback with the scene when import succeeds
  125251. * @param onProgress a callback with a progress event for each file being loaded
  125252. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125253. * @param pluginExtension the extension used to determine the plugin
  125254. * @returns The loaded plugin
  125255. */
  125256. 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>;
  125257. /**
  125258. * Append a scene
  125259. * @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)
  125260. * @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)
  125261. * @param scene is the instance of BABYLON.Scene to append to
  125262. * @param onProgress a callback with a progress event for each file being loaded
  125263. * @param pluginExtension the extension used to determine the plugin
  125264. * @returns The given scene
  125265. */
  125266. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125267. /**
  125268. * Load a scene into an asset container
  125269. * @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)
  125270. * @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)
  125271. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125272. * @param onSuccess a callback with the scene when import succeeds
  125273. * @param onProgress a callback with a progress event for each file being loaded
  125274. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125275. * @param pluginExtension the extension used to determine the plugin
  125276. * @returns The loaded plugin
  125277. */
  125278. 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>;
  125279. /**
  125280. * Load a scene into an asset container
  125281. * @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)
  125282. * @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)
  125283. * @param scene is the instance of Scene to append to
  125284. * @param onProgress a callback with a progress event for each file being loaded
  125285. * @param pluginExtension the extension used to determine the plugin
  125286. * @returns The loaded asset container
  125287. */
  125288. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  125289. /**
  125290. * Import animations from a file into a scene
  125291. * @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)
  125292. * @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)
  125293. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125294. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  125295. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  125296. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  125297. * @param onSuccess a callback with the scene when import succeeds
  125298. * @param onProgress a callback with a progress event for each file being loaded
  125299. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125300. * @param pluginExtension the extension used to determine the plugin
  125301. */
  125302. 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;
  125303. /**
  125304. * Import animations from a file into a scene
  125305. * @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)
  125306. * @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)
  125307. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125308. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  125309. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  125310. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  125311. * @param onSuccess a callback with the scene when import succeeds
  125312. * @param onProgress a callback with a progress event for each file being loaded
  125313. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125314. * @param pluginExtension the extension used to determine the plugin
  125315. * @returns the updated scene with imported animations
  125316. */
  125317. 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>;
  125318. }
  125319. }
  125320. declare module BABYLON {
  125321. /**
  125322. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  125323. */
  125324. export type MotionControllerHandedness = "none" | "left" | "right";
  125325. /**
  125326. * The type of components available in motion controllers.
  125327. * This is not the name of the component.
  125328. */
  125329. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  125330. /**
  125331. * The state of a controller component
  125332. */
  125333. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  125334. /**
  125335. * The schema of motion controller layout.
  125336. * No object will be initialized using this interface
  125337. * This is used just to define the profile.
  125338. */
  125339. export interface IMotionControllerLayout {
  125340. /**
  125341. * Path to load the assets. Usually relative to the base path
  125342. */
  125343. assetPath: string;
  125344. /**
  125345. * Available components (unsorted)
  125346. */
  125347. components: {
  125348. /**
  125349. * A map of component Ids
  125350. */
  125351. [componentId: string]: {
  125352. /**
  125353. * The type of input the component outputs
  125354. */
  125355. type: MotionControllerComponentType;
  125356. /**
  125357. * The indices of this component in the gamepad object
  125358. */
  125359. gamepadIndices: {
  125360. /**
  125361. * Index of button
  125362. */
  125363. button?: number;
  125364. /**
  125365. * If available, index of x-axis
  125366. */
  125367. xAxis?: number;
  125368. /**
  125369. * If available, index of y-axis
  125370. */
  125371. yAxis?: number;
  125372. };
  125373. /**
  125374. * The mesh's root node name
  125375. */
  125376. rootNodeName: string;
  125377. /**
  125378. * Animation definitions for this model
  125379. */
  125380. visualResponses: {
  125381. [stateKey: string]: {
  125382. /**
  125383. * What property will be animated
  125384. */
  125385. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  125386. /**
  125387. * What states influence this visual response
  125388. */
  125389. states: MotionControllerComponentStateType[];
  125390. /**
  125391. * Type of animation - movement or visibility
  125392. */
  125393. valueNodeProperty: "transform" | "visibility";
  125394. /**
  125395. * Base node name to move. Its position will be calculated according to the min and max nodes
  125396. */
  125397. valueNodeName?: string;
  125398. /**
  125399. * Minimum movement node
  125400. */
  125401. minNodeName?: string;
  125402. /**
  125403. * Max movement node
  125404. */
  125405. maxNodeName?: string;
  125406. };
  125407. };
  125408. /**
  125409. * If touch enabled, what is the name of node to display user feedback
  125410. */
  125411. touchPointNodeName?: string;
  125412. };
  125413. };
  125414. /**
  125415. * Is it xr standard mapping or not
  125416. */
  125417. gamepadMapping: "" | "xr-standard";
  125418. /**
  125419. * Base root node of this entire model
  125420. */
  125421. rootNodeName: string;
  125422. /**
  125423. * Defines the main button component id
  125424. */
  125425. selectComponentId: string;
  125426. }
  125427. /**
  125428. * A definition for the layout map in the input profile
  125429. */
  125430. export interface IMotionControllerLayoutMap {
  125431. /**
  125432. * Layouts with handedness type as a key
  125433. */
  125434. [handedness: string]: IMotionControllerLayout;
  125435. }
  125436. /**
  125437. * The XR Input profile schema
  125438. * Profiles can be found here:
  125439. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  125440. */
  125441. export interface IMotionControllerProfile {
  125442. /**
  125443. * fallback profiles for this profileId
  125444. */
  125445. fallbackProfileIds: string[];
  125446. /**
  125447. * The layout map, with handedness as key
  125448. */
  125449. layouts: IMotionControllerLayoutMap;
  125450. /**
  125451. * The id of this profile
  125452. * correlates to the profile(s) in the xrInput.profiles array
  125453. */
  125454. profileId: string;
  125455. }
  125456. /**
  125457. * A helper-interface for the 3 meshes needed for controller button animation
  125458. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  125459. */
  125460. export interface IMotionControllerButtonMeshMap {
  125461. /**
  125462. * the mesh that defines the pressed value mesh position.
  125463. * This is used to find the max-position of this button
  125464. */
  125465. pressedMesh: AbstractMesh;
  125466. /**
  125467. * the mesh that defines the unpressed value mesh position.
  125468. * This is used to find the min (or initial) position of this button
  125469. */
  125470. unpressedMesh: AbstractMesh;
  125471. /**
  125472. * The mesh that will be changed when value changes
  125473. */
  125474. valueMesh: AbstractMesh;
  125475. }
  125476. /**
  125477. * A helper-interface for the 3 meshes needed for controller axis animation.
  125478. * This will be expanded when touchpad animations are fully supported
  125479. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  125480. */
  125481. export interface IMotionControllerMeshMap {
  125482. /**
  125483. * the mesh that defines the maximum value mesh position.
  125484. */
  125485. maxMesh?: AbstractMesh;
  125486. /**
  125487. * the mesh that defines the minimum value mesh position.
  125488. */
  125489. minMesh?: AbstractMesh;
  125490. /**
  125491. * The mesh that will be changed when axis value changes
  125492. */
  125493. valueMesh: AbstractMesh;
  125494. }
  125495. /**
  125496. * The elements needed for change-detection of the gamepad objects in motion controllers
  125497. */
  125498. export interface IMinimalMotionControllerObject {
  125499. /**
  125500. * Available axes of this controller
  125501. */
  125502. axes: number[];
  125503. /**
  125504. * An array of available buttons
  125505. */
  125506. buttons: Array<{
  125507. /**
  125508. * Value of the button/trigger
  125509. */
  125510. value: number;
  125511. /**
  125512. * If the button/trigger is currently touched
  125513. */
  125514. touched: boolean;
  125515. /**
  125516. * If the button/trigger is currently pressed
  125517. */
  125518. pressed: boolean;
  125519. }>;
  125520. /**
  125521. * EXPERIMENTAL haptic support.
  125522. */
  125523. hapticActuators?: Array<{
  125524. pulse: (value: number, duration: number) => Promise<boolean>;
  125525. }>;
  125526. }
  125527. /**
  125528. * An Abstract Motion controller
  125529. * This class receives an xrInput and a profile layout and uses those to initialize the components
  125530. * Each component has an observable to check for changes in value and state
  125531. */
  125532. export abstract class WebXRAbstractMotionController implements IDisposable {
  125533. protected scene: Scene;
  125534. protected layout: IMotionControllerLayout;
  125535. /**
  125536. * The gamepad object correlating to this controller
  125537. */
  125538. gamepadObject: IMinimalMotionControllerObject;
  125539. /**
  125540. * handedness (left/right/none) of this controller
  125541. */
  125542. handedness: MotionControllerHandedness;
  125543. private _initComponent;
  125544. private _modelReady;
  125545. /**
  125546. * A map of components (WebXRControllerComponent) in this motion controller
  125547. * Components have a ComponentType and can also have both button and axis definitions
  125548. */
  125549. readonly components: {
  125550. [id: string]: WebXRControllerComponent;
  125551. };
  125552. /**
  125553. * Disable the model's animation. Can be set at any time.
  125554. */
  125555. disableAnimation: boolean;
  125556. /**
  125557. * Observers registered here will be triggered when the model of this controller is done loading
  125558. */
  125559. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  125560. /**
  125561. * The profile id of this motion controller
  125562. */
  125563. abstract profileId: string;
  125564. /**
  125565. * The root mesh of the model. It is null if the model was not yet initialized
  125566. */
  125567. rootMesh: Nullable<AbstractMesh>;
  125568. /**
  125569. * constructs a new abstract motion controller
  125570. * @param scene the scene to which the model of the controller will be added
  125571. * @param layout The profile layout to load
  125572. * @param gamepadObject The gamepad object correlating to this controller
  125573. * @param handedness handedness (left/right/none) of this controller
  125574. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  125575. */
  125576. constructor(scene: Scene, layout: IMotionControllerLayout,
  125577. /**
  125578. * The gamepad object correlating to this controller
  125579. */
  125580. gamepadObject: IMinimalMotionControllerObject,
  125581. /**
  125582. * handedness (left/right/none) of this controller
  125583. */
  125584. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  125585. /**
  125586. * Dispose this controller, the model mesh and all its components
  125587. */
  125588. dispose(): void;
  125589. /**
  125590. * Returns all components of specific type
  125591. * @param type the type to search for
  125592. * @return an array of components with this type
  125593. */
  125594. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  125595. /**
  125596. * get a component based an its component id as defined in layout.components
  125597. * @param id the id of the component
  125598. * @returns the component correlates to the id or undefined if not found
  125599. */
  125600. getComponent(id: string): WebXRControllerComponent;
  125601. /**
  125602. * Get the list of components available in this motion controller
  125603. * @returns an array of strings correlating to available components
  125604. */
  125605. getComponentIds(): string[];
  125606. /**
  125607. * Get the first component of specific type
  125608. * @param type type of component to find
  125609. * @return a controller component or null if not found
  125610. */
  125611. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  125612. /**
  125613. * Get the main (Select) component of this controller as defined in the layout
  125614. * @returns the main component of this controller
  125615. */
  125616. getMainComponent(): WebXRControllerComponent;
  125617. /**
  125618. * Loads the model correlating to this controller
  125619. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  125620. * @returns A promise fulfilled with the result of the model loading
  125621. */
  125622. loadModel(): Promise<boolean>;
  125623. /**
  125624. * Update this model using the current XRFrame
  125625. * @param xrFrame the current xr frame to use and update the model
  125626. */
  125627. updateFromXRFrame(xrFrame: XRFrame): void;
  125628. /**
  125629. * Backwards compatibility due to a deeply-integrated typo
  125630. */
  125631. get handness(): XREye;
  125632. /**
  125633. * Pulse (vibrate) this controller
  125634. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  125635. * Consecutive calls to this function will cancel the last pulse call
  125636. *
  125637. * @param value the strength of the pulse in 0.0...1.0 range
  125638. * @param duration Duration of the pulse in milliseconds
  125639. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  125640. * @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
  125641. */
  125642. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  125643. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125644. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125645. /**
  125646. * Moves the axis on the controller mesh based on its current state
  125647. * @param axis the index of the axis
  125648. * @param axisValue the value of the axis which determines the meshes new position
  125649. * @hidden
  125650. */
  125651. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  125652. /**
  125653. * Update the model itself with the current frame data
  125654. * @param xrFrame the frame to use for updating the model mesh
  125655. */
  125656. protected updateModel(xrFrame: XRFrame): void;
  125657. /**
  125658. * Get the filename and path for this controller's model
  125659. * @returns a map of filename and path
  125660. */
  125661. protected abstract _getFilenameAndPath(): {
  125662. filename: string;
  125663. path: string;
  125664. };
  125665. /**
  125666. * This function is called before the mesh is loaded. It checks for loading constraints.
  125667. * For example, this function can check if the GLB loader is available
  125668. * If this function returns false, the generic controller will be loaded instead
  125669. * @returns Is the client ready to load the mesh
  125670. */
  125671. protected abstract _getModelLoadingConstraints(): boolean;
  125672. /**
  125673. * This function will be called after the model was successfully loaded and can be used
  125674. * for mesh transformations before it is available for the user
  125675. * @param meshes the loaded meshes
  125676. */
  125677. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  125678. /**
  125679. * Set the root mesh for this controller. Important for the WebXR controller class
  125680. * @param meshes the loaded meshes
  125681. */
  125682. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  125683. /**
  125684. * A function executed each frame that updates the mesh (if needed)
  125685. * @param xrFrame the current xrFrame
  125686. */
  125687. protected abstract _updateModel(xrFrame: XRFrame): void;
  125688. private _getGenericFilenameAndPath;
  125689. private _getGenericParentMesh;
  125690. }
  125691. }
  125692. declare module BABYLON {
  125693. /**
  125694. * A generic trigger-only motion controller for WebXR
  125695. */
  125696. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  125697. /**
  125698. * Static version of the profile id of this controller
  125699. */
  125700. static ProfileId: string;
  125701. profileId: string;
  125702. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  125703. protected _getFilenameAndPath(): {
  125704. filename: string;
  125705. path: string;
  125706. };
  125707. protected _getModelLoadingConstraints(): boolean;
  125708. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  125709. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125710. protected _updateModel(): void;
  125711. }
  125712. }
  125713. declare module BABYLON {
  125714. /**
  125715. * Class containing static functions to help procedurally build meshes
  125716. */
  125717. export class SphereBuilder {
  125718. /**
  125719. * Creates a sphere mesh
  125720. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125721. * * 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`)
  125722. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125723. * * 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
  125724. * * 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)
  125725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125726. * * 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
  125727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125728. * @param name defines the name of the mesh
  125729. * @param options defines the options used to create the mesh
  125730. * @param scene defines the hosting scene
  125731. * @returns the sphere mesh
  125732. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125733. */
  125734. static CreateSphere(name: string, options: {
  125735. segments?: number;
  125736. diameter?: number;
  125737. diameterX?: number;
  125738. diameterY?: number;
  125739. diameterZ?: number;
  125740. arc?: number;
  125741. slice?: number;
  125742. sideOrientation?: number;
  125743. frontUVs?: Vector4;
  125744. backUVs?: Vector4;
  125745. updatable?: boolean;
  125746. }, scene?: Nullable<Scene>): Mesh;
  125747. }
  125748. }
  125749. declare module BABYLON {
  125750. /**
  125751. * A profiled motion controller has its profile loaded from an online repository.
  125752. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  125753. */
  125754. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  125755. private _repositoryUrl;
  125756. private _buttonMeshMapping;
  125757. private _touchDots;
  125758. /**
  125759. * The profile ID of this controller. Will be populated when the controller initializes.
  125760. */
  125761. profileId: string;
  125762. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  125763. dispose(): void;
  125764. protected _getFilenameAndPath(): {
  125765. filename: string;
  125766. path: string;
  125767. };
  125768. protected _getModelLoadingConstraints(): boolean;
  125769. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  125770. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125771. protected _updateModel(_xrFrame: XRFrame): void;
  125772. }
  125773. }
  125774. declare module BABYLON {
  125775. /**
  125776. * A construction function type to create a new controller based on an xrInput object
  125777. */
  125778. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  125779. /**
  125780. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  125781. *
  125782. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  125783. * it should be replaced with auto-loaded controllers.
  125784. *
  125785. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  125786. */
  125787. export class WebXRMotionControllerManager {
  125788. private static _AvailableControllers;
  125789. private static _Fallbacks;
  125790. private static _ProfileLoadingPromises;
  125791. private static _ProfilesList;
  125792. /**
  125793. * The base URL of the online controller repository. Can be changed at any time.
  125794. */
  125795. static BaseRepositoryUrl: string;
  125796. /**
  125797. * Which repository gets priority - local or online
  125798. */
  125799. static PrioritizeOnlineRepository: boolean;
  125800. /**
  125801. * Use the online repository, or use only locally-defined controllers
  125802. */
  125803. static UseOnlineRepository: boolean;
  125804. /**
  125805. * Clear the cache used for profile loading and reload when requested again
  125806. */
  125807. static ClearProfilesCache(): void;
  125808. /**
  125809. * Register the default fallbacks.
  125810. * This function is called automatically when this file is imported.
  125811. */
  125812. static DefaultFallbacks(): void;
  125813. /**
  125814. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  125815. * @param profileId the profile to which a fallback needs to be found
  125816. * @return an array with corresponding fallback profiles
  125817. */
  125818. static FindFallbackWithProfileId(profileId: string): string[];
  125819. /**
  125820. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  125821. * The order of search:
  125822. *
  125823. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  125824. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  125825. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  125826. * 4) return the generic trigger controller if none were found
  125827. *
  125828. * @param xrInput the xrInput to which a new controller is initialized
  125829. * @param scene the scene to which the model will be added
  125830. * @param forceProfile force a certain profile for this controller
  125831. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  125832. */
  125833. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  125834. /**
  125835. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  125836. *
  125837. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  125838. *
  125839. * @param type the profile type to register
  125840. * @param constructFunction the function to be called when loading this profile
  125841. */
  125842. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  125843. /**
  125844. * Register a fallback to a specific profile.
  125845. * @param profileId the profileId that will receive the fallbacks
  125846. * @param fallbacks A list of fallback profiles
  125847. */
  125848. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  125849. /**
  125850. * Will update the list of profiles available in the repository
  125851. * @return a promise that resolves to a map of profiles available online
  125852. */
  125853. static UpdateProfilesList(): Promise<{
  125854. [profile: string]: string;
  125855. }>;
  125856. private static _LoadProfileFromRepository;
  125857. private static _LoadProfilesFromAvailableControllers;
  125858. }
  125859. }
  125860. declare module BABYLON {
  125861. /**
  125862. * Configuration options for the WebXR controller creation
  125863. */
  125864. export interface IWebXRControllerOptions {
  125865. /**
  125866. * Should the controller mesh be animated when a user interacts with it
  125867. * The pressed buttons / thumbstick and touchpad animations will be disabled
  125868. */
  125869. disableMotionControllerAnimation?: boolean;
  125870. /**
  125871. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  125872. */
  125873. doNotLoadControllerMesh?: boolean;
  125874. /**
  125875. * Force a specific controller type for this controller.
  125876. * This can be used when creating your own profile or when testing different controllers
  125877. */
  125878. forceControllerProfile?: string;
  125879. /**
  125880. * Defines a rendering group ID for meshes that will be loaded.
  125881. * This is for the default controllers only.
  125882. */
  125883. renderingGroupId?: number;
  125884. }
  125885. /**
  125886. * Represents an XR controller
  125887. */
  125888. export class WebXRInputSource {
  125889. private _scene;
  125890. /** The underlying input source for the controller */
  125891. inputSource: XRInputSource;
  125892. private _options;
  125893. private _tmpVector;
  125894. private _uniqueId;
  125895. /**
  125896. * 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
  125897. */
  125898. grip?: AbstractMesh;
  125899. /**
  125900. * If available, this is the gamepad object related to this controller.
  125901. * Using this object it is possible to get click events and trackpad changes of the
  125902. * webxr controller that is currently being used.
  125903. */
  125904. motionController?: WebXRAbstractMotionController;
  125905. /**
  125906. * Event that fires when the controller is removed/disposed.
  125907. * The object provided as event data is this controller, after associated assets were disposed.
  125908. * uniqueId is still available.
  125909. */
  125910. onDisposeObservable: Observable<WebXRInputSource>;
  125911. /**
  125912. * Will be triggered when the mesh associated with the motion controller is done loading.
  125913. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  125914. * A shortened version of controller -> motion controller -> on mesh loaded.
  125915. */
  125916. onMeshLoadedObservable: Observable<AbstractMesh>;
  125917. /**
  125918. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  125919. */
  125920. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  125921. /**
  125922. * Pointer which can be used to select objects or attach a visible laser to
  125923. */
  125924. pointer: AbstractMesh;
  125925. /**
  125926. * Creates the input source object
  125927. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  125928. * @param _scene the scene which the controller should be associated to
  125929. * @param inputSource the underlying input source for the controller
  125930. * @param _options options for this controller creation
  125931. */
  125932. constructor(_scene: Scene,
  125933. /** The underlying input source for the controller */
  125934. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  125935. /**
  125936. * Get this controllers unique id
  125937. */
  125938. get uniqueId(): string;
  125939. /**
  125940. * Disposes of the object
  125941. */
  125942. dispose(): void;
  125943. /**
  125944. * Gets a world space ray coming from the pointer or grip
  125945. * @param result the resulting ray
  125946. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  125947. */
  125948. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  125949. /**
  125950. * Updates the controller pose based on the given XRFrame
  125951. * @param xrFrame xr frame to update the pose with
  125952. * @param referenceSpace reference space to use
  125953. */
  125954. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  125955. }
  125956. }
  125957. declare module BABYLON {
  125958. /**
  125959. * The schema for initialization options of the XR Input class
  125960. */
  125961. export interface IWebXRInputOptions {
  125962. /**
  125963. * If set to true no model will be automatically loaded
  125964. */
  125965. doNotLoadControllerMeshes?: boolean;
  125966. /**
  125967. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  125968. * If not found, the xr input profile data will be used.
  125969. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  125970. */
  125971. forceInputProfile?: string;
  125972. /**
  125973. * Do not send a request to the controller repository to load the profile.
  125974. *
  125975. * Instead, use the controllers available in babylon itself.
  125976. */
  125977. disableOnlineControllerRepository?: boolean;
  125978. /**
  125979. * A custom URL for the controllers repository
  125980. */
  125981. customControllersRepositoryURL?: string;
  125982. /**
  125983. * Should the controller model's components not move according to the user input
  125984. */
  125985. disableControllerAnimation?: boolean;
  125986. /**
  125987. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  125988. */
  125989. controllerOptions?: IWebXRControllerOptions;
  125990. }
  125991. /**
  125992. * XR input used to track XR inputs such as controllers/rays
  125993. */
  125994. export class WebXRInput implements IDisposable {
  125995. /**
  125996. * the xr session manager for this session
  125997. */
  125998. xrSessionManager: WebXRSessionManager;
  125999. /**
  126000. * the WebXR camera for this session. Mainly used for teleportation
  126001. */
  126002. xrCamera: WebXRCamera;
  126003. private readonly options;
  126004. /**
  126005. * XR controllers being tracked
  126006. */
  126007. controllers: Array<WebXRInputSource>;
  126008. private _frameObserver;
  126009. private _sessionEndedObserver;
  126010. private _sessionInitObserver;
  126011. /**
  126012. * Event when a controller has been connected/added
  126013. */
  126014. onControllerAddedObservable: Observable<WebXRInputSource>;
  126015. /**
  126016. * Event when a controller has been removed/disconnected
  126017. */
  126018. onControllerRemovedObservable: Observable<WebXRInputSource>;
  126019. /**
  126020. * Initializes the WebXRInput
  126021. * @param xrSessionManager the xr session manager for this session
  126022. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  126023. * @param options = initialization options for this xr input
  126024. */
  126025. constructor(
  126026. /**
  126027. * the xr session manager for this session
  126028. */
  126029. xrSessionManager: WebXRSessionManager,
  126030. /**
  126031. * the WebXR camera for this session. Mainly used for teleportation
  126032. */
  126033. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  126034. private _onInputSourcesChange;
  126035. private _addAndRemoveControllers;
  126036. /**
  126037. * Disposes of the object
  126038. */
  126039. dispose(): void;
  126040. }
  126041. }
  126042. declare module BABYLON {
  126043. /**
  126044. * This is the base class for all WebXR features.
  126045. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  126046. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  126047. */
  126048. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  126049. protected _xrSessionManager: WebXRSessionManager;
  126050. private _attached;
  126051. private _removeOnDetach;
  126052. /**
  126053. * Should auto-attach be disabled?
  126054. */
  126055. disableAutoAttach: boolean;
  126056. /**
  126057. * Construct a new (abstract) WebXR feature
  126058. * @param _xrSessionManager the xr session manager for this feature
  126059. */
  126060. constructor(_xrSessionManager: WebXRSessionManager);
  126061. /**
  126062. * Is this feature attached
  126063. */
  126064. get attached(): boolean;
  126065. /**
  126066. * attach this feature
  126067. *
  126068. * @param force should attachment be forced (even when already attached)
  126069. * @returns true if successful, false is failed or already attached
  126070. */
  126071. attach(force?: boolean): boolean;
  126072. /**
  126073. * detach this feature.
  126074. *
  126075. * @returns true if successful, false if failed or already detached
  126076. */
  126077. detach(): boolean;
  126078. /**
  126079. * Dispose this feature and all of the resources attached
  126080. */
  126081. dispose(): void;
  126082. /**
  126083. * This is used to register callbacks that will automatically be removed when detach is called.
  126084. * @param observable the observable to which the observer will be attached
  126085. * @param callback the callback to register
  126086. */
  126087. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  126088. /**
  126089. * Code in this function will be executed on each xrFrame received from the browser.
  126090. * This function will not execute after the feature is detached.
  126091. * @param _xrFrame the current frame
  126092. */
  126093. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  126094. }
  126095. }
  126096. declare module BABYLON {
  126097. /**
  126098. * Renders a layer on top of an existing scene
  126099. */
  126100. export class UtilityLayerRenderer implements IDisposable {
  126101. /** the original scene that will be rendered on top of */
  126102. originalScene: Scene;
  126103. private _pointerCaptures;
  126104. private _lastPointerEvents;
  126105. private static _DefaultUtilityLayer;
  126106. private static _DefaultKeepDepthUtilityLayer;
  126107. private _sharedGizmoLight;
  126108. private _renderCamera;
  126109. /**
  126110. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  126111. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  126112. * @returns the camera that is used when rendering the utility layer
  126113. */
  126114. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  126115. /**
  126116. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  126117. * @param cam the camera that should be used when rendering the utility layer
  126118. */
  126119. setRenderCamera(cam: Nullable<Camera>): void;
  126120. /**
  126121. * @hidden
  126122. * Light which used by gizmos to get light shading
  126123. */
  126124. _getSharedGizmoLight(): HemisphericLight;
  126125. /**
  126126. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  126127. */
  126128. pickUtilitySceneFirst: boolean;
  126129. /**
  126130. * 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)
  126131. */
  126132. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  126133. /**
  126134. * 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)
  126135. */
  126136. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  126137. /**
  126138. * The scene that is rendered on top of the original scene
  126139. */
  126140. utilityLayerScene: Scene;
  126141. /**
  126142. * If the utility layer should automatically be rendered on top of existing scene
  126143. */
  126144. shouldRender: boolean;
  126145. /**
  126146. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  126147. */
  126148. onlyCheckPointerDownEvents: boolean;
  126149. /**
  126150. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  126151. */
  126152. processAllEvents: boolean;
  126153. /**
  126154. * Observable raised when the pointer move from the utility layer scene to the main scene
  126155. */
  126156. onPointerOutObservable: Observable<number>;
  126157. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  126158. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  126159. private _afterRenderObserver;
  126160. private _sceneDisposeObserver;
  126161. private _originalPointerObserver;
  126162. /**
  126163. * Instantiates a UtilityLayerRenderer
  126164. * @param originalScene the original scene that will be rendered on top of
  126165. * @param handleEvents boolean indicating if the utility layer should handle events
  126166. */
  126167. constructor(
  126168. /** the original scene that will be rendered on top of */
  126169. originalScene: Scene, handleEvents?: boolean);
  126170. private _notifyObservers;
  126171. /**
  126172. * Renders the utility layers scene on top of the original scene
  126173. */
  126174. render(): void;
  126175. /**
  126176. * Disposes of the renderer
  126177. */
  126178. dispose(): void;
  126179. private _updateCamera;
  126180. }
  126181. }
  126182. declare module BABYLON {
  126183. /**
  126184. * Options interface for the pointer selection module
  126185. */
  126186. export interface IWebXRControllerPointerSelectionOptions {
  126187. /**
  126188. * if provided, this scene will be used to render meshes.
  126189. */
  126190. customUtilityLayerScene?: Scene;
  126191. /**
  126192. * 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)
  126193. * If not disabled, the last picked point will be used to execute a pointer up event
  126194. * If disabled, pointer up event will be triggered right after the pointer down event.
  126195. * Used in screen and gaze target ray mode only
  126196. */
  126197. disablePointerUpOnTouchOut: boolean;
  126198. /**
  126199. * For gaze mode (time to select instead of press)
  126200. */
  126201. forceGazeMode: boolean;
  126202. /**
  126203. * 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
  126204. * to start a new countdown to the pointer down event.
  126205. * Defaults to 1.
  126206. */
  126207. gazeModePointerMovedFactor?: number;
  126208. /**
  126209. * Different button type to use instead of the main component
  126210. */
  126211. overrideButtonId?: string;
  126212. /**
  126213. * use this rendering group id for the meshes (optional)
  126214. */
  126215. renderingGroupId?: number;
  126216. /**
  126217. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  126218. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  126219. * 3000 means 3 seconds between pointing at something and selecting it
  126220. */
  126221. timeToSelect?: number;
  126222. /**
  126223. * Should meshes created here be added to a utility layer or the main scene
  126224. */
  126225. useUtilityLayer?: boolean;
  126226. /**
  126227. * the xr input to use with this pointer selection
  126228. */
  126229. xrInput: WebXRInput;
  126230. }
  126231. /**
  126232. * A module that will enable pointer selection for motion controllers of XR Input Sources
  126233. */
  126234. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  126235. private readonly _options;
  126236. private static _idCounter;
  126237. private _attachController;
  126238. private _controllers;
  126239. private _scene;
  126240. private _tmpVectorForPickCompare;
  126241. /**
  126242. * The module's name
  126243. */
  126244. static readonly Name: string;
  126245. /**
  126246. * The (Babylon) version of this module.
  126247. * This is an integer representing the implementation version.
  126248. * This number does not correspond to the WebXR specs version
  126249. */
  126250. static readonly Version: number;
  126251. /**
  126252. * Disable lighting on the laser pointer (so it will always be visible)
  126253. */
  126254. disablePointerLighting: boolean;
  126255. /**
  126256. * Disable lighting on the selection mesh (so it will always be visible)
  126257. */
  126258. disableSelectionMeshLighting: boolean;
  126259. /**
  126260. * Should the laser pointer be displayed
  126261. */
  126262. displayLaserPointer: boolean;
  126263. /**
  126264. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  126265. */
  126266. displaySelectionMesh: boolean;
  126267. /**
  126268. * This color will be set to the laser pointer when selection is triggered
  126269. */
  126270. laserPointerPickedColor: Color3;
  126271. /**
  126272. * Default color of the laser pointer
  126273. */
  126274. laserPointerDefaultColor: Color3;
  126275. /**
  126276. * default color of the selection ring
  126277. */
  126278. selectionMeshDefaultColor: Color3;
  126279. /**
  126280. * This color will be applied to the selection ring when selection is triggered
  126281. */
  126282. selectionMeshPickedColor: Color3;
  126283. /**
  126284. * Optional filter to be used for ray selection. This predicate shares behavior with
  126285. * scene.pointerMovePredicate which takes priority if it is also assigned.
  126286. */
  126287. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  126288. /**
  126289. * constructs a new background remover module
  126290. * @param _xrSessionManager the session manager for this module
  126291. * @param _options read-only options to be used in this module
  126292. */
  126293. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  126294. /**
  126295. * attach this feature
  126296. * Will usually be called by the features manager
  126297. *
  126298. * @returns true if successful.
  126299. */
  126300. attach(): boolean;
  126301. /**
  126302. * detach this feature.
  126303. * Will usually be called by the features manager
  126304. *
  126305. * @returns true if successful.
  126306. */
  126307. detach(): boolean;
  126308. /**
  126309. * Will get the mesh under a specific pointer.
  126310. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  126311. * @param controllerId the controllerId to check
  126312. * @returns The mesh under pointer or null if no mesh is under the pointer
  126313. */
  126314. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  126315. /**
  126316. * Get the xr controller that correlates to the pointer id in the pointer event
  126317. *
  126318. * @param id the pointer id to search for
  126319. * @returns the controller that correlates to this id or null if not found
  126320. */
  126321. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  126322. protected _onXRFrame(_xrFrame: XRFrame): void;
  126323. private _attachGazeMode;
  126324. private _attachScreenRayMode;
  126325. private _attachTrackedPointerRayMode;
  126326. private _convertNormalToDirectionOfRay;
  126327. private _detachController;
  126328. private _generateNewMeshPair;
  126329. private _pickingMoved;
  126330. private _updatePointerDistance;
  126331. /** @hidden */
  126332. get lasterPointerDefaultColor(): Color3;
  126333. }
  126334. }
  126335. declare module BABYLON {
  126336. /**
  126337. * Button which can be used to enter a different mode of XR
  126338. */
  126339. export class WebXREnterExitUIButton {
  126340. /** button element */
  126341. element: HTMLElement;
  126342. /** XR initialization options for the button */
  126343. sessionMode: XRSessionMode;
  126344. /** Reference space type */
  126345. referenceSpaceType: XRReferenceSpaceType;
  126346. /**
  126347. * Creates a WebXREnterExitUIButton
  126348. * @param element button element
  126349. * @param sessionMode XR initialization session mode
  126350. * @param referenceSpaceType the type of reference space to be used
  126351. */
  126352. constructor(
  126353. /** button element */
  126354. element: HTMLElement,
  126355. /** XR initialization options for the button */
  126356. sessionMode: XRSessionMode,
  126357. /** Reference space type */
  126358. referenceSpaceType: XRReferenceSpaceType);
  126359. /**
  126360. * Extendable function which can be used to update the button's visuals when the state changes
  126361. * @param activeButton the current active button in the UI
  126362. */
  126363. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  126364. }
  126365. /**
  126366. * Options to create the webXR UI
  126367. */
  126368. export class WebXREnterExitUIOptions {
  126369. /**
  126370. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  126371. */
  126372. customButtons?: Array<WebXREnterExitUIButton>;
  126373. /**
  126374. * A reference space type to use when creating the default button.
  126375. * Default is local-floor
  126376. */
  126377. referenceSpaceType?: XRReferenceSpaceType;
  126378. /**
  126379. * Context to enter xr with
  126380. */
  126381. renderTarget?: Nullable<WebXRRenderTarget>;
  126382. /**
  126383. * A session mode to use when creating the default button.
  126384. * Default is immersive-vr
  126385. */
  126386. sessionMode?: XRSessionMode;
  126387. /**
  126388. * A list of optional features to init the session with
  126389. */
  126390. optionalFeatures?: string[];
  126391. }
  126392. /**
  126393. * UI to allow the user to enter/exit XR mode
  126394. */
  126395. export class WebXREnterExitUI implements IDisposable {
  126396. private scene;
  126397. /** version of the options passed to this UI */
  126398. options: WebXREnterExitUIOptions;
  126399. private _activeButton;
  126400. private _buttons;
  126401. private _overlay;
  126402. /**
  126403. * Fired every time the active button is changed.
  126404. *
  126405. * When xr is entered via a button that launches xr that button will be the callback parameter
  126406. *
  126407. * When exiting xr the callback parameter will be null)
  126408. */
  126409. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  126410. /**
  126411. *
  126412. * @param scene babylon scene object to use
  126413. * @param options (read-only) version of the options passed to this UI
  126414. */
  126415. private constructor();
  126416. /**
  126417. * Creates UI to allow the user to enter/exit XR mode
  126418. * @param scene the scene to add the ui to
  126419. * @param helper the xr experience helper to enter/exit xr with
  126420. * @param options options to configure the UI
  126421. * @returns the created ui
  126422. */
  126423. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  126424. /**
  126425. * Disposes of the XR UI component
  126426. */
  126427. dispose(): void;
  126428. private _updateButtons;
  126429. }
  126430. }
  126431. declare module BABYLON {
  126432. /**
  126433. * Class containing static functions to help procedurally build meshes
  126434. */
  126435. export class LinesBuilder {
  126436. /**
  126437. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  126438. * * 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
  126439. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  126440. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  126441. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  126442. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  126443. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126444. * * 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
  126445. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  126446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  126448. * @param name defines the name of the new line system
  126449. * @param options defines the options used to create the line system
  126450. * @param scene defines the hosting scene
  126451. * @returns a new line system mesh
  126452. */
  126453. static CreateLineSystem(name: string, options: {
  126454. lines: Vector3[][];
  126455. updatable?: boolean;
  126456. instance?: Nullable<LinesMesh>;
  126457. colors?: Nullable<Color4[][]>;
  126458. useVertexAlpha?: boolean;
  126459. }, scene: Nullable<Scene>): LinesMesh;
  126460. /**
  126461. * Creates a line mesh
  126462. * 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
  126463. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126464. * * The parameter `points` is an array successive Vector3
  126465. * * 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
  126466. * * The optional parameter `colors` is an array of successive Color4, one per line point
  126467. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  126468. * * When updating an instance, remember that only point positions can change, not the number of points
  126469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126470. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  126471. * @param name defines the name of the new line system
  126472. * @param options defines the options used to create the line system
  126473. * @param scene defines the hosting scene
  126474. * @returns a new line mesh
  126475. */
  126476. static CreateLines(name: string, options: {
  126477. points: Vector3[];
  126478. updatable?: boolean;
  126479. instance?: Nullable<LinesMesh>;
  126480. colors?: Color4[];
  126481. useVertexAlpha?: boolean;
  126482. }, scene?: Nullable<Scene>): LinesMesh;
  126483. /**
  126484. * Creates a dashed line mesh
  126485. * * 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
  126486. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126487. * * The parameter `points` is an array successive Vector3
  126488. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  126489. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  126490. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  126491. * * 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
  126492. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126493. * * When updating an instance, remember that only point positions can change, not the number of points
  126494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126495. * @param name defines the name of the mesh
  126496. * @param options defines the options used to create the mesh
  126497. * @param scene defines the hosting scene
  126498. * @returns the dashed line mesh
  126499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  126500. */
  126501. static CreateDashedLines(name: string, options: {
  126502. points: Vector3[];
  126503. dashSize?: number;
  126504. gapSize?: number;
  126505. dashNb?: number;
  126506. updatable?: boolean;
  126507. instance?: LinesMesh;
  126508. useVertexAlpha?: boolean;
  126509. }, scene?: Nullable<Scene>): LinesMesh;
  126510. }
  126511. }
  126512. declare module BABYLON {
  126513. /**
  126514. * Construction options for a timer
  126515. */
  126516. export interface ITimerOptions<T> {
  126517. /**
  126518. * Time-to-end
  126519. */
  126520. timeout: number;
  126521. /**
  126522. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  126523. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  126524. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  126525. */
  126526. contextObservable: Observable<T>;
  126527. /**
  126528. * Optional parameters when adding an observer to the observable
  126529. */
  126530. observableParameters?: {
  126531. mask?: number;
  126532. insertFirst?: boolean;
  126533. scope?: any;
  126534. };
  126535. /**
  126536. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  126537. */
  126538. breakCondition?: (data?: ITimerData<T>) => boolean;
  126539. /**
  126540. * Will be triggered when the time condition has met
  126541. */
  126542. onEnded?: (data: ITimerData<any>) => void;
  126543. /**
  126544. * Will be triggered when the break condition has met (prematurely ended)
  126545. */
  126546. onAborted?: (data: ITimerData<any>) => void;
  126547. /**
  126548. * Optional function to execute on each tick (or count)
  126549. */
  126550. onTick?: (data: ITimerData<any>) => void;
  126551. }
  126552. /**
  126553. * An interface defining the data sent by the timer
  126554. */
  126555. export interface ITimerData<T> {
  126556. /**
  126557. * When did it start
  126558. */
  126559. startTime: number;
  126560. /**
  126561. * Time now
  126562. */
  126563. currentTime: number;
  126564. /**
  126565. * Time passed since started
  126566. */
  126567. deltaTime: number;
  126568. /**
  126569. * How much is completed, in [0.0...1.0].
  126570. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  126571. */
  126572. completeRate: number;
  126573. /**
  126574. * What the registered observable sent in the last count
  126575. */
  126576. payload: T;
  126577. }
  126578. /**
  126579. * The current state of the timer
  126580. */
  126581. export enum TimerState {
  126582. /**
  126583. * Timer initialized, not yet started
  126584. */
  126585. INIT = 0,
  126586. /**
  126587. * Timer started and counting
  126588. */
  126589. STARTED = 1,
  126590. /**
  126591. * Timer ended (whether aborted or time reached)
  126592. */
  126593. ENDED = 2
  126594. }
  126595. /**
  126596. * A simple version of the timer. Will take options and start the timer immediately after calling it
  126597. *
  126598. * @param options options with which to initialize this timer
  126599. */
  126600. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  126601. /**
  126602. * An advanced implementation of a timer class
  126603. */
  126604. export class AdvancedTimer<T = any> implements IDisposable {
  126605. /**
  126606. * Will notify each time the timer calculates the remaining time
  126607. */
  126608. onEachCountObservable: Observable<ITimerData<T>>;
  126609. /**
  126610. * Will trigger when the timer was aborted due to the break condition
  126611. */
  126612. onTimerAbortedObservable: Observable<ITimerData<T>>;
  126613. /**
  126614. * Will trigger when the timer ended successfully
  126615. */
  126616. onTimerEndedObservable: Observable<ITimerData<T>>;
  126617. /**
  126618. * Will trigger when the timer state has changed
  126619. */
  126620. onStateChangedObservable: Observable<TimerState>;
  126621. private _observer;
  126622. private _contextObservable;
  126623. private _observableParameters;
  126624. private _startTime;
  126625. private _timer;
  126626. private _state;
  126627. private _breakCondition;
  126628. private _timeToEnd;
  126629. private _breakOnNextTick;
  126630. /**
  126631. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  126632. * @param options construction options for this advanced timer
  126633. */
  126634. constructor(options: ITimerOptions<T>);
  126635. /**
  126636. * set a breaking condition for this timer. Default is to never break during count
  126637. * @param predicate the new break condition. Returns true to break, false otherwise
  126638. */
  126639. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  126640. /**
  126641. * Reset ALL associated observables in this advanced timer
  126642. */
  126643. clearObservables(): void;
  126644. /**
  126645. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  126646. *
  126647. * @param timeToEnd how much time to measure until timer ended
  126648. */
  126649. start(timeToEnd?: number): void;
  126650. /**
  126651. * Will force a stop on the next tick.
  126652. */
  126653. stop(): void;
  126654. /**
  126655. * Dispose this timer, clearing all resources
  126656. */
  126657. dispose(): void;
  126658. private _setState;
  126659. private _tick;
  126660. private _stop;
  126661. }
  126662. }
  126663. declare module BABYLON {
  126664. /**
  126665. * The options container for the teleportation module
  126666. */
  126667. export interface IWebXRTeleportationOptions {
  126668. /**
  126669. * if provided, this scene will be used to render meshes.
  126670. */
  126671. customUtilityLayerScene?: Scene;
  126672. /**
  126673. * Values to configure the default target mesh
  126674. */
  126675. defaultTargetMeshOptions?: {
  126676. /**
  126677. * Fill color of the teleportation area
  126678. */
  126679. teleportationFillColor?: string;
  126680. /**
  126681. * Border color for the teleportation area
  126682. */
  126683. teleportationBorderColor?: string;
  126684. /**
  126685. * Disable the mesh's animation sequence
  126686. */
  126687. disableAnimation?: boolean;
  126688. /**
  126689. * Disable lighting on the material or the ring and arrow
  126690. */
  126691. disableLighting?: boolean;
  126692. /**
  126693. * Override the default material of the torus and arrow
  126694. */
  126695. torusArrowMaterial?: Material;
  126696. };
  126697. /**
  126698. * A list of meshes to use as floor meshes.
  126699. * Meshes can be added and removed after initializing the feature using the
  126700. * addFloorMesh and removeFloorMesh functions
  126701. * If empty, rotation will still work
  126702. */
  126703. floorMeshes?: AbstractMesh[];
  126704. /**
  126705. * use this rendering group id for the meshes (optional)
  126706. */
  126707. renderingGroupId?: number;
  126708. /**
  126709. * Should teleportation move only to snap points
  126710. */
  126711. snapPointsOnly?: boolean;
  126712. /**
  126713. * An array of points to which the teleportation will snap to.
  126714. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  126715. */
  126716. snapPositions?: Vector3[];
  126717. /**
  126718. * How close should the teleportation ray be in order to snap to position.
  126719. * Default to 0.8 units (meters)
  126720. */
  126721. snapToPositionRadius?: number;
  126722. /**
  126723. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  126724. * If you want to support rotation, make sure your mesh has a direction indicator.
  126725. *
  126726. * When left untouched, the default mesh will be initialized.
  126727. */
  126728. teleportationTargetMesh?: AbstractMesh;
  126729. /**
  126730. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  126731. */
  126732. timeToTeleport?: number;
  126733. /**
  126734. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  126735. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  126736. */
  126737. useMainComponentOnly?: boolean;
  126738. /**
  126739. * Should meshes created here be added to a utility layer or the main scene
  126740. */
  126741. useUtilityLayer?: boolean;
  126742. /**
  126743. * Babylon XR Input class for controller
  126744. */
  126745. xrInput: WebXRInput;
  126746. }
  126747. /**
  126748. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  126749. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  126750. * the input of the attached controllers.
  126751. */
  126752. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  126753. private _options;
  126754. private _controllers;
  126755. private _currentTeleportationControllerId;
  126756. private _floorMeshes;
  126757. private _quadraticBezierCurve;
  126758. private _selectionFeature;
  126759. private _snapToPositions;
  126760. private _snappedToPoint;
  126761. private _teleportationRingMaterial?;
  126762. private _tmpRay;
  126763. private _tmpVector;
  126764. /**
  126765. * The module's name
  126766. */
  126767. static readonly Name: string;
  126768. /**
  126769. * The (Babylon) version of this module.
  126770. * This is an integer representing the implementation version.
  126771. * This number does not correspond to the webxr specs version
  126772. */
  126773. static readonly Version: number;
  126774. /**
  126775. * Is movement backwards enabled
  126776. */
  126777. backwardsMovementEnabled: boolean;
  126778. /**
  126779. * Distance to travel when moving backwards
  126780. */
  126781. backwardsTeleportationDistance: number;
  126782. /**
  126783. * The distance from the user to the inspection point in the direction of the controller
  126784. * A higher number will allow the user to move further
  126785. * defaults to 5 (meters, in xr units)
  126786. */
  126787. parabolicCheckRadius: number;
  126788. /**
  126789. * Should the module support parabolic ray on top of direct ray
  126790. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  126791. * Very helpful when moving between floors / different heights
  126792. */
  126793. parabolicRayEnabled: boolean;
  126794. /**
  126795. * How much rotation should be applied when rotating right and left
  126796. */
  126797. rotationAngle: number;
  126798. /**
  126799. * Is rotation enabled when moving forward?
  126800. * Disabling this feature will prevent the user from deciding the direction when teleporting
  126801. */
  126802. rotationEnabled: boolean;
  126803. /**
  126804. * constructs a new anchor system
  126805. * @param _xrSessionManager an instance of WebXRSessionManager
  126806. * @param _options configuration object for this feature
  126807. */
  126808. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  126809. /**
  126810. * Get the snapPointsOnly flag
  126811. */
  126812. get snapPointsOnly(): boolean;
  126813. /**
  126814. * Sets the snapPointsOnly flag
  126815. * @param snapToPoints should teleportation be exclusively to snap points
  126816. */
  126817. set snapPointsOnly(snapToPoints: boolean);
  126818. /**
  126819. * Add a new mesh to the floor meshes array
  126820. * @param mesh the mesh to use as floor mesh
  126821. */
  126822. addFloorMesh(mesh: AbstractMesh): void;
  126823. /**
  126824. * Add a new snap-to point to fix teleportation to this position
  126825. * @param newSnapPoint The new Snap-To point
  126826. */
  126827. addSnapPoint(newSnapPoint: Vector3): void;
  126828. attach(): boolean;
  126829. detach(): boolean;
  126830. dispose(): void;
  126831. /**
  126832. * Remove a mesh from the floor meshes array
  126833. * @param mesh the mesh to remove
  126834. */
  126835. removeFloorMesh(mesh: AbstractMesh): void;
  126836. /**
  126837. * Remove a mesh from the floor meshes array using its name
  126838. * @param name the mesh name to remove
  126839. */
  126840. removeFloorMeshByName(name: string): void;
  126841. /**
  126842. * 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
  126843. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  126844. * @returns was the point found and removed or not
  126845. */
  126846. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  126847. /**
  126848. * This function sets a selection feature that will be disabled when
  126849. * the forward ray is shown and will be reattached when hidden.
  126850. * This is used to remove the selection rays when moving.
  126851. * @param selectionFeature the feature to disable when forward movement is enabled
  126852. */
  126853. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  126854. protected _onXRFrame(_xrFrame: XRFrame): void;
  126855. private _attachController;
  126856. private _createDefaultTargetMesh;
  126857. private _detachController;
  126858. private _findClosestSnapPointWithRadius;
  126859. private _setTargetMeshPosition;
  126860. private _setTargetMeshVisibility;
  126861. private _showParabolicPath;
  126862. private _teleportForward;
  126863. }
  126864. }
  126865. declare module BABYLON {
  126866. /**
  126867. * Options for the default xr helper
  126868. */
  126869. export class WebXRDefaultExperienceOptions {
  126870. /**
  126871. * Enable or disable default UI to enter XR
  126872. */
  126873. disableDefaultUI?: boolean;
  126874. /**
  126875. * Should teleportation not initialize. defaults to false.
  126876. */
  126877. disableTeleportation?: boolean;
  126878. /**
  126879. * Floor meshes that will be used for teleport
  126880. */
  126881. floorMeshes?: Array<AbstractMesh>;
  126882. /**
  126883. * If set to true, the first frame will not be used to reset position
  126884. * The first frame is mainly used when copying transformation from the old camera
  126885. * Mainly used in AR
  126886. */
  126887. ignoreNativeCameraTransformation?: boolean;
  126888. /**
  126889. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  126890. */
  126891. inputOptions?: IWebXRInputOptions;
  126892. /**
  126893. * optional configuration for the output canvas
  126894. */
  126895. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  126896. /**
  126897. * optional UI options. This can be used among other to change session mode and reference space type
  126898. */
  126899. uiOptions?: WebXREnterExitUIOptions;
  126900. /**
  126901. * When loading teleportation and pointer select, use stable versions instead of latest.
  126902. */
  126903. useStablePlugins?: boolean;
  126904. /**
  126905. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  126906. */
  126907. renderingGroupId?: number;
  126908. /**
  126909. * A list of optional features to init the session with
  126910. * If set to true, all features we support will be added
  126911. */
  126912. optionalFeatures?: boolean | string[];
  126913. }
  126914. /**
  126915. * Default experience which provides a similar setup to the previous webVRExperience
  126916. */
  126917. export class WebXRDefaultExperience {
  126918. /**
  126919. * Base experience
  126920. */
  126921. baseExperience: WebXRExperienceHelper;
  126922. /**
  126923. * Enables ui for entering/exiting xr
  126924. */
  126925. enterExitUI: WebXREnterExitUI;
  126926. /**
  126927. * Input experience extension
  126928. */
  126929. input: WebXRInput;
  126930. /**
  126931. * Enables laser pointer and selection
  126932. */
  126933. pointerSelection: WebXRControllerPointerSelection;
  126934. /**
  126935. * Default target xr should render to
  126936. */
  126937. renderTarget: WebXRRenderTarget;
  126938. /**
  126939. * Enables teleportation
  126940. */
  126941. teleportation: WebXRMotionControllerTeleportation;
  126942. private constructor();
  126943. /**
  126944. * Creates the default xr experience
  126945. * @param scene scene
  126946. * @param options options for basic configuration
  126947. * @returns resulting WebXRDefaultExperience
  126948. */
  126949. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  126950. /**
  126951. * DIsposes of the experience helper
  126952. */
  126953. dispose(): void;
  126954. }
  126955. }
  126956. declare module BABYLON {
  126957. /**
  126958. * Options to modify the vr teleportation behavior.
  126959. */
  126960. export interface VRTeleportationOptions {
  126961. /**
  126962. * The name of the mesh which should be used as the teleportation floor. (default: null)
  126963. */
  126964. floorMeshName?: string;
  126965. /**
  126966. * A list of meshes to be used as the teleportation floor. (default: empty)
  126967. */
  126968. floorMeshes?: Mesh[];
  126969. /**
  126970. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  126971. */
  126972. teleportationMode?: number;
  126973. /**
  126974. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  126975. */
  126976. teleportationTime?: number;
  126977. /**
  126978. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  126979. */
  126980. teleportationSpeed?: number;
  126981. /**
  126982. * The easing function used in the animation or null for Linear. (default CircleEase)
  126983. */
  126984. easingFunction?: EasingFunction;
  126985. }
  126986. /**
  126987. * Options to modify the vr experience helper's behavior.
  126988. */
  126989. export interface VRExperienceHelperOptions extends WebVROptions {
  126990. /**
  126991. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  126992. */
  126993. createDeviceOrientationCamera?: boolean;
  126994. /**
  126995. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  126996. */
  126997. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  126998. /**
  126999. * Uses the main button on the controller to toggle the laser casted. (default: true)
  127000. */
  127001. laserToggle?: boolean;
  127002. /**
  127003. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  127004. */
  127005. floorMeshes?: Mesh[];
  127006. /**
  127007. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  127008. */
  127009. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  127010. /**
  127011. * Defines if WebXR should be used instead of WebVR (if available)
  127012. */
  127013. useXR?: boolean;
  127014. }
  127015. /**
  127016. * Event containing information after VR has been entered
  127017. */
  127018. export class OnAfterEnteringVRObservableEvent {
  127019. /**
  127020. * If entering vr was successful
  127021. */
  127022. success: boolean;
  127023. }
  127024. /**
  127025. * Helps to quickly add VR support to an existing scene.
  127026. * See https://doc.babylonjs.com/how_to/webvr_helper
  127027. */
  127028. export class VRExperienceHelper {
  127029. /** Options to modify the vr experience helper's behavior. */
  127030. webVROptions: VRExperienceHelperOptions;
  127031. private _scene;
  127032. private _position;
  127033. private _btnVR;
  127034. private _btnVRDisplayed;
  127035. private _webVRsupported;
  127036. private _webVRready;
  127037. private _webVRrequesting;
  127038. private _webVRpresenting;
  127039. private _hasEnteredVR;
  127040. private _fullscreenVRpresenting;
  127041. private _inputElement;
  127042. private _webVRCamera;
  127043. private _vrDeviceOrientationCamera;
  127044. private _deviceOrientationCamera;
  127045. private _existingCamera;
  127046. private _onKeyDown;
  127047. private _onVrDisplayPresentChange;
  127048. private _onVRDisplayChanged;
  127049. private _onVRRequestPresentStart;
  127050. private _onVRRequestPresentComplete;
  127051. /**
  127052. * 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)
  127053. */
  127054. enableGazeEvenWhenNoPointerLock: boolean;
  127055. /**
  127056. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  127057. */
  127058. exitVROnDoubleTap: boolean;
  127059. /**
  127060. * Observable raised right before entering VR.
  127061. */
  127062. onEnteringVRObservable: Observable<VRExperienceHelper>;
  127063. /**
  127064. * Observable raised when entering VR has completed.
  127065. */
  127066. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  127067. /**
  127068. * Observable raised when exiting VR.
  127069. */
  127070. onExitingVRObservable: Observable<VRExperienceHelper>;
  127071. /**
  127072. * Observable raised when controller mesh is loaded.
  127073. */
  127074. onControllerMeshLoadedObservable: Observable<WebVRController>;
  127075. /** Return this.onEnteringVRObservable
  127076. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  127077. */
  127078. get onEnteringVR(): Observable<VRExperienceHelper>;
  127079. /** Return this.onExitingVRObservable
  127080. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  127081. */
  127082. get onExitingVR(): Observable<VRExperienceHelper>;
  127083. /** Return this.onControllerMeshLoadedObservable
  127084. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  127085. */
  127086. get onControllerMeshLoaded(): Observable<WebVRController>;
  127087. private _rayLength;
  127088. private _useCustomVRButton;
  127089. private _teleportationRequested;
  127090. private _teleportActive;
  127091. private _floorMeshName;
  127092. private _floorMeshesCollection;
  127093. private _teleportationMode;
  127094. private _teleportationTime;
  127095. private _teleportationSpeed;
  127096. private _teleportationEasing;
  127097. private _rotationAllowed;
  127098. private _teleportBackwardsVector;
  127099. private _teleportationTarget;
  127100. private _isDefaultTeleportationTarget;
  127101. private _postProcessMove;
  127102. private _teleportationFillColor;
  127103. private _teleportationBorderColor;
  127104. private _rotationAngle;
  127105. private _haloCenter;
  127106. private _cameraGazer;
  127107. private _padSensibilityUp;
  127108. private _padSensibilityDown;
  127109. private _leftController;
  127110. private _rightController;
  127111. private _gazeColor;
  127112. private _laserColor;
  127113. private _pickedLaserColor;
  127114. private _pickedGazeColor;
  127115. /**
  127116. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  127117. */
  127118. onNewMeshSelected: Observable<AbstractMesh>;
  127119. /**
  127120. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  127121. * This observable will provide the mesh and the controller used to select the mesh
  127122. */
  127123. onMeshSelectedWithController: Observable<{
  127124. mesh: AbstractMesh;
  127125. controller: WebVRController;
  127126. }>;
  127127. /**
  127128. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  127129. */
  127130. onNewMeshPicked: Observable<PickingInfo>;
  127131. private _circleEase;
  127132. /**
  127133. * Observable raised before camera teleportation
  127134. */
  127135. onBeforeCameraTeleport: Observable<Vector3>;
  127136. /**
  127137. * Observable raised after camera teleportation
  127138. */
  127139. onAfterCameraTeleport: Observable<Vector3>;
  127140. /**
  127141. * Observable raised when current selected mesh gets unselected
  127142. */
  127143. onSelectedMeshUnselected: Observable<AbstractMesh>;
  127144. private _raySelectionPredicate;
  127145. /**
  127146. * To be optionaly changed by user to define custom ray selection
  127147. */
  127148. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127149. /**
  127150. * To be optionaly changed by user to define custom selection logic (after ray selection)
  127151. */
  127152. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127153. /**
  127154. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  127155. */
  127156. teleportationEnabled: boolean;
  127157. private _defaultHeight;
  127158. private _teleportationInitialized;
  127159. private _interactionsEnabled;
  127160. private _interactionsRequested;
  127161. private _displayGaze;
  127162. private _displayLaserPointer;
  127163. /**
  127164. * The mesh used to display where the user is going to teleport.
  127165. */
  127166. get teleportationTarget(): Mesh;
  127167. /**
  127168. * Sets the mesh to be used to display where the user is going to teleport.
  127169. */
  127170. set teleportationTarget(value: Mesh);
  127171. /**
  127172. * 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
  127173. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  127174. * See https://doc.babylonjs.com/resources/baking_transformations
  127175. */
  127176. get gazeTrackerMesh(): Mesh;
  127177. set gazeTrackerMesh(value: Mesh);
  127178. /**
  127179. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  127180. */
  127181. updateGazeTrackerScale: boolean;
  127182. /**
  127183. * If the gaze trackers color should be updated when selecting meshes
  127184. */
  127185. updateGazeTrackerColor: boolean;
  127186. /**
  127187. * If the controller laser color should be updated when selecting meshes
  127188. */
  127189. updateControllerLaserColor: boolean;
  127190. /**
  127191. * The gaze tracking mesh corresponding to the left controller
  127192. */
  127193. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  127194. /**
  127195. * The gaze tracking mesh corresponding to the right controller
  127196. */
  127197. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  127198. /**
  127199. * If the ray of the gaze should be displayed.
  127200. */
  127201. get displayGaze(): boolean;
  127202. /**
  127203. * Sets if the ray of the gaze should be displayed.
  127204. */
  127205. set displayGaze(value: boolean);
  127206. /**
  127207. * If the ray of the LaserPointer should be displayed.
  127208. */
  127209. get displayLaserPointer(): boolean;
  127210. /**
  127211. * Sets if the ray of the LaserPointer should be displayed.
  127212. */
  127213. set displayLaserPointer(value: boolean);
  127214. /**
  127215. * The deviceOrientationCamera used as the camera when not in VR.
  127216. */
  127217. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  127218. /**
  127219. * Based on the current WebVR support, returns the current VR camera used.
  127220. */
  127221. get currentVRCamera(): Nullable<Camera>;
  127222. /**
  127223. * The webVRCamera which is used when in VR.
  127224. */
  127225. get webVRCamera(): WebVRFreeCamera;
  127226. /**
  127227. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  127228. */
  127229. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  127230. /**
  127231. * The html button that is used to trigger entering into VR.
  127232. */
  127233. get vrButton(): Nullable<HTMLButtonElement>;
  127234. private get _teleportationRequestInitiated();
  127235. /**
  127236. * Defines whether or not Pointer lock should be requested when switching to
  127237. * full screen.
  127238. */
  127239. requestPointerLockOnFullScreen: boolean;
  127240. /**
  127241. * If asking to force XR, this will be populated with the default xr experience
  127242. */
  127243. xr: WebXRDefaultExperience;
  127244. /**
  127245. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  127246. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  127247. */
  127248. xrTestDone: boolean;
  127249. /**
  127250. * Instantiates a VRExperienceHelper.
  127251. * Helps to quickly add VR support to an existing scene.
  127252. * @param scene The scene the VRExperienceHelper belongs to.
  127253. * @param webVROptions Options to modify the vr experience helper's behavior.
  127254. */
  127255. constructor(scene: Scene,
  127256. /** Options to modify the vr experience helper's behavior. */
  127257. webVROptions?: VRExperienceHelperOptions);
  127258. private completeVRInit;
  127259. private _onDefaultMeshLoaded;
  127260. private _onResize;
  127261. private _onFullscreenChange;
  127262. /**
  127263. * Gets a value indicating if we are currently in VR mode.
  127264. */
  127265. get isInVRMode(): boolean;
  127266. private onVrDisplayPresentChange;
  127267. private onVRDisplayChanged;
  127268. private moveButtonToBottomRight;
  127269. private displayVRButton;
  127270. private updateButtonVisibility;
  127271. private _cachedAngularSensibility;
  127272. /**
  127273. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  127274. * Otherwise, will use the fullscreen API.
  127275. */
  127276. enterVR(): void;
  127277. /**
  127278. * Attempt to exit VR, or fullscreen.
  127279. */
  127280. exitVR(): void;
  127281. /**
  127282. * The position of the vr experience helper.
  127283. */
  127284. get position(): Vector3;
  127285. /**
  127286. * Sets the position of the vr experience helper.
  127287. */
  127288. set position(value: Vector3);
  127289. /**
  127290. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  127291. */
  127292. enableInteractions(): void;
  127293. private get _noControllerIsActive();
  127294. private beforeRender;
  127295. private _isTeleportationFloor;
  127296. /**
  127297. * Adds a floor mesh to be used for teleportation.
  127298. * @param floorMesh the mesh to be used for teleportation.
  127299. */
  127300. addFloorMesh(floorMesh: Mesh): void;
  127301. /**
  127302. * Removes a floor mesh from being used for teleportation.
  127303. * @param floorMesh the mesh to be removed.
  127304. */
  127305. removeFloorMesh(floorMesh: Mesh): void;
  127306. /**
  127307. * Enables interactions and teleportation using the VR controllers and gaze.
  127308. * @param vrTeleportationOptions options to modify teleportation behavior.
  127309. */
  127310. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  127311. private _onNewGamepadConnected;
  127312. private _tryEnableInteractionOnController;
  127313. private _onNewGamepadDisconnected;
  127314. private _enableInteractionOnController;
  127315. private _checkTeleportWithRay;
  127316. private _checkRotate;
  127317. private _checkTeleportBackwards;
  127318. private _enableTeleportationOnController;
  127319. private _createTeleportationCircles;
  127320. private _displayTeleportationTarget;
  127321. private _hideTeleportationTarget;
  127322. private _rotateCamera;
  127323. private _moveTeleportationSelectorTo;
  127324. private _workingVector;
  127325. private _workingQuaternion;
  127326. private _workingMatrix;
  127327. /**
  127328. * Time Constant Teleportation Mode
  127329. */
  127330. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  127331. /**
  127332. * Speed Constant Teleportation Mode
  127333. */
  127334. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  127335. /**
  127336. * Teleports the users feet to the desired location
  127337. * @param location The location where the user's feet should be placed
  127338. */
  127339. teleportCamera(location: Vector3): void;
  127340. private _convertNormalToDirectionOfRay;
  127341. private _castRayAndSelectObject;
  127342. private _notifySelectedMeshUnselected;
  127343. /**
  127344. * Permanently set new colors for the laser pointer
  127345. * @param color the new laser color
  127346. * @param pickedColor the new laser color when picked mesh detected
  127347. */
  127348. setLaserColor(color: Color3, pickedColor?: Color3): void;
  127349. /**
  127350. * Set lighting enabled / disabled on the laser pointer of both controllers
  127351. * @param enabled should the lighting be enabled on the laser pointer
  127352. */
  127353. setLaserLightingState(enabled?: boolean): void;
  127354. /**
  127355. * Permanently set new colors for the gaze pointer
  127356. * @param color the new gaze color
  127357. * @param pickedColor the new gaze color when picked mesh detected
  127358. */
  127359. setGazeColor(color: Color3, pickedColor?: Color3): void;
  127360. /**
  127361. * Sets the color of the laser ray from the vr controllers.
  127362. * @param color new color for the ray.
  127363. */
  127364. changeLaserColor(color: Color3): void;
  127365. /**
  127366. * Sets the color of the ray from the vr headsets gaze.
  127367. * @param color new color for the ray.
  127368. */
  127369. changeGazeColor(color: Color3): void;
  127370. /**
  127371. * Exits VR and disposes of the vr experience helper
  127372. */
  127373. dispose(): void;
  127374. /**
  127375. * Gets the name of the VRExperienceHelper class
  127376. * @returns "VRExperienceHelper"
  127377. */
  127378. getClassName(): string;
  127379. }
  127380. }
  127381. declare module BABYLON {
  127382. /**
  127383. * Contains an array of blocks representing the octree
  127384. */
  127385. export interface IOctreeContainer<T> {
  127386. /**
  127387. * Blocks within the octree
  127388. */
  127389. blocks: Array<OctreeBlock<T>>;
  127390. }
  127391. /**
  127392. * Class used to store a cell in an octree
  127393. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127394. */
  127395. export class OctreeBlock<T> {
  127396. /**
  127397. * Gets the content of the current block
  127398. */
  127399. entries: T[];
  127400. /**
  127401. * Gets the list of block children
  127402. */
  127403. blocks: Array<OctreeBlock<T>>;
  127404. private _depth;
  127405. private _maxDepth;
  127406. private _capacity;
  127407. private _minPoint;
  127408. private _maxPoint;
  127409. private _boundingVectors;
  127410. private _creationFunc;
  127411. /**
  127412. * Creates a new block
  127413. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  127414. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  127415. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  127416. * @param depth defines the current depth of this block in the octree
  127417. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  127418. * @param creationFunc defines a callback to call when an element is added to the block
  127419. */
  127420. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  127421. /**
  127422. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  127423. */
  127424. get capacity(): number;
  127425. /**
  127426. * Gets the minimum vector (in world space) of the block's bounding box
  127427. */
  127428. get minPoint(): Vector3;
  127429. /**
  127430. * Gets the maximum vector (in world space) of the block's bounding box
  127431. */
  127432. get maxPoint(): Vector3;
  127433. /**
  127434. * Add a new element to this block
  127435. * @param entry defines the element to add
  127436. */
  127437. addEntry(entry: T): void;
  127438. /**
  127439. * Remove an element from this block
  127440. * @param entry defines the element to remove
  127441. */
  127442. removeEntry(entry: T): void;
  127443. /**
  127444. * Add an array of elements to this block
  127445. * @param entries defines the array of elements to add
  127446. */
  127447. addEntries(entries: T[]): void;
  127448. /**
  127449. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  127450. * @param frustumPlanes defines the frustum planes to test
  127451. * @param selection defines the array to store current content if selection is positive
  127452. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127453. */
  127454. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127455. /**
  127456. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  127457. * @param sphereCenter defines the bounding sphere center
  127458. * @param sphereRadius defines the bounding sphere radius
  127459. * @param selection defines the array to store current content if selection is positive
  127460. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127461. */
  127462. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127463. /**
  127464. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  127465. * @param ray defines the ray to test with
  127466. * @param selection defines the array to store current content if selection is positive
  127467. */
  127468. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  127469. /**
  127470. * Subdivide the content into child blocks (this block will then be empty)
  127471. */
  127472. createInnerBlocks(): void;
  127473. /**
  127474. * @hidden
  127475. */
  127476. 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;
  127477. }
  127478. }
  127479. declare module BABYLON {
  127480. /**
  127481. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  127482. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127483. */
  127484. export class Octree<T> {
  127485. /** 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.) */
  127486. maxDepth: number;
  127487. /**
  127488. * Blocks within the octree containing objects
  127489. */
  127490. blocks: Array<OctreeBlock<T>>;
  127491. /**
  127492. * Content stored in the octree
  127493. */
  127494. dynamicContent: T[];
  127495. private _maxBlockCapacity;
  127496. private _selectionContent;
  127497. private _creationFunc;
  127498. /**
  127499. * Creates a octree
  127500. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127501. * @param creationFunc function to be used to instatiate the octree
  127502. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  127503. * @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.)
  127504. */
  127505. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  127506. /** 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.) */
  127507. maxDepth?: number);
  127508. /**
  127509. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  127510. * @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);
  127511. * @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);
  127512. * @param entries meshes to be added to the octree blocks
  127513. */
  127514. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  127515. /**
  127516. * Adds a mesh to the octree
  127517. * @param entry Mesh to add to the octree
  127518. */
  127519. addMesh(entry: T): void;
  127520. /**
  127521. * Remove an element from the octree
  127522. * @param entry defines the element to remove
  127523. */
  127524. removeMesh(entry: T): void;
  127525. /**
  127526. * Selects an array of meshes within the frustum
  127527. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  127528. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  127529. * @returns array of meshes within the frustum
  127530. */
  127531. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  127532. /**
  127533. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  127534. * @param sphereCenter defines the bounding sphere center
  127535. * @param sphereRadius defines the bounding sphere radius
  127536. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127537. * @returns an array of objects that intersect the sphere
  127538. */
  127539. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  127540. /**
  127541. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  127542. * @param ray defines the ray to test with
  127543. * @returns array of intersected objects
  127544. */
  127545. intersectsRay(ray: Ray): SmartArray<T>;
  127546. /**
  127547. * Adds a mesh into the octree block if it intersects the block
  127548. */
  127549. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  127550. /**
  127551. * Adds a submesh into the octree block if it intersects the block
  127552. */
  127553. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  127554. }
  127555. }
  127556. declare module BABYLON {
  127557. interface Scene {
  127558. /**
  127559. * @hidden
  127560. * Backing Filed
  127561. */
  127562. _selectionOctree: Octree<AbstractMesh>;
  127563. /**
  127564. * Gets the octree used to boost mesh selection (picking)
  127565. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127566. */
  127567. selectionOctree: Octree<AbstractMesh>;
  127568. /**
  127569. * Creates or updates the octree used to boost selection (picking)
  127570. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127571. * @param maxCapacity defines the maximum capacity per leaf
  127572. * @param maxDepth defines the maximum depth of the octree
  127573. * @returns an octree of AbstractMesh
  127574. */
  127575. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  127576. }
  127577. interface AbstractMesh {
  127578. /**
  127579. * @hidden
  127580. * Backing Field
  127581. */
  127582. _submeshesOctree: Octree<SubMesh>;
  127583. /**
  127584. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  127585. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  127586. * @param maxCapacity defines the maximum size of each block (64 by default)
  127587. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  127588. * @returns the new octree
  127589. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  127590. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127591. */
  127592. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  127593. }
  127594. /**
  127595. * Defines the octree scene component responsible to manage any octrees
  127596. * in a given scene.
  127597. */
  127598. export class OctreeSceneComponent {
  127599. /**
  127600. * The component name help to identify the component in the list of scene components.
  127601. */
  127602. readonly name: string;
  127603. /**
  127604. * The scene the component belongs to.
  127605. */
  127606. scene: Scene;
  127607. /**
  127608. * Indicates if the meshes have been checked to make sure they are isEnabled()
  127609. */
  127610. readonly checksIsEnabled: boolean;
  127611. /**
  127612. * Creates a new instance of the component for the given scene
  127613. * @param scene Defines the scene to register the component in
  127614. */
  127615. constructor(scene: Scene);
  127616. /**
  127617. * Registers the component in a given scene
  127618. */
  127619. register(): void;
  127620. /**
  127621. * Return the list of active meshes
  127622. * @returns the list of active meshes
  127623. */
  127624. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  127625. /**
  127626. * Return the list of active sub meshes
  127627. * @param mesh The mesh to get the candidates sub meshes from
  127628. * @returns the list of active sub meshes
  127629. */
  127630. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  127631. private _tempRay;
  127632. /**
  127633. * Return the list of sub meshes intersecting with a given local ray
  127634. * @param mesh defines the mesh to find the submesh for
  127635. * @param localRay defines the ray in local space
  127636. * @returns the list of intersecting sub meshes
  127637. */
  127638. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  127639. /**
  127640. * Return the list of sub meshes colliding with a collider
  127641. * @param mesh defines the mesh to find the submesh for
  127642. * @param collider defines the collider to evaluate the collision against
  127643. * @returns the list of colliding sub meshes
  127644. */
  127645. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  127646. /**
  127647. * Rebuilds the elements related to this component in case of
  127648. * context lost for instance.
  127649. */
  127650. rebuild(): void;
  127651. /**
  127652. * Disposes the component and the associated ressources.
  127653. */
  127654. dispose(): void;
  127655. }
  127656. }
  127657. declare module BABYLON {
  127658. /**
  127659. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  127660. */
  127661. export class Gizmo implements IDisposable {
  127662. /** The utility layer the gizmo will be added to */
  127663. gizmoLayer: UtilityLayerRenderer;
  127664. /**
  127665. * The root mesh of the gizmo
  127666. */
  127667. _rootMesh: Mesh;
  127668. private _attachedMesh;
  127669. /**
  127670. * Ratio for the scale of the gizmo (Default: 1)
  127671. */
  127672. scaleRatio: number;
  127673. /**
  127674. * If a custom mesh has been set (Default: false)
  127675. */
  127676. protected _customMeshSet: boolean;
  127677. /**
  127678. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  127679. * * When set, interactions will be enabled
  127680. */
  127681. get attachedMesh(): Nullable<AbstractMesh>;
  127682. set attachedMesh(value: Nullable<AbstractMesh>);
  127683. /**
  127684. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  127685. * @param mesh The mesh to replace the default mesh of the gizmo
  127686. */
  127687. setCustomMesh(mesh: Mesh): void;
  127688. /**
  127689. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  127690. */
  127691. updateGizmoRotationToMatchAttachedMesh: boolean;
  127692. /**
  127693. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  127694. */
  127695. updateGizmoPositionToMatchAttachedMesh: boolean;
  127696. /**
  127697. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  127698. */
  127699. updateScale: boolean;
  127700. protected _interactionsEnabled: boolean;
  127701. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127702. private _beforeRenderObserver;
  127703. private _tempVector;
  127704. /**
  127705. * Creates a gizmo
  127706. * @param gizmoLayer The utility layer the gizmo will be added to
  127707. */
  127708. constructor(
  127709. /** The utility layer the gizmo will be added to */
  127710. gizmoLayer?: UtilityLayerRenderer);
  127711. /**
  127712. * Updates the gizmo to match the attached mesh's position/rotation
  127713. */
  127714. protected _update(): void;
  127715. /**
  127716. * Disposes of the gizmo
  127717. */
  127718. dispose(): void;
  127719. }
  127720. }
  127721. declare module BABYLON {
  127722. /**
  127723. * Single plane drag gizmo
  127724. */
  127725. export class PlaneDragGizmo extends Gizmo {
  127726. /**
  127727. * Drag behavior responsible for the gizmos dragging interactions
  127728. */
  127729. dragBehavior: PointerDragBehavior;
  127730. private _pointerObserver;
  127731. /**
  127732. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127733. */
  127734. snapDistance: number;
  127735. /**
  127736. * Event that fires each time the gizmo snaps to a new location.
  127737. * * snapDistance is the the change in distance
  127738. */
  127739. onSnapObservable: Observable<{
  127740. snapDistance: number;
  127741. }>;
  127742. private _plane;
  127743. private _coloredMaterial;
  127744. private _hoverMaterial;
  127745. private _isEnabled;
  127746. private _parent;
  127747. /** @hidden */
  127748. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  127749. /** @hidden */
  127750. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127751. /**
  127752. * Creates a PlaneDragGizmo
  127753. * @param gizmoLayer The utility layer the gizmo will be added to
  127754. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  127755. * @param color The color of the gizmo
  127756. */
  127757. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127758. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127759. /**
  127760. * If the gizmo is enabled
  127761. */
  127762. set isEnabled(value: boolean);
  127763. get isEnabled(): boolean;
  127764. /**
  127765. * Disposes of the gizmo
  127766. */
  127767. dispose(): void;
  127768. }
  127769. }
  127770. declare module BABYLON {
  127771. /**
  127772. * Gizmo that enables dragging a mesh along 3 axis
  127773. */
  127774. export class PositionGizmo extends Gizmo {
  127775. /**
  127776. * Internal gizmo used for interactions on the x axis
  127777. */
  127778. xGizmo: AxisDragGizmo;
  127779. /**
  127780. * Internal gizmo used for interactions on the y axis
  127781. */
  127782. yGizmo: AxisDragGizmo;
  127783. /**
  127784. * Internal gizmo used for interactions on the z axis
  127785. */
  127786. zGizmo: AxisDragGizmo;
  127787. /**
  127788. * Internal gizmo used for interactions on the yz plane
  127789. */
  127790. xPlaneGizmo: PlaneDragGizmo;
  127791. /**
  127792. * Internal gizmo used for interactions on the xz plane
  127793. */
  127794. yPlaneGizmo: PlaneDragGizmo;
  127795. /**
  127796. * Internal gizmo used for interactions on the xy plane
  127797. */
  127798. zPlaneGizmo: PlaneDragGizmo;
  127799. /**
  127800. * private variables
  127801. */
  127802. private _meshAttached;
  127803. private _updateGizmoRotationToMatchAttachedMesh;
  127804. private _snapDistance;
  127805. private _scaleRatio;
  127806. /** Fires an event when any of it's sub gizmos are dragged */
  127807. onDragStartObservable: Observable<unknown>;
  127808. /** Fires an event when any of it's sub gizmos are released from dragging */
  127809. onDragEndObservable: Observable<unknown>;
  127810. /**
  127811. * If set to true, planar drag is enabled
  127812. */
  127813. private _planarGizmoEnabled;
  127814. get attachedMesh(): Nullable<AbstractMesh>;
  127815. set attachedMesh(mesh: Nullable<AbstractMesh>);
  127816. /**
  127817. * Creates a PositionGizmo
  127818. * @param gizmoLayer The utility layer the gizmo will be added to
  127819. */
  127820. constructor(gizmoLayer?: UtilityLayerRenderer);
  127821. /**
  127822. * If the planar drag gizmo is enabled
  127823. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  127824. */
  127825. set planarGizmoEnabled(value: boolean);
  127826. get planarGizmoEnabled(): boolean;
  127827. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  127828. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  127829. /**
  127830. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127831. */
  127832. set snapDistance(value: number);
  127833. get snapDistance(): number;
  127834. /**
  127835. * Ratio for the scale of the gizmo (Default: 1)
  127836. */
  127837. set scaleRatio(value: number);
  127838. get scaleRatio(): number;
  127839. /**
  127840. * Disposes of the gizmo
  127841. */
  127842. dispose(): void;
  127843. /**
  127844. * CustomMeshes are not supported by this gizmo
  127845. * @param mesh The mesh to replace the default mesh of the gizmo
  127846. */
  127847. setCustomMesh(mesh: Mesh): void;
  127848. }
  127849. }
  127850. declare module BABYLON {
  127851. /**
  127852. * Single axis drag gizmo
  127853. */
  127854. export class AxisDragGizmo extends Gizmo {
  127855. /**
  127856. * Drag behavior responsible for the gizmos dragging interactions
  127857. */
  127858. dragBehavior: PointerDragBehavior;
  127859. private _pointerObserver;
  127860. /**
  127861. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127862. */
  127863. snapDistance: number;
  127864. /**
  127865. * Event that fires each time the gizmo snaps to a new location.
  127866. * * snapDistance is the the change in distance
  127867. */
  127868. onSnapObservable: Observable<{
  127869. snapDistance: number;
  127870. }>;
  127871. private _isEnabled;
  127872. private _parent;
  127873. private _arrow;
  127874. private _coloredMaterial;
  127875. private _hoverMaterial;
  127876. /** @hidden */
  127877. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  127878. /** @hidden */
  127879. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127880. /**
  127881. * Creates an AxisDragGizmo
  127882. * @param gizmoLayer The utility layer the gizmo will be added to
  127883. * @param dragAxis The axis which the gizmo will be able to drag on
  127884. * @param color The color of the gizmo
  127885. */
  127886. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127887. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127888. /**
  127889. * If the gizmo is enabled
  127890. */
  127891. set isEnabled(value: boolean);
  127892. get isEnabled(): boolean;
  127893. /**
  127894. * Disposes of the gizmo
  127895. */
  127896. dispose(): void;
  127897. }
  127898. }
  127899. declare module BABYLON.Debug {
  127900. /**
  127901. * The Axes viewer will show 3 axes in a specific point in space
  127902. */
  127903. export class AxesViewer {
  127904. private _xAxis;
  127905. private _yAxis;
  127906. private _zAxis;
  127907. private _scaleLinesFactor;
  127908. private _instanced;
  127909. /**
  127910. * Gets the hosting scene
  127911. */
  127912. scene: Scene;
  127913. /**
  127914. * Gets or sets a number used to scale line length
  127915. */
  127916. scaleLines: number;
  127917. /** Gets the node hierarchy used to render x-axis */
  127918. get xAxis(): TransformNode;
  127919. /** Gets the node hierarchy used to render y-axis */
  127920. get yAxis(): TransformNode;
  127921. /** Gets the node hierarchy used to render z-axis */
  127922. get zAxis(): TransformNode;
  127923. /**
  127924. * Creates a new AxesViewer
  127925. * @param scene defines the hosting scene
  127926. * @param scaleLines defines a number used to scale line length (1 by default)
  127927. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  127928. * @param xAxis defines the node hierarchy used to render the x-axis
  127929. * @param yAxis defines the node hierarchy used to render the y-axis
  127930. * @param zAxis defines the node hierarchy used to render the z-axis
  127931. */
  127932. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  127933. /**
  127934. * Force the viewer to update
  127935. * @param position defines the position of the viewer
  127936. * @param xaxis defines the x axis of the viewer
  127937. * @param yaxis defines the y axis of the viewer
  127938. * @param zaxis defines the z axis of the viewer
  127939. */
  127940. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  127941. /**
  127942. * Creates an instance of this axes viewer.
  127943. * @returns a new axes viewer with instanced meshes
  127944. */
  127945. createInstance(): AxesViewer;
  127946. /** Releases resources */
  127947. dispose(): void;
  127948. private static _SetRenderingGroupId;
  127949. }
  127950. }
  127951. declare module BABYLON.Debug {
  127952. /**
  127953. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  127954. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  127955. */
  127956. export class BoneAxesViewer extends AxesViewer {
  127957. /**
  127958. * Gets or sets the target mesh where to display the axes viewer
  127959. */
  127960. mesh: Nullable<Mesh>;
  127961. /**
  127962. * Gets or sets the target bone where to display the axes viewer
  127963. */
  127964. bone: Nullable<Bone>;
  127965. /** Gets current position */
  127966. pos: Vector3;
  127967. /** Gets direction of X axis */
  127968. xaxis: Vector3;
  127969. /** Gets direction of Y axis */
  127970. yaxis: Vector3;
  127971. /** Gets direction of Z axis */
  127972. zaxis: Vector3;
  127973. /**
  127974. * Creates a new BoneAxesViewer
  127975. * @param scene defines the hosting scene
  127976. * @param bone defines the target bone
  127977. * @param mesh defines the target mesh
  127978. * @param scaleLines defines a scaling factor for line length (1 by default)
  127979. */
  127980. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  127981. /**
  127982. * Force the viewer to update
  127983. */
  127984. update(): void;
  127985. /** Releases resources */
  127986. dispose(): void;
  127987. }
  127988. }
  127989. declare module BABYLON {
  127990. /**
  127991. * Interface used to define scene explorer extensibility option
  127992. */
  127993. export interface IExplorerExtensibilityOption {
  127994. /**
  127995. * Define the option label
  127996. */
  127997. label: string;
  127998. /**
  127999. * Defines the action to execute on click
  128000. */
  128001. action: (entity: any) => void;
  128002. }
  128003. /**
  128004. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  128005. */
  128006. export interface IExplorerExtensibilityGroup {
  128007. /**
  128008. * Defines a predicate to test if a given type mut be extended
  128009. */
  128010. predicate: (entity: any) => boolean;
  128011. /**
  128012. * Gets the list of options added to a type
  128013. */
  128014. entries: IExplorerExtensibilityOption[];
  128015. }
  128016. /**
  128017. * Interface used to define the options to use to create the Inspector
  128018. */
  128019. export interface IInspectorOptions {
  128020. /**
  128021. * Display in overlay mode (default: false)
  128022. */
  128023. overlay?: boolean;
  128024. /**
  128025. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  128026. */
  128027. globalRoot?: HTMLElement;
  128028. /**
  128029. * Display the Scene explorer
  128030. */
  128031. showExplorer?: boolean;
  128032. /**
  128033. * Display the property inspector
  128034. */
  128035. showInspector?: boolean;
  128036. /**
  128037. * Display in embed mode (both panes on the right)
  128038. */
  128039. embedMode?: boolean;
  128040. /**
  128041. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  128042. */
  128043. handleResize?: boolean;
  128044. /**
  128045. * Allow the panes to popup (default: true)
  128046. */
  128047. enablePopup?: boolean;
  128048. /**
  128049. * Allow the panes to be closed by users (default: true)
  128050. */
  128051. enableClose?: boolean;
  128052. /**
  128053. * Optional list of extensibility entries
  128054. */
  128055. explorerExtensibility?: IExplorerExtensibilityGroup[];
  128056. /**
  128057. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  128058. */
  128059. inspectorURL?: string;
  128060. /**
  128061. * Optional initial tab (default to DebugLayerTab.Properties)
  128062. */
  128063. initialTab?: DebugLayerTab;
  128064. }
  128065. interface Scene {
  128066. /**
  128067. * @hidden
  128068. * Backing field
  128069. */
  128070. _debugLayer: DebugLayer;
  128071. /**
  128072. * Gets the debug layer (aka Inspector) associated with the scene
  128073. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128074. */
  128075. debugLayer: DebugLayer;
  128076. }
  128077. /**
  128078. * Enum of inspector action tab
  128079. */
  128080. export enum DebugLayerTab {
  128081. /**
  128082. * Properties tag (default)
  128083. */
  128084. Properties = 0,
  128085. /**
  128086. * Debug tab
  128087. */
  128088. Debug = 1,
  128089. /**
  128090. * Statistics tab
  128091. */
  128092. Statistics = 2,
  128093. /**
  128094. * Tools tab
  128095. */
  128096. Tools = 3,
  128097. /**
  128098. * Settings tab
  128099. */
  128100. Settings = 4
  128101. }
  128102. /**
  128103. * The debug layer (aka Inspector) is the go to tool in order to better understand
  128104. * what is happening in your scene
  128105. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128106. */
  128107. export class DebugLayer {
  128108. /**
  128109. * Define the url to get the inspector script from.
  128110. * By default it uses the babylonjs CDN.
  128111. * @ignoreNaming
  128112. */
  128113. static InspectorURL: string;
  128114. private _scene;
  128115. private BJSINSPECTOR;
  128116. private _onPropertyChangedObservable?;
  128117. /**
  128118. * Observable triggered when a property is changed through the inspector.
  128119. */
  128120. get onPropertyChangedObservable(): any;
  128121. /**
  128122. * Instantiates a new debug layer.
  128123. * The debug layer (aka Inspector) is the go to tool in order to better understand
  128124. * what is happening in your scene
  128125. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128126. * @param scene Defines the scene to inspect
  128127. */
  128128. constructor(scene: Scene);
  128129. /** Creates the inspector window. */
  128130. private _createInspector;
  128131. /**
  128132. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  128133. * @param entity defines the entity to select
  128134. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  128135. */
  128136. select(entity: any, lineContainerTitles?: string | string[]): void;
  128137. /** Get the inspector from bundle or global */
  128138. private _getGlobalInspector;
  128139. /**
  128140. * Get if the inspector is visible or not.
  128141. * @returns true if visible otherwise, false
  128142. */
  128143. isVisible(): boolean;
  128144. /**
  128145. * Hide the inspector and close its window.
  128146. */
  128147. hide(): void;
  128148. /**
  128149. * Update the scene in the inspector
  128150. */
  128151. setAsActiveScene(): void;
  128152. /**
  128153. * Launch the debugLayer.
  128154. * @param config Define the configuration of the inspector
  128155. * @return a promise fulfilled when the debug layer is visible
  128156. */
  128157. show(config?: IInspectorOptions): Promise<DebugLayer>;
  128158. }
  128159. }
  128160. declare module BABYLON {
  128161. /**
  128162. * Class containing static functions to help procedurally build meshes
  128163. */
  128164. export class BoxBuilder {
  128165. /**
  128166. * Creates a box mesh
  128167. * * The parameter `size` sets the size (float) of each box side (default 1)
  128168. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  128169. * * 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)
  128170. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  128171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128172. * * 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
  128173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128174. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  128175. * @param name defines the name of the mesh
  128176. * @param options defines the options used to create the mesh
  128177. * @param scene defines the hosting scene
  128178. * @returns the box mesh
  128179. */
  128180. static CreateBox(name: string, options: {
  128181. size?: number;
  128182. width?: number;
  128183. height?: number;
  128184. depth?: number;
  128185. faceUV?: Vector4[];
  128186. faceColors?: Color4[];
  128187. sideOrientation?: number;
  128188. frontUVs?: Vector4;
  128189. backUVs?: Vector4;
  128190. wrap?: boolean;
  128191. topBaseAt?: number;
  128192. bottomBaseAt?: number;
  128193. updatable?: boolean;
  128194. }, scene?: Nullable<Scene>): Mesh;
  128195. }
  128196. }
  128197. declare module BABYLON.Debug {
  128198. /**
  128199. * Used to show the physics impostor around the specific mesh
  128200. */
  128201. export class PhysicsViewer {
  128202. /** @hidden */
  128203. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  128204. /** @hidden */
  128205. protected _meshes: Array<Nullable<AbstractMesh>>;
  128206. /** @hidden */
  128207. protected _scene: Nullable<Scene>;
  128208. /** @hidden */
  128209. protected _numMeshes: number;
  128210. /** @hidden */
  128211. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  128212. private _renderFunction;
  128213. private _utilityLayer;
  128214. private _debugBoxMesh;
  128215. private _debugSphereMesh;
  128216. private _debugCylinderMesh;
  128217. private _debugMaterial;
  128218. private _debugMeshMeshes;
  128219. /**
  128220. * Creates a new PhysicsViewer
  128221. * @param scene defines the hosting scene
  128222. */
  128223. constructor(scene: Scene);
  128224. /** @hidden */
  128225. protected _updateDebugMeshes(): void;
  128226. /**
  128227. * Renders a specified physic impostor
  128228. * @param impostor defines the impostor to render
  128229. * @param targetMesh defines the mesh represented by the impostor
  128230. * @returns the new debug mesh used to render the impostor
  128231. */
  128232. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  128233. /**
  128234. * Hides a specified physic impostor
  128235. * @param impostor defines the impostor to hide
  128236. */
  128237. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  128238. private _getDebugMaterial;
  128239. private _getDebugBoxMesh;
  128240. private _getDebugSphereMesh;
  128241. private _getDebugCylinderMesh;
  128242. private _getDebugMeshMesh;
  128243. private _getDebugMesh;
  128244. /** Releases all resources */
  128245. dispose(): void;
  128246. }
  128247. }
  128248. declare module BABYLON {
  128249. /**
  128250. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  128251. * in order to better appreciate the issue one might have.
  128252. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  128253. */
  128254. export class RayHelper {
  128255. /**
  128256. * Defines the ray we are currently tryin to visualize.
  128257. */
  128258. ray: Nullable<Ray>;
  128259. private _renderPoints;
  128260. private _renderLine;
  128261. private _renderFunction;
  128262. private _scene;
  128263. private _updateToMeshFunction;
  128264. private _attachedToMesh;
  128265. private _meshSpaceDirection;
  128266. private _meshSpaceOrigin;
  128267. /**
  128268. * Helper function to create a colored helper in a scene in one line.
  128269. * @param ray Defines the ray we are currently tryin to visualize
  128270. * @param scene Defines the scene the ray is used in
  128271. * @param color Defines the color we want to see the ray in
  128272. * @returns The newly created ray helper.
  128273. */
  128274. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  128275. /**
  128276. * Instantiate a new ray helper.
  128277. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  128278. * in order to better appreciate the issue one might have.
  128279. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  128280. * @param ray Defines the ray we are currently tryin to visualize
  128281. */
  128282. constructor(ray: Ray);
  128283. /**
  128284. * Shows the ray we are willing to debug.
  128285. * @param scene Defines the scene the ray needs to be rendered in
  128286. * @param color Defines the color the ray needs to be rendered in
  128287. */
  128288. show(scene: Scene, color?: Color3): void;
  128289. /**
  128290. * Hides the ray we are debugging.
  128291. */
  128292. hide(): void;
  128293. private _render;
  128294. /**
  128295. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  128296. * @param mesh Defines the mesh we want the helper attached to
  128297. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  128298. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  128299. * @param length Defines the length of the ray
  128300. */
  128301. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  128302. /**
  128303. * Detach the ray helper from the mesh it has previously been attached to.
  128304. */
  128305. detachFromMesh(): void;
  128306. private _updateToMesh;
  128307. /**
  128308. * Dispose the helper and release its associated resources.
  128309. */
  128310. dispose(): void;
  128311. }
  128312. }
  128313. declare module BABYLON.Debug {
  128314. /**
  128315. * Class used to render a debug view of a given skeleton
  128316. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  128317. */
  128318. export class SkeletonViewer {
  128319. /** defines the skeleton to render */
  128320. skeleton: Skeleton;
  128321. /** defines the mesh attached to the skeleton */
  128322. mesh: AbstractMesh;
  128323. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  128324. autoUpdateBonesMatrices: boolean;
  128325. /** defines the rendering group id to use with the viewer */
  128326. renderingGroupId: number;
  128327. /** Gets or sets the color used to render the skeleton */
  128328. color: Color3;
  128329. private _scene;
  128330. private _debugLines;
  128331. private _debugMesh;
  128332. private _isEnabled;
  128333. private _renderFunction;
  128334. private _utilityLayer;
  128335. /**
  128336. * Returns the mesh used to render the bones
  128337. */
  128338. get debugMesh(): Nullable<LinesMesh>;
  128339. /**
  128340. * Creates a new SkeletonViewer
  128341. * @param skeleton defines the skeleton to render
  128342. * @param mesh defines the mesh attached to the skeleton
  128343. * @param scene defines the hosting scene
  128344. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  128345. * @param renderingGroupId defines the rendering group id to use with the viewer
  128346. */
  128347. constructor(
  128348. /** defines the skeleton to render */
  128349. skeleton: Skeleton,
  128350. /** defines the mesh attached to the skeleton */
  128351. mesh: AbstractMesh, scene: Scene,
  128352. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  128353. autoUpdateBonesMatrices?: boolean,
  128354. /** defines the rendering group id to use with the viewer */
  128355. renderingGroupId?: number);
  128356. /** Gets or sets a boolean indicating if the viewer is enabled */
  128357. set isEnabled(value: boolean);
  128358. get isEnabled(): boolean;
  128359. private _getBonePosition;
  128360. private _getLinesForBonesWithLength;
  128361. private _getLinesForBonesNoLength;
  128362. /** Update the viewer to sync with current skeleton state */
  128363. update(): void;
  128364. /** Release associated resources */
  128365. dispose(): void;
  128366. }
  128367. }
  128368. declare module BABYLON {
  128369. /**
  128370. * Enum for Device Types
  128371. */
  128372. export enum DeviceType {
  128373. /** Generic */
  128374. Generic = 0,
  128375. /** Keyboard */
  128376. Keyboard = 1,
  128377. /** Mouse */
  128378. Mouse = 2,
  128379. /** Touch Pointers */
  128380. Touch = 3,
  128381. /** PS4 Dual Shock */
  128382. DualShock = 4,
  128383. /** Xbox */
  128384. Xbox = 5,
  128385. /** Switch Controller */
  128386. Switch = 6
  128387. }
  128388. /**
  128389. * Enum for All Pointers (Touch/Mouse)
  128390. */
  128391. export enum PointerInput {
  128392. /** Horizontal Axis */
  128393. Horizontal = 0,
  128394. /** Vertical Axis */
  128395. Vertical = 1,
  128396. /** Left Click or Touch */
  128397. LeftClick = 2,
  128398. /** Middle Click */
  128399. MiddleClick = 3,
  128400. /** Right Click */
  128401. RightClick = 4,
  128402. /** Browser Back */
  128403. BrowserBack = 5,
  128404. /** Browser Forward */
  128405. BrowserForward = 6
  128406. }
  128407. /**
  128408. * Enum for Dual Shock Gamepad
  128409. */
  128410. export enum DualShockInput {
  128411. /** Cross */
  128412. Cross = 0,
  128413. /** Circle */
  128414. Circle = 1,
  128415. /** Square */
  128416. Square = 2,
  128417. /** Triangle */
  128418. Triangle = 3,
  128419. /** L1 */
  128420. L1 = 4,
  128421. /** R1 */
  128422. R1 = 5,
  128423. /** L2 */
  128424. L2 = 6,
  128425. /** R2 */
  128426. R2 = 7,
  128427. /** Share */
  128428. Share = 8,
  128429. /** Options */
  128430. Options = 9,
  128431. /** L3 */
  128432. L3 = 10,
  128433. /** R3 */
  128434. R3 = 11,
  128435. /** DPadUp */
  128436. DPadUp = 12,
  128437. /** DPadDown */
  128438. DPadDown = 13,
  128439. /** DPadLeft */
  128440. DPadLeft = 14,
  128441. /** DRight */
  128442. DPadRight = 15,
  128443. /** Home */
  128444. Home = 16,
  128445. /** TouchPad */
  128446. TouchPad = 17,
  128447. /** LStickXAxis */
  128448. LStickXAxis = 18,
  128449. /** LStickYAxis */
  128450. LStickYAxis = 19,
  128451. /** RStickXAxis */
  128452. RStickXAxis = 20,
  128453. /** RStickYAxis */
  128454. RStickYAxis = 21
  128455. }
  128456. /**
  128457. * Enum for Xbox Gamepad
  128458. */
  128459. export enum XboxInput {
  128460. /** A */
  128461. A = 0,
  128462. /** B */
  128463. B = 1,
  128464. /** X */
  128465. X = 2,
  128466. /** Y */
  128467. Y = 3,
  128468. /** LB */
  128469. LB = 4,
  128470. /** RB */
  128471. RB = 5,
  128472. /** LT */
  128473. LT = 6,
  128474. /** RT */
  128475. RT = 7,
  128476. /** Back */
  128477. Back = 8,
  128478. /** Start */
  128479. Start = 9,
  128480. /** LS */
  128481. LS = 10,
  128482. /** RS */
  128483. RS = 11,
  128484. /** DPadUp */
  128485. DPadUp = 12,
  128486. /** DPadDown */
  128487. DPadDown = 13,
  128488. /** DPadLeft */
  128489. DPadLeft = 14,
  128490. /** DRight */
  128491. DPadRight = 15,
  128492. /** Home */
  128493. Home = 16,
  128494. /** LStickXAxis */
  128495. LStickXAxis = 17,
  128496. /** LStickYAxis */
  128497. LStickYAxis = 18,
  128498. /** RStickXAxis */
  128499. RStickXAxis = 19,
  128500. /** RStickYAxis */
  128501. RStickYAxis = 20
  128502. }
  128503. /**
  128504. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  128505. */
  128506. export enum SwitchInput {
  128507. /** B */
  128508. B = 0,
  128509. /** A */
  128510. A = 1,
  128511. /** Y */
  128512. Y = 2,
  128513. /** X */
  128514. X = 3,
  128515. /** L */
  128516. L = 4,
  128517. /** R */
  128518. R = 5,
  128519. /** ZL */
  128520. ZL = 6,
  128521. /** ZR */
  128522. ZR = 7,
  128523. /** Minus */
  128524. Minus = 8,
  128525. /** Plus */
  128526. Plus = 9,
  128527. /** LS */
  128528. LS = 10,
  128529. /** RS */
  128530. RS = 11,
  128531. /** DPadUp */
  128532. DPadUp = 12,
  128533. /** DPadDown */
  128534. DPadDown = 13,
  128535. /** DPadLeft */
  128536. DPadLeft = 14,
  128537. /** DRight */
  128538. DPadRight = 15,
  128539. /** Home */
  128540. Home = 16,
  128541. /** Capture */
  128542. Capture = 17,
  128543. /** LStickXAxis */
  128544. LStickXAxis = 18,
  128545. /** LStickYAxis */
  128546. LStickYAxis = 19,
  128547. /** RStickXAxis */
  128548. RStickXAxis = 20,
  128549. /** RStickYAxis */
  128550. RStickYAxis = 21
  128551. }
  128552. }
  128553. declare module BABYLON {
  128554. /**
  128555. * This class will take all inputs from Keyboard, Pointer, and
  128556. * any Gamepads and provide a polling system that all devices
  128557. * will use. This class assumes that there will only be one
  128558. * pointer device and one keyboard.
  128559. */
  128560. export class DeviceInputSystem implements IDisposable {
  128561. /**
  128562. * Callback to be triggered when a device is connected
  128563. */
  128564. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128565. /**
  128566. * Callback to be triggered when a device is disconnected
  128567. */
  128568. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128569. /**
  128570. * Callback to be triggered when event driven input is updated
  128571. */
  128572. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  128573. private _inputs;
  128574. private _gamepads;
  128575. private _keyboardActive;
  128576. private _pointerActive;
  128577. private _elementToAttachTo;
  128578. private _keyboardDownEvent;
  128579. private _keyboardUpEvent;
  128580. private _pointerMoveEvent;
  128581. private _pointerDownEvent;
  128582. private _pointerUpEvent;
  128583. private _gamepadConnectedEvent;
  128584. private _gamepadDisconnectedEvent;
  128585. private static _MAX_KEYCODES;
  128586. private static _MAX_POINTER_INPUTS;
  128587. private constructor();
  128588. /**
  128589. * Creates a new DeviceInputSystem instance
  128590. * @param engine Engine to pull input element from
  128591. * @returns The new instance
  128592. */
  128593. static Create(engine: Engine): DeviceInputSystem;
  128594. /**
  128595. * Checks for current device input value, given an id and input index
  128596. * @param deviceName Id of connected device
  128597. * @param inputIndex Index of device input
  128598. * @returns Current value of input
  128599. */
  128600. /**
  128601. * Checks for current device input value, given an id and input index
  128602. * @param deviceType Enum specifiying device type
  128603. * @param deviceSlot "Slot" or index that device is referenced in
  128604. * @param inputIndex Id of input to be checked
  128605. * @returns Current value of input
  128606. */
  128607. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  128608. /**
  128609. * Dispose of all the eventlisteners
  128610. */
  128611. dispose(): void;
  128612. /**
  128613. * Add device and inputs to device array
  128614. * @param deviceType Enum specifiying device type
  128615. * @param deviceSlot "Slot" or index that device is referenced in
  128616. * @param numberOfInputs Number of input entries to create for given device
  128617. */
  128618. private _registerDevice;
  128619. /**
  128620. * Given a specific device name, remove that device from the device map
  128621. * @param deviceType Enum specifiying device type
  128622. * @param deviceSlot "Slot" or index that device is referenced in
  128623. */
  128624. private _unregisterDevice;
  128625. /**
  128626. * Handle all actions that come from keyboard interaction
  128627. */
  128628. private _handleKeyActions;
  128629. /**
  128630. * Handle all actions that come from pointer interaction
  128631. */
  128632. private _handlePointerActions;
  128633. /**
  128634. * Handle all actions that come from gamepad interaction
  128635. */
  128636. private _handleGamepadActions;
  128637. /**
  128638. * Update all non-event based devices with each frame
  128639. * @param deviceType Enum specifiying device type
  128640. * @param deviceSlot "Slot" or index that device is referenced in
  128641. * @param inputIndex Id of input to be checked
  128642. */
  128643. private _updateDevice;
  128644. /**
  128645. * Gets DeviceType from the device name
  128646. * @param deviceName Name of Device from DeviceInputSystem
  128647. * @returns DeviceType enum value
  128648. */
  128649. private _getGamepadDeviceType;
  128650. }
  128651. }
  128652. declare module BABYLON {
  128653. /**
  128654. * Type to handle enforcement of inputs
  128655. */
  128656. 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;
  128657. }
  128658. declare module BABYLON {
  128659. /**
  128660. * Class that handles all input for a specific device
  128661. */
  128662. export class DeviceSource<T extends DeviceType> {
  128663. /** Type of device */
  128664. readonly deviceType: DeviceType;
  128665. /** "Slot" or index that device is referenced in */
  128666. readonly deviceSlot: number;
  128667. /**
  128668. * Observable to handle device input changes per device
  128669. */
  128670. readonly onInputChangedObservable: Observable<{
  128671. inputIndex: DeviceInput<T>;
  128672. previousState: Nullable<number>;
  128673. currentState: Nullable<number>;
  128674. }>;
  128675. private readonly _deviceInputSystem;
  128676. /**
  128677. * Default Constructor
  128678. * @param deviceInputSystem Reference to DeviceInputSystem
  128679. * @param deviceType Type of device
  128680. * @param deviceSlot "Slot" or index that device is referenced in
  128681. */
  128682. constructor(deviceInputSystem: DeviceInputSystem,
  128683. /** Type of device */
  128684. deviceType: DeviceType,
  128685. /** "Slot" or index that device is referenced in */
  128686. deviceSlot?: number);
  128687. /**
  128688. * Get input for specific input
  128689. * @param inputIndex index of specific input on device
  128690. * @returns Input value from DeviceInputSystem
  128691. */
  128692. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  128693. }
  128694. /**
  128695. * Class to keep track of devices
  128696. */
  128697. export class DeviceSourceManager implements IDisposable {
  128698. /**
  128699. * Observable to be triggered when before a device is connected
  128700. */
  128701. readonly onBeforeDeviceConnectedObservable: Observable<{
  128702. deviceType: DeviceType;
  128703. deviceSlot: number;
  128704. }>;
  128705. /**
  128706. * Observable to be triggered when before a device is disconnected
  128707. */
  128708. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  128709. deviceType: DeviceType;
  128710. deviceSlot: number;
  128711. }>;
  128712. /**
  128713. * Observable to be triggered when after a device is connected
  128714. */
  128715. readonly onAfterDeviceConnectedObservable: Observable<{
  128716. deviceType: DeviceType;
  128717. deviceSlot: number;
  128718. }>;
  128719. /**
  128720. * Observable to be triggered when after a device is disconnected
  128721. */
  128722. readonly onAfterDeviceDisconnectedObservable: Observable<{
  128723. deviceType: DeviceType;
  128724. deviceSlot: number;
  128725. }>;
  128726. private readonly _devices;
  128727. private readonly _firstDevice;
  128728. private readonly _deviceInputSystem;
  128729. /**
  128730. * Default Constructor
  128731. * @param engine engine to pull input element from
  128732. */
  128733. constructor(engine: Engine);
  128734. /**
  128735. * Gets a DeviceSource, given a type and slot
  128736. * @param deviceType Enum specifying device type
  128737. * @param deviceSlot "Slot" or index that device is referenced in
  128738. * @returns DeviceSource object
  128739. */
  128740. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  128741. /**
  128742. * Gets an array of DeviceSource objects for a given device type
  128743. * @param deviceType Enum specifying device type
  128744. * @returns Array of DeviceSource objects
  128745. */
  128746. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  128747. /**
  128748. * Dispose of DeviceInputSystem and other parts
  128749. */
  128750. dispose(): void;
  128751. /**
  128752. * Function to add device name to device list
  128753. * @param deviceType Enum specifying device type
  128754. * @param deviceSlot "Slot" or index that device is referenced in
  128755. */
  128756. private _addDevice;
  128757. /**
  128758. * Function to remove device name to device list
  128759. * @param deviceType Enum specifying device type
  128760. * @param deviceSlot "Slot" or index that device is referenced in
  128761. */
  128762. private _removeDevice;
  128763. /**
  128764. * Updates array storing first connected device of each type
  128765. * @param type Type of Device
  128766. */
  128767. private _updateFirstDevices;
  128768. }
  128769. }
  128770. declare module BABYLON {
  128771. /**
  128772. * Options to create the null engine
  128773. */
  128774. export class NullEngineOptions {
  128775. /**
  128776. * Render width (Default: 512)
  128777. */
  128778. renderWidth: number;
  128779. /**
  128780. * Render height (Default: 256)
  128781. */
  128782. renderHeight: number;
  128783. /**
  128784. * Texture size (Default: 512)
  128785. */
  128786. textureSize: number;
  128787. /**
  128788. * If delta time between frames should be constant
  128789. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128790. */
  128791. deterministicLockstep: boolean;
  128792. /**
  128793. * Maximum about of steps between frames (Default: 4)
  128794. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128795. */
  128796. lockstepMaxSteps: number;
  128797. }
  128798. /**
  128799. * The null engine class provides support for headless version of babylon.js.
  128800. * This can be used in server side scenario or for testing purposes
  128801. */
  128802. export class NullEngine extends Engine {
  128803. private _options;
  128804. /**
  128805. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  128806. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128807. * @returns true if engine is in deterministic lock step mode
  128808. */
  128809. isDeterministicLockStep(): boolean;
  128810. /**
  128811. * Gets the max steps when engine is running in deterministic lock step
  128812. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128813. * @returns the max steps
  128814. */
  128815. getLockstepMaxSteps(): number;
  128816. /**
  128817. * Gets the current hardware scaling level.
  128818. * By default the hardware scaling level is computed from the window device ratio.
  128819. * 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.
  128820. * @returns a number indicating the current hardware scaling level
  128821. */
  128822. getHardwareScalingLevel(): number;
  128823. constructor(options?: NullEngineOptions);
  128824. /**
  128825. * Creates a vertex buffer
  128826. * @param vertices the data for the vertex buffer
  128827. * @returns the new WebGL static buffer
  128828. */
  128829. createVertexBuffer(vertices: FloatArray): DataBuffer;
  128830. /**
  128831. * Creates a new index buffer
  128832. * @param indices defines the content of the index buffer
  128833. * @param updatable defines if the index buffer must be updatable
  128834. * @returns a new webGL buffer
  128835. */
  128836. createIndexBuffer(indices: IndicesArray): DataBuffer;
  128837. /**
  128838. * Clear the current render buffer or the current render target (if any is set up)
  128839. * @param color defines the color to use
  128840. * @param backBuffer defines if the back buffer must be cleared
  128841. * @param depth defines if the depth buffer must be cleared
  128842. * @param stencil defines if the stencil buffer must be cleared
  128843. */
  128844. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128845. /**
  128846. * Gets the current render width
  128847. * @param useScreen defines if screen size must be used (or the current render target if any)
  128848. * @returns a number defining the current render width
  128849. */
  128850. getRenderWidth(useScreen?: boolean): number;
  128851. /**
  128852. * Gets the current render height
  128853. * @param useScreen defines if screen size must be used (or the current render target if any)
  128854. * @returns a number defining the current render height
  128855. */
  128856. getRenderHeight(useScreen?: boolean): number;
  128857. /**
  128858. * Set the WebGL's viewport
  128859. * @param viewport defines the viewport element to be used
  128860. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  128861. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  128862. */
  128863. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  128864. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  128865. /**
  128866. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  128867. * @param pipelineContext defines the pipeline context to use
  128868. * @param uniformsNames defines the list of uniform names
  128869. * @returns an array of webGL uniform locations
  128870. */
  128871. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  128872. /**
  128873. * Gets the lsit of active attributes for a given webGL program
  128874. * @param pipelineContext defines the pipeline context to use
  128875. * @param attributesNames defines the list of attribute names to get
  128876. * @returns an array of indices indicating the offset of each attribute
  128877. */
  128878. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128879. /**
  128880. * Binds an effect to the webGL context
  128881. * @param effect defines the effect to bind
  128882. */
  128883. bindSamplers(effect: Effect): void;
  128884. /**
  128885. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  128886. * @param effect defines the effect to activate
  128887. */
  128888. enableEffect(effect: Effect): void;
  128889. /**
  128890. * Set various states to the webGL context
  128891. * @param culling defines backface culling state
  128892. * @param zOffset defines the value to apply to zOffset (0 by default)
  128893. * @param force defines if states must be applied even if cache is up to date
  128894. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  128895. */
  128896. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128897. /**
  128898. * Set the value of an uniform to an array of int32
  128899. * @param uniform defines the webGL uniform location where to store the value
  128900. * @param array defines the array of int32 to store
  128901. */
  128902. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128903. /**
  128904. * Set the value of an uniform to an array of int32 (stored as vec2)
  128905. * @param uniform defines the webGL uniform location where to store the value
  128906. * @param array defines the array of int32 to store
  128907. */
  128908. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128909. /**
  128910. * Set the value of an uniform to an array of int32 (stored as vec3)
  128911. * @param uniform defines the webGL uniform location where to store the value
  128912. * @param array defines the array of int32 to store
  128913. */
  128914. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128915. /**
  128916. * Set the value of an uniform to an array of int32 (stored as vec4)
  128917. * @param uniform defines the webGL uniform location where to store the value
  128918. * @param array defines the array of int32 to store
  128919. */
  128920. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128921. /**
  128922. * Set the value of an uniform to an array of float32
  128923. * @param uniform defines the webGL uniform location where to store the value
  128924. * @param array defines the array of float32 to store
  128925. */
  128926. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128927. /**
  128928. * Set the value of an uniform to an array of float32 (stored as vec2)
  128929. * @param uniform defines the webGL uniform location where to store the value
  128930. * @param array defines the array of float32 to store
  128931. */
  128932. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128933. /**
  128934. * Set the value of an uniform to an array of float32 (stored as vec3)
  128935. * @param uniform defines the webGL uniform location where to store the value
  128936. * @param array defines the array of float32 to store
  128937. */
  128938. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128939. /**
  128940. * Set the value of an uniform to an array of float32 (stored as vec4)
  128941. * @param uniform defines the webGL uniform location where to store the value
  128942. * @param array defines the array of float32 to store
  128943. */
  128944. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128945. /**
  128946. * Set the value of an uniform to an array of number
  128947. * @param uniform defines the webGL uniform location where to store the value
  128948. * @param array defines the array of number to store
  128949. */
  128950. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128951. /**
  128952. * Set the value of an uniform to an array of number (stored as vec2)
  128953. * @param uniform defines the webGL uniform location where to store the value
  128954. * @param array defines the array of number to store
  128955. */
  128956. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128957. /**
  128958. * Set the value of an uniform to an array of number (stored as vec3)
  128959. * @param uniform defines the webGL uniform location where to store the value
  128960. * @param array defines the array of number to store
  128961. */
  128962. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128963. /**
  128964. * Set the value of an uniform to an array of number (stored as vec4)
  128965. * @param uniform defines the webGL uniform location where to store the value
  128966. * @param array defines the array of number to store
  128967. */
  128968. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128969. /**
  128970. * Set the value of an uniform to an array of float32 (stored as matrices)
  128971. * @param uniform defines the webGL uniform location where to store the value
  128972. * @param matrices defines the array of float32 to store
  128973. */
  128974. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128975. /**
  128976. * Set the value of an uniform to a matrix (3x3)
  128977. * @param uniform defines the webGL uniform location where to store the value
  128978. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  128979. */
  128980. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128981. /**
  128982. * Set the value of an uniform to a matrix (2x2)
  128983. * @param uniform defines the webGL uniform location where to store the value
  128984. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  128985. */
  128986. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128987. /**
  128988. * Set the value of an uniform to a number (float)
  128989. * @param uniform defines the webGL uniform location where to store the value
  128990. * @param value defines the float number to store
  128991. */
  128992. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128993. /**
  128994. * Set the value of an uniform to a vec2
  128995. * @param uniform defines the webGL uniform location where to store the value
  128996. * @param x defines the 1st component of the value
  128997. * @param y defines the 2nd component of the value
  128998. */
  128999. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  129000. /**
  129001. * Set the value of an uniform to a vec3
  129002. * @param uniform defines the webGL uniform location where to store the value
  129003. * @param x defines the 1st component of the value
  129004. * @param y defines the 2nd component of the value
  129005. * @param z defines the 3rd component of the value
  129006. */
  129007. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  129008. /**
  129009. * Set the value of an uniform to a boolean
  129010. * @param uniform defines the webGL uniform location where to store the value
  129011. * @param bool defines the boolean to store
  129012. */
  129013. setBool(uniform: WebGLUniformLocation, bool: number): void;
  129014. /**
  129015. * Set the value of an uniform to a vec4
  129016. * @param uniform defines the webGL uniform location where to store the value
  129017. * @param x defines the 1st component of the value
  129018. * @param y defines the 2nd component of the value
  129019. * @param z defines the 3rd component of the value
  129020. * @param w defines the 4th component of the value
  129021. */
  129022. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  129023. /**
  129024. * Sets the current alpha mode
  129025. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  129026. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129027. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129028. */
  129029. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129030. /**
  129031. * Bind webGl buffers directly to the webGL context
  129032. * @param vertexBuffers defines the vertex buffer to bind
  129033. * @param indexBuffer defines the index buffer to bind
  129034. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  129035. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  129036. * @param effect defines the effect associated with the vertex buffer
  129037. */
  129038. bindBuffers(vertexBuffers: {
  129039. [key: string]: VertexBuffer;
  129040. }, indexBuffer: DataBuffer, effect: Effect): void;
  129041. /**
  129042. * Force the entire cache to be cleared
  129043. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  129044. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  129045. */
  129046. wipeCaches(bruteForce?: boolean): void;
  129047. /**
  129048. * Send a draw order
  129049. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  129050. * @param indexStart defines the starting index
  129051. * @param indexCount defines the number of index to draw
  129052. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129053. */
  129054. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  129055. /**
  129056. * Draw a list of indexed primitives
  129057. * @param fillMode defines the primitive to use
  129058. * @param indexStart defines the starting index
  129059. * @param indexCount defines the number of index to draw
  129060. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129061. */
  129062. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129063. /**
  129064. * Draw a list of unindexed primitives
  129065. * @param fillMode defines the primitive to use
  129066. * @param verticesStart defines the index of first vertex to draw
  129067. * @param verticesCount defines the count of vertices to draw
  129068. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129069. */
  129070. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129071. /** @hidden */
  129072. _createTexture(): WebGLTexture;
  129073. /** @hidden */
  129074. _releaseTexture(texture: InternalTexture): void;
  129075. /**
  129076. * Usually called from Texture.ts.
  129077. * Passed information to create a WebGLTexture
  129078. * @param urlArg defines a value which contains one of the following:
  129079. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129080. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129081. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129082. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129083. * @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)
  129084. * @param scene needed for loading to the correct scene
  129085. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129086. * @param onLoad optional callback to be called upon successful completion
  129087. * @param onError optional callback to be called upon failure
  129088. * @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
  129089. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129090. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129091. * @param forcedExtension defines the extension to use to pick the right loader
  129092. * @param mimeType defines an optional mime type
  129093. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129094. */
  129095. 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;
  129096. /**
  129097. * Creates a new render target texture
  129098. * @param size defines the size of the texture
  129099. * @param options defines the options used to create the texture
  129100. * @returns a new render target texture stored in an InternalTexture
  129101. */
  129102. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  129103. /**
  129104. * Update the sampling mode of a given texture
  129105. * @param samplingMode defines the required sampling mode
  129106. * @param texture defines the texture to update
  129107. */
  129108. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  129109. /**
  129110. * Binds the frame buffer to the specified texture.
  129111. * @param texture The texture to render to or null for the default canvas
  129112. * @param faceIndex The face of the texture to render to in case of cube texture
  129113. * @param requiredWidth The width of the target to render to
  129114. * @param requiredHeight The height of the target to render to
  129115. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  129116. * @param lodLevel defines le lod level to bind to the frame buffer
  129117. */
  129118. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  129119. /**
  129120. * Unbind the current render target texture from the webGL context
  129121. * @param texture defines the render target texture to unbind
  129122. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129123. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129124. */
  129125. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129126. /**
  129127. * Creates a dynamic vertex buffer
  129128. * @param vertices the data for the dynamic vertex buffer
  129129. * @returns the new WebGL dynamic buffer
  129130. */
  129131. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  129132. /**
  129133. * Update the content of a dynamic texture
  129134. * @param texture defines the texture to update
  129135. * @param canvas defines the canvas containing the source
  129136. * @param invertY defines if data must be stored with Y axis inverted
  129137. * @param premulAlpha defines if alpha is stored as premultiplied
  129138. * @param format defines the format of the data
  129139. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  129140. */
  129141. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  129142. /**
  129143. * Gets a boolean indicating if all created effects are ready
  129144. * @returns true if all effects are ready
  129145. */
  129146. areAllEffectsReady(): boolean;
  129147. /**
  129148. * @hidden
  129149. * Get the current error code of the webGL context
  129150. * @returns the error code
  129151. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  129152. */
  129153. getError(): number;
  129154. /** @hidden */
  129155. _getUnpackAlignement(): number;
  129156. /** @hidden */
  129157. _unpackFlipY(value: boolean): void;
  129158. /**
  129159. * Update a dynamic index buffer
  129160. * @param indexBuffer defines the target index buffer
  129161. * @param indices defines the data to update
  129162. * @param offset defines the offset in the target index buffer where update should start
  129163. */
  129164. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  129165. /**
  129166. * Updates a dynamic vertex buffer.
  129167. * @param vertexBuffer the vertex buffer to update
  129168. * @param vertices the data used to update the vertex buffer
  129169. * @param byteOffset the byte offset of the data (optional)
  129170. * @param byteLength the byte length of the data (optional)
  129171. */
  129172. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  129173. /** @hidden */
  129174. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  129175. /** @hidden */
  129176. _bindTexture(channel: number, texture: InternalTexture): void;
  129177. protected _deleteBuffer(buffer: WebGLBuffer): void;
  129178. /**
  129179. * 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
  129180. */
  129181. releaseEffects(): void;
  129182. displayLoadingUI(): void;
  129183. hideLoadingUI(): void;
  129184. /** @hidden */
  129185. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129186. /** @hidden */
  129187. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129188. /** @hidden */
  129189. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129190. /** @hidden */
  129191. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  129192. }
  129193. }
  129194. declare module BABYLON {
  129195. /**
  129196. * @hidden
  129197. **/
  129198. export class _TimeToken {
  129199. _startTimeQuery: Nullable<WebGLQuery>;
  129200. _endTimeQuery: Nullable<WebGLQuery>;
  129201. _timeElapsedQuery: Nullable<WebGLQuery>;
  129202. _timeElapsedQueryEnded: boolean;
  129203. }
  129204. }
  129205. declare module BABYLON {
  129206. /** @hidden */
  129207. export class _OcclusionDataStorage {
  129208. /** @hidden */
  129209. occlusionInternalRetryCounter: number;
  129210. /** @hidden */
  129211. isOcclusionQueryInProgress: boolean;
  129212. /** @hidden */
  129213. isOccluded: boolean;
  129214. /** @hidden */
  129215. occlusionRetryCount: number;
  129216. /** @hidden */
  129217. occlusionType: number;
  129218. /** @hidden */
  129219. occlusionQueryAlgorithmType: number;
  129220. }
  129221. interface Engine {
  129222. /**
  129223. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  129224. * @return the new query
  129225. */
  129226. createQuery(): WebGLQuery;
  129227. /**
  129228. * Delete and release a webGL query
  129229. * @param query defines the query to delete
  129230. * @return the current engine
  129231. */
  129232. deleteQuery(query: WebGLQuery): Engine;
  129233. /**
  129234. * Check if a given query has resolved and got its value
  129235. * @param query defines the query to check
  129236. * @returns true if the query got its value
  129237. */
  129238. isQueryResultAvailable(query: WebGLQuery): boolean;
  129239. /**
  129240. * Gets the value of a given query
  129241. * @param query defines the query to check
  129242. * @returns the value of the query
  129243. */
  129244. getQueryResult(query: WebGLQuery): number;
  129245. /**
  129246. * Initiates an occlusion query
  129247. * @param algorithmType defines the algorithm to use
  129248. * @param query defines the query to use
  129249. * @returns the current engine
  129250. * @see https://doc.babylonjs.com/features/occlusionquery
  129251. */
  129252. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  129253. /**
  129254. * Ends an occlusion query
  129255. * @see https://doc.babylonjs.com/features/occlusionquery
  129256. * @param algorithmType defines the algorithm to use
  129257. * @returns the current engine
  129258. */
  129259. endOcclusionQuery(algorithmType: number): Engine;
  129260. /**
  129261. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  129262. * Please note that only one query can be issued at a time
  129263. * @returns a time token used to track the time span
  129264. */
  129265. startTimeQuery(): Nullable<_TimeToken>;
  129266. /**
  129267. * Ends a time query
  129268. * @param token defines the token used to measure the time span
  129269. * @returns the time spent (in ns)
  129270. */
  129271. endTimeQuery(token: _TimeToken): int;
  129272. /** @hidden */
  129273. _currentNonTimestampToken: Nullable<_TimeToken>;
  129274. /** @hidden */
  129275. _createTimeQuery(): WebGLQuery;
  129276. /** @hidden */
  129277. _deleteTimeQuery(query: WebGLQuery): void;
  129278. /** @hidden */
  129279. _getGlAlgorithmType(algorithmType: number): number;
  129280. /** @hidden */
  129281. _getTimeQueryResult(query: WebGLQuery): any;
  129282. /** @hidden */
  129283. _getTimeQueryAvailability(query: WebGLQuery): any;
  129284. }
  129285. interface AbstractMesh {
  129286. /**
  129287. * Backing filed
  129288. * @hidden
  129289. */
  129290. __occlusionDataStorage: _OcclusionDataStorage;
  129291. /**
  129292. * Access property
  129293. * @hidden
  129294. */
  129295. _occlusionDataStorage: _OcclusionDataStorage;
  129296. /**
  129297. * 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.
  129298. * The default value is -1 which means don't break the query and wait till the result
  129299. * @see https://doc.babylonjs.com/features/occlusionquery
  129300. */
  129301. occlusionRetryCount: number;
  129302. /**
  129303. * 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:
  129304. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  129305. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  129306. * * 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.
  129307. * @see https://doc.babylonjs.com/features/occlusionquery
  129308. */
  129309. occlusionType: number;
  129310. /**
  129311. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  129312. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  129313. * * 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.
  129314. * @see https://doc.babylonjs.com/features/occlusionquery
  129315. */
  129316. occlusionQueryAlgorithmType: number;
  129317. /**
  129318. * 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
  129319. * @see https://doc.babylonjs.com/features/occlusionquery
  129320. */
  129321. isOccluded: boolean;
  129322. /**
  129323. * Flag to check the progress status of the query
  129324. * @see https://doc.babylonjs.com/features/occlusionquery
  129325. */
  129326. isOcclusionQueryInProgress: boolean;
  129327. }
  129328. }
  129329. declare module BABYLON {
  129330. /** @hidden */
  129331. export var _forceTransformFeedbackToBundle: boolean;
  129332. interface Engine {
  129333. /**
  129334. * Creates a webGL transform feedback object
  129335. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  129336. * @returns the webGL transform feedback object
  129337. */
  129338. createTransformFeedback(): WebGLTransformFeedback;
  129339. /**
  129340. * Delete a webGL transform feedback object
  129341. * @param value defines the webGL transform feedback object to delete
  129342. */
  129343. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  129344. /**
  129345. * Bind a webGL transform feedback object to the webgl context
  129346. * @param value defines the webGL transform feedback object to bind
  129347. */
  129348. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  129349. /**
  129350. * Begins a transform feedback operation
  129351. * @param usePoints defines if points or triangles must be used
  129352. */
  129353. beginTransformFeedback(usePoints: boolean): void;
  129354. /**
  129355. * Ends a transform feedback operation
  129356. */
  129357. endTransformFeedback(): void;
  129358. /**
  129359. * Specify the varyings to use with transform feedback
  129360. * @param program defines the associated webGL program
  129361. * @param value defines the list of strings representing the varying names
  129362. */
  129363. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  129364. /**
  129365. * Bind a webGL buffer for a transform feedback operation
  129366. * @param value defines the webGL buffer to bind
  129367. */
  129368. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  129369. }
  129370. }
  129371. declare module BABYLON {
  129372. /**
  129373. * Creation options of the multi render target texture.
  129374. */
  129375. export interface IMultiRenderTargetOptions {
  129376. /**
  129377. * Define if the texture needs to create mip maps after render.
  129378. */
  129379. generateMipMaps?: boolean;
  129380. /**
  129381. * Define the types of all the draw buffers we want to create
  129382. */
  129383. types?: number[];
  129384. /**
  129385. * Define the sampling modes of all the draw buffers we want to create
  129386. */
  129387. samplingModes?: number[];
  129388. /**
  129389. * Define if a depth buffer is required
  129390. */
  129391. generateDepthBuffer?: boolean;
  129392. /**
  129393. * Define if a stencil buffer is required
  129394. */
  129395. generateStencilBuffer?: boolean;
  129396. /**
  129397. * Define if a depth texture is required instead of a depth buffer
  129398. */
  129399. generateDepthTexture?: boolean;
  129400. /**
  129401. * Define the number of desired draw buffers
  129402. */
  129403. textureCount?: number;
  129404. /**
  129405. * Define if aspect ratio should be adapted to the texture or stay the scene one
  129406. */
  129407. doNotChangeAspectRatio?: boolean;
  129408. /**
  129409. * Define the default type of the buffers we are creating
  129410. */
  129411. defaultType?: number;
  129412. }
  129413. /**
  129414. * A multi render target, like a render target provides the ability to render to a texture.
  129415. * Unlike the render target, it can render to several draw buffers in one draw.
  129416. * This is specially interesting in deferred rendering or for any effects requiring more than
  129417. * just one color from a single pass.
  129418. */
  129419. export class MultiRenderTarget extends RenderTargetTexture {
  129420. private _internalTextures;
  129421. private _textures;
  129422. private _multiRenderTargetOptions;
  129423. private _count;
  129424. /**
  129425. * Get if draw buffers are currently supported by the used hardware and browser.
  129426. */
  129427. get isSupported(): boolean;
  129428. /**
  129429. * Get the list of textures generated by the multi render target.
  129430. */
  129431. get textures(): Texture[];
  129432. /**
  129433. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  129434. */
  129435. get count(): number;
  129436. /**
  129437. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  129438. */
  129439. get depthTexture(): Texture;
  129440. /**
  129441. * Set the wrapping mode on U of all the textures we are rendering to.
  129442. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129443. */
  129444. set wrapU(wrap: number);
  129445. /**
  129446. * Set the wrapping mode on V of all the textures we are rendering to.
  129447. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129448. */
  129449. set wrapV(wrap: number);
  129450. /**
  129451. * Instantiate a new multi render target texture.
  129452. * A multi render target, like a render target provides the ability to render to a texture.
  129453. * Unlike the render target, it can render to several draw buffers in one draw.
  129454. * This is specially interesting in deferred rendering or for any effects requiring more than
  129455. * just one color from a single pass.
  129456. * @param name Define the name of the texture
  129457. * @param size Define the size of the buffers to render to
  129458. * @param count Define the number of target we are rendering into
  129459. * @param scene Define the scene the texture belongs to
  129460. * @param options Define the options used to create the multi render target
  129461. */
  129462. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  129463. /** @hidden */
  129464. _rebuild(): void;
  129465. private _createInternalTextures;
  129466. private _createTextures;
  129467. /**
  129468. * Define the number of samples used if MSAA is enabled.
  129469. */
  129470. get samples(): number;
  129471. set samples(value: number);
  129472. /**
  129473. * Resize all the textures in the multi render target.
  129474. * Be carrefull as it will recreate all the data in the new texture.
  129475. * @param size Define the new size
  129476. */
  129477. resize(size: any): void;
  129478. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  129479. /**
  129480. * Dispose the render targets and their associated resources
  129481. */
  129482. dispose(): void;
  129483. /**
  129484. * Release all the underlying texture used as draw buffers.
  129485. */
  129486. releaseInternalTextures(): void;
  129487. }
  129488. }
  129489. declare module BABYLON {
  129490. interface ThinEngine {
  129491. /**
  129492. * Unbind a list of render target textures from the webGL context
  129493. * This is used only when drawBuffer extension or webGL2 are active
  129494. * @param textures defines the render target textures to unbind
  129495. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129496. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129497. */
  129498. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  129499. /**
  129500. * Create a multi render target texture
  129501. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  129502. * @param size defines the size of the texture
  129503. * @param options defines the creation options
  129504. * @returns the cube texture as an InternalTexture
  129505. */
  129506. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  129507. /**
  129508. * Update the sample count for a given multiple render target texture
  129509. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  129510. * @param textures defines the textures to update
  129511. * @param samples defines the sample count to set
  129512. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  129513. */
  129514. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  129515. /**
  129516. * Select a subsets of attachments to draw to.
  129517. * @param attachments gl attachments
  129518. */
  129519. bindAttachments(attachments: number[]): void;
  129520. }
  129521. }
  129522. declare module BABYLON {
  129523. /**
  129524. * Class used to define an additional view for the engine
  129525. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129526. */
  129527. export class EngineView {
  129528. /** Defines the canvas where to render the view */
  129529. target: HTMLCanvasElement;
  129530. /** Defines an optional camera used to render the view (will use active camera else) */
  129531. camera?: Camera;
  129532. }
  129533. interface Engine {
  129534. /**
  129535. * Gets or sets the HTML element to use for attaching events
  129536. */
  129537. inputElement: Nullable<HTMLElement>;
  129538. /**
  129539. * Gets the current engine view
  129540. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129541. */
  129542. activeView: Nullable<EngineView>;
  129543. /** Gets or sets the list of views */
  129544. views: EngineView[];
  129545. /**
  129546. * Register a new child canvas
  129547. * @param canvas defines the canvas to register
  129548. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  129549. * @returns the associated view
  129550. */
  129551. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  129552. /**
  129553. * Remove a registered child canvas
  129554. * @param canvas defines the canvas to remove
  129555. * @returns the current engine
  129556. */
  129557. unRegisterView(canvas: HTMLCanvasElement): Engine;
  129558. }
  129559. }
  129560. declare module BABYLON {
  129561. interface Engine {
  129562. /** @hidden */
  129563. _excludedCompressedTextures: string[];
  129564. /** @hidden */
  129565. _textureFormatInUse: string;
  129566. /**
  129567. * Gets the list of texture formats supported
  129568. */
  129569. readonly texturesSupported: Array<string>;
  129570. /**
  129571. * Gets the texture format in use
  129572. */
  129573. readonly textureFormatInUse: Nullable<string>;
  129574. /**
  129575. * Set the compressed texture extensions or file names to skip.
  129576. *
  129577. * @param skippedFiles defines the list of those texture files you want to skip
  129578. * Example: [".dds", ".env", "myfile.png"]
  129579. */
  129580. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  129581. /**
  129582. * Set the compressed texture format to use, based on the formats you have, and the formats
  129583. * supported by the hardware / browser.
  129584. *
  129585. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  129586. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  129587. * to API arguments needed to compressed textures. This puts the burden on the container
  129588. * generator to house the arcane code for determining these for current & future formats.
  129589. *
  129590. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  129591. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  129592. *
  129593. * Note: The result of this call is not taken into account when a texture is base64.
  129594. *
  129595. * @param formatsAvailable defines the list of those format families you have created
  129596. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  129597. *
  129598. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  129599. * @returns The extension selected.
  129600. */
  129601. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  129602. }
  129603. }
  129604. declare module BABYLON {
  129605. /**
  129606. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  129607. */
  129608. export interface CubeMapInfo {
  129609. /**
  129610. * The pixel array for the front face.
  129611. * This is stored in format, left to right, up to down format.
  129612. */
  129613. front: Nullable<ArrayBufferView>;
  129614. /**
  129615. * The pixel array for the back face.
  129616. * This is stored in format, left to right, up to down format.
  129617. */
  129618. back: Nullable<ArrayBufferView>;
  129619. /**
  129620. * The pixel array for the left face.
  129621. * This is stored in format, left to right, up to down format.
  129622. */
  129623. left: Nullable<ArrayBufferView>;
  129624. /**
  129625. * The pixel array for the right face.
  129626. * This is stored in format, left to right, up to down format.
  129627. */
  129628. right: Nullable<ArrayBufferView>;
  129629. /**
  129630. * The pixel array for the up face.
  129631. * This is stored in format, left to right, up to down format.
  129632. */
  129633. up: Nullable<ArrayBufferView>;
  129634. /**
  129635. * The pixel array for the down face.
  129636. * This is stored in format, left to right, up to down format.
  129637. */
  129638. down: Nullable<ArrayBufferView>;
  129639. /**
  129640. * The size of the cubemap stored.
  129641. *
  129642. * Each faces will be size * size pixels.
  129643. */
  129644. size: number;
  129645. /**
  129646. * The format of the texture.
  129647. *
  129648. * RGBA, RGB.
  129649. */
  129650. format: number;
  129651. /**
  129652. * The type of the texture data.
  129653. *
  129654. * UNSIGNED_INT, FLOAT.
  129655. */
  129656. type: number;
  129657. /**
  129658. * Specifies whether the texture is in gamma space.
  129659. */
  129660. gammaSpace: boolean;
  129661. }
  129662. /**
  129663. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  129664. */
  129665. export class PanoramaToCubeMapTools {
  129666. private static FACE_LEFT;
  129667. private static FACE_RIGHT;
  129668. private static FACE_FRONT;
  129669. private static FACE_BACK;
  129670. private static FACE_DOWN;
  129671. private static FACE_UP;
  129672. /**
  129673. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  129674. *
  129675. * @param float32Array The source data.
  129676. * @param inputWidth The width of the input panorama.
  129677. * @param inputHeight The height of the input panorama.
  129678. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  129679. * @return The cubemap data
  129680. */
  129681. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  129682. private static CreateCubemapTexture;
  129683. private static CalcProjectionSpherical;
  129684. }
  129685. }
  129686. declare module BABYLON {
  129687. /**
  129688. * Helper class dealing with the extraction of spherical polynomial dataArray
  129689. * from a cube map.
  129690. */
  129691. export class CubeMapToSphericalPolynomialTools {
  129692. private static FileFaces;
  129693. /**
  129694. * Converts a texture to the according Spherical Polynomial data.
  129695. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129696. *
  129697. * @param texture The texture to extract the information from.
  129698. * @return The Spherical Polynomial data.
  129699. */
  129700. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  129701. /**
  129702. * Converts a cubemap to the according Spherical Polynomial data.
  129703. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129704. *
  129705. * @param cubeInfo The Cube map to extract the information from.
  129706. * @return The Spherical Polynomial data.
  129707. */
  129708. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  129709. }
  129710. }
  129711. declare module BABYLON {
  129712. interface BaseTexture {
  129713. /**
  129714. * Get the polynomial representation of the texture data.
  129715. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  129716. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  129717. */
  129718. sphericalPolynomial: Nullable<SphericalPolynomial>;
  129719. }
  129720. }
  129721. declare module BABYLON {
  129722. /** @hidden */
  129723. export var rgbdEncodePixelShader: {
  129724. name: string;
  129725. shader: string;
  129726. };
  129727. }
  129728. declare module BABYLON {
  129729. /** @hidden */
  129730. export var rgbdDecodePixelShader: {
  129731. name: string;
  129732. shader: string;
  129733. };
  129734. }
  129735. declare module BABYLON {
  129736. /**
  129737. * Raw texture data and descriptor sufficient for WebGL texture upload
  129738. */
  129739. export interface EnvironmentTextureInfo {
  129740. /**
  129741. * Version of the environment map
  129742. */
  129743. version: number;
  129744. /**
  129745. * Width of image
  129746. */
  129747. width: number;
  129748. /**
  129749. * Irradiance information stored in the file.
  129750. */
  129751. irradiance: any;
  129752. /**
  129753. * Specular information stored in the file.
  129754. */
  129755. specular: any;
  129756. }
  129757. /**
  129758. * Defines One Image in the file. It requires only the position in the file
  129759. * as well as the length.
  129760. */
  129761. interface BufferImageData {
  129762. /**
  129763. * Length of the image data.
  129764. */
  129765. length: number;
  129766. /**
  129767. * Position of the data from the null terminator delimiting the end of the JSON.
  129768. */
  129769. position: number;
  129770. }
  129771. /**
  129772. * Defines the specular data enclosed in the file.
  129773. * This corresponds to the version 1 of the data.
  129774. */
  129775. export interface EnvironmentTextureSpecularInfoV1 {
  129776. /**
  129777. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  129778. */
  129779. specularDataPosition?: number;
  129780. /**
  129781. * This contains all the images data needed to reconstruct the cubemap.
  129782. */
  129783. mipmaps: Array<BufferImageData>;
  129784. /**
  129785. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  129786. */
  129787. lodGenerationScale: number;
  129788. }
  129789. /**
  129790. * Sets of helpers addressing the serialization and deserialization of environment texture
  129791. * stored in a BabylonJS env file.
  129792. * Those files are usually stored as .env files.
  129793. */
  129794. export class EnvironmentTextureTools {
  129795. /**
  129796. * Magic number identifying the env file.
  129797. */
  129798. private static _MagicBytes;
  129799. /**
  129800. * Gets the environment info from an env file.
  129801. * @param data The array buffer containing the .env bytes.
  129802. * @returns the environment file info (the json header) if successfully parsed.
  129803. */
  129804. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  129805. /**
  129806. * Creates an environment texture from a loaded cube texture.
  129807. * @param texture defines the cube texture to convert in env file
  129808. * @return a promise containing the environment data if succesfull.
  129809. */
  129810. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  129811. /**
  129812. * Creates a JSON representation of the spherical data.
  129813. * @param texture defines the texture containing the polynomials
  129814. * @return the JSON representation of the spherical info
  129815. */
  129816. private static _CreateEnvTextureIrradiance;
  129817. /**
  129818. * Creates the ArrayBufferViews used for initializing environment texture image data.
  129819. * @param data the image data
  129820. * @param info parameters that determine what views will be created for accessing the underlying buffer
  129821. * @return the views described by info providing access to the underlying buffer
  129822. */
  129823. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  129824. /**
  129825. * Uploads the texture info contained in the env file to the GPU.
  129826. * @param texture defines the internal texture to upload to
  129827. * @param data defines the data to load
  129828. * @param info defines the texture info retrieved through the GetEnvInfo method
  129829. * @returns a promise
  129830. */
  129831. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  129832. private static _OnImageReadyAsync;
  129833. /**
  129834. * Uploads the levels of image data to the GPU.
  129835. * @param texture defines the internal texture to upload to
  129836. * @param imageData defines the array buffer views of image data [mipmap][face]
  129837. * @returns a promise
  129838. */
  129839. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  129840. /**
  129841. * Uploads spherical polynomials information to the texture.
  129842. * @param texture defines the texture we are trying to upload the information to
  129843. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  129844. */
  129845. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  129846. /** @hidden */
  129847. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129848. }
  129849. }
  129850. declare module BABYLON {
  129851. /**
  129852. * Class used to inline functions in shader code
  129853. */
  129854. export class ShaderCodeInliner {
  129855. private static readonly _RegexpFindFunctionNameAndType;
  129856. private _sourceCode;
  129857. private _functionDescr;
  129858. private _numMaxIterations;
  129859. /** Gets or sets the token used to mark the functions to inline */
  129860. inlineToken: string;
  129861. /** Gets or sets the debug mode */
  129862. debug: boolean;
  129863. /** Gets the code after the inlining process */
  129864. get code(): string;
  129865. /**
  129866. * Initializes the inliner
  129867. * @param sourceCode shader code source to inline
  129868. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  129869. */
  129870. constructor(sourceCode: string, numMaxIterations?: number);
  129871. /**
  129872. * Start the processing of the shader code
  129873. */
  129874. processCode(): void;
  129875. private _collectFunctions;
  129876. private _processInlining;
  129877. private _extractBetweenMarkers;
  129878. private _skipWhitespaces;
  129879. private _removeComments;
  129880. private _replaceFunctionCallsByCode;
  129881. private _findBackward;
  129882. private _escapeRegExp;
  129883. private _replaceNames;
  129884. }
  129885. }
  129886. declare module BABYLON {
  129887. /**
  129888. * Container for accessors for natively-stored mesh data buffers.
  129889. */
  129890. class NativeDataBuffer extends DataBuffer {
  129891. /**
  129892. * Accessor value used to identify/retrieve a natively-stored index buffer.
  129893. */
  129894. nativeIndexBuffer?: any;
  129895. /**
  129896. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  129897. */
  129898. nativeVertexBuffer?: any;
  129899. }
  129900. /** @hidden */
  129901. class NativeTexture extends InternalTexture {
  129902. getInternalTexture(): InternalTexture;
  129903. getViewCount(): number;
  129904. }
  129905. /** @hidden */
  129906. export class NativeEngine extends Engine {
  129907. private readonly _native;
  129908. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  129909. private readonly INVALID_HANDLE;
  129910. getHardwareScalingLevel(): number;
  129911. constructor();
  129912. dispose(): void;
  129913. /**
  129914. * Can be used to override the current requestAnimationFrame requester.
  129915. * @hidden
  129916. */
  129917. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  129918. /**
  129919. * Override default engine behavior.
  129920. * @param color
  129921. * @param backBuffer
  129922. * @param depth
  129923. * @param stencil
  129924. */
  129925. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  129926. /**
  129927. * Gets host document
  129928. * @returns the host document object
  129929. */
  129930. getHostDocument(): Nullable<Document>;
  129931. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129932. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  129933. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  129934. recordVertexArrayObject(vertexBuffers: {
  129935. [key: string]: VertexBuffer;
  129936. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  129937. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129938. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129939. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129940. /**
  129941. * Draw a list of indexed primitives
  129942. * @param fillMode defines the primitive to use
  129943. * @param indexStart defines the starting index
  129944. * @param indexCount defines the number of index to draw
  129945. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129946. */
  129947. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129948. /**
  129949. * Draw a list of unindexed primitives
  129950. * @param fillMode defines the primitive to use
  129951. * @param verticesStart defines the index of first vertex to draw
  129952. * @param verticesCount defines the count of vertices to draw
  129953. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129954. */
  129955. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129956. createPipelineContext(): IPipelineContext;
  129957. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  129958. /** @hidden */
  129959. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  129960. /** @hidden */
  129961. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  129962. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129963. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129964. protected _setProgram(program: WebGLProgram): void;
  129965. _releaseEffect(effect: Effect): void;
  129966. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  129967. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  129968. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  129969. bindSamplers(effect: Effect): void;
  129970. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  129971. getRenderWidth(useScreen?: boolean): number;
  129972. getRenderHeight(useScreen?: boolean): number;
  129973. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  129974. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129975. /**
  129976. * Set the z offset to apply to current rendering
  129977. * @param value defines the offset to apply
  129978. */
  129979. setZOffset(value: number): void;
  129980. /**
  129981. * Gets the current value of the zOffset
  129982. * @returns the current zOffset state
  129983. */
  129984. getZOffset(): number;
  129985. /**
  129986. * Enable or disable depth buffering
  129987. * @param enable defines the state to set
  129988. */
  129989. setDepthBuffer(enable: boolean): void;
  129990. /**
  129991. * Gets a boolean indicating if depth writing is enabled
  129992. * @returns the current depth writing state
  129993. */
  129994. getDepthWrite(): boolean;
  129995. /**
  129996. * Enable or disable depth writing
  129997. * @param enable defines the state to set
  129998. */
  129999. setDepthWrite(enable: boolean): void;
  130000. /**
  130001. * Enable or disable color writing
  130002. * @param enable defines the state to set
  130003. */
  130004. setColorWrite(enable: boolean): void;
  130005. /**
  130006. * Gets a boolean indicating if color writing is enabled
  130007. * @returns the current color writing state
  130008. */
  130009. getColorWrite(): boolean;
  130010. /**
  130011. * Sets alpha constants used by some alpha blending modes
  130012. * @param r defines the red component
  130013. * @param g defines the green component
  130014. * @param b defines the blue component
  130015. * @param a defines the alpha component
  130016. */
  130017. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  130018. /**
  130019. * Sets the current alpha mode
  130020. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  130021. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130022. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130023. */
  130024. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130025. /**
  130026. * Gets the current alpha mode
  130027. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130028. * @returns the current alpha mode
  130029. */
  130030. getAlphaMode(): number;
  130031. setInt(uniform: WebGLUniformLocation, int: number): void;
  130032. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130033. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130034. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130035. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130036. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130037. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130038. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130039. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130040. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130041. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130042. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130043. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130044. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130045. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130046. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130047. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130048. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130049. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130050. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130051. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  130052. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  130053. wipeCaches(bruteForce?: boolean): void;
  130054. _createTexture(): WebGLTexture;
  130055. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  130056. /**
  130057. * Usually called from Texture.ts.
  130058. * Passed information to create a WebGLTexture
  130059. * @param url defines a value which contains one of the following:
  130060. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130061. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130062. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130063. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130064. * @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)
  130065. * @param scene needed for loading to the correct scene
  130066. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130067. * @param onLoad optional callback to be called upon successful completion
  130068. * @param onError optional callback to be called upon failure
  130069. * @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
  130070. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130071. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130072. * @param forcedExtension defines the extension to use to pick the right loader
  130073. * @param mimeType defines an optional mime type
  130074. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130075. */
  130076. 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;
  130077. /**
  130078. * Creates a cube texture
  130079. * @param rootUrl defines the url where the files to load is located
  130080. * @param scene defines the current scene
  130081. * @param files defines the list of files to load (1 per face)
  130082. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  130083. * @param onLoad defines an optional callback raised when the texture is loaded
  130084. * @param onError defines an optional callback raised if there is an issue to load the texture
  130085. * @param format defines the format of the data
  130086. * @param forcedExtension defines the extension to use to pick the right loader
  130087. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  130088. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  130089. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  130090. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  130091. * @returns the cube texture as an InternalTexture
  130092. */
  130093. 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;
  130094. private _getSamplingFilter;
  130095. private static _GetNativeTextureFormat;
  130096. createRenderTargetTexture(size: number | {
  130097. width: number;
  130098. height: number;
  130099. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  130100. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130101. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130102. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130103. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  130104. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  130105. /**
  130106. * Updates a dynamic vertex buffer.
  130107. * @param vertexBuffer the vertex buffer to update
  130108. * @param data the data used to update the vertex buffer
  130109. * @param byteOffset the byte offset of the data (optional)
  130110. * @param byteLength the byte length of the data (optional)
  130111. */
  130112. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  130113. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  130114. private _updateAnisotropicLevel;
  130115. private _getAddressMode;
  130116. /** @hidden */
  130117. _bindTexture(channel: number, texture: InternalTexture): void;
  130118. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  130119. releaseEffects(): void;
  130120. /** @hidden */
  130121. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130122. /** @hidden */
  130123. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130124. /** @hidden */
  130125. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130126. /** @hidden */
  130127. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130128. }
  130129. }
  130130. declare module BABYLON {
  130131. /**
  130132. * Gather the list of clipboard event types as constants.
  130133. */
  130134. export class ClipboardEventTypes {
  130135. /**
  130136. * The clipboard event is fired when a copy command is active (pressed).
  130137. */
  130138. static readonly COPY: number;
  130139. /**
  130140. * The clipboard event is fired when a cut command is active (pressed).
  130141. */
  130142. static readonly CUT: number;
  130143. /**
  130144. * The clipboard event is fired when a paste command is active (pressed).
  130145. */
  130146. static readonly PASTE: number;
  130147. }
  130148. /**
  130149. * This class is used to store clipboard related info for the onClipboardObservable event.
  130150. */
  130151. export class ClipboardInfo {
  130152. /**
  130153. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130154. */
  130155. type: number;
  130156. /**
  130157. * Defines the related dom event
  130158. */
  130159. event: ClipboardEvent;
  130160. /**
  130161. *Creates an instance of ClipboardInfo.
  130162. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  130163. * @param event Defines the related dom event
  130164. */
  130165. constructor(
  130166. /**
  130167. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130168. */
  130169. type: number,
  130170. /**
  130171. * Defines the related dom event
  130172. */
  130173. event: ClipboardEvent);
  130174. /**
  130175. * Get the clipboard event's type from the keycode.
  130176. * @param keyCode Defines the keyCode for the current keyboard event.
  130177. * @return {number}
  130178. */
  130179. static GetTypeFromCharacter(keyCode: number): number;
  130180. }
  130181. }
  130182. declare module BABYLON {
  130183. /**
  130184. * Google Daydream controller
  130185. */
  130186. export class DaydreamController extends WebVRController {
  130187. /**
  130188. * Base Url for the controller model.
  130189. */
  130190. static MODEL_BASE_URL: string;
  130191. /**
  130192. * File name for the controller model.
  130193. */
  130194. static MODEL_FILENAME: string;
  130195. /**
  130196. * Gamepad Id prefix used to identify Daydream Controller.
  130197. */
  130198. static readonly GAMEPAD_ID_PREFIX: string;
  130199. /**
  130200. * Creates a new DaydreamController from a gamepad
  130201. * @param vrGamepad the gamepad that the controller should be created from
  130202. */
  130203. constructor(vrGamepad: any);
  130204. /**
  130205. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130206. * @param scene scene in which to add meshes
  130207. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130208. */
  130209. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130210. /**
  130211. * Called once for each button that changed state since the last frame
  130212. * @param buttonIdx Which button index changed
  130213. * @param state New state of the button
  130214. * @param changes Which properties on the state changed since last frame
  130215. */
  130216. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130217. }
  130218. }
  130219. declare module BABYLON {
  130220. /**
  130221. * Gear VR Controller
  130222. */
  130223. export class GearVRController extends WebVRController {
  130224. /**
  130225. * Base Url for the controller model.
  130226. */
  130227. static MODEL_BASE_URL: string;
  130228. /**
  130229. * File name for the controller model.
  130230. */
  130231. static MODEL_FILENAME: string;
  130232. /**
  130233. * Gamepad Id prefix used to identify this controller.
  130234. */
  130235. static readonly GAMEPAD_ID_PREFIX: string;
  130236. private readonly _buttonIndexToObservableNameMap;
  130237. /**
  130238. * Creates a new GearVRController from a gamepad
  130239. * @param vrGamepad the gamepad that the controller should be created from
  130240. */
  130241. constructor(vrGamepad: any);
  130242. /**
  130243. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130244. * @param scene scene in which to add meshes
  130245. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130246. */
  130247. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130248. /**
  130249. * Called once for each button that changed state since the last frame
  130250. * @param buttonIdx Which button index changed
  130251. * @param state New state of the button
  130252. * @param changes Which properties on the state changed since last frame
  130253. */
  130254. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130255. }
  130256. }
  130257. declare module BABYLON {
  130258. /**
  130259. * Generic Controller
  130260. */
  130261. export class GenericController extends WebVRController {
  130262. /**
  130263. * Base Url for the controller model.
  130264. */
  130265. static readonly MODEL_BASE_URL: string;
  130266. /**
  130267. * File name for the controller model.
  130268. */
  130269. static readonly MODEL_FILENAME: string;
  130270. /**
  130271. * Creates a new GenericController from a gamepad
  130272. * @param vrGamepad the gamepad that the controller should be created from
  130273. */
  130274. constructor(vrGamepad: any);
  130275. /**
  130276. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130277. * @param scene scene in which to add meshes
  130278. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130279. */
  130280. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130281. /**
  130282. * Called once for each button that changed state since the last frame
  130283. * @param buttonIdx Which button index changed
  130284. * @param state New state of the button
  130285. * @param changes Which properties on the state changed since last frame
  130286. */
  130287. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130288. }
  130289. }
  130290. declare module BABYLON {
  130291. /**
  130292. * Oculus Touch Controller
  130293. */
  130294. export class OculusTouchController extends WebVRController {
  130295. /**
  130296. * Base Url for the controller model.
  130297. */
  130298. static MODEL_BASE_URL: string;
  130299. /**
  130300. * File name for the left controller model.
  130301. */
  130302. static MODEL_LEFT_FILENAME: string;
  130303. /**
  130304. * File name for the right controller model.
  130305. */
  130306. static MODEL_RIGHT_FILENAME: string;
  130307. /**
  130308. * Base Url for the Quest controller model.
  130309. */
  130310. static QUEST_MODEL_BASE_URL: string;
  130311. /**
  130312. * @hidden
  130313. * If the controllers are running on a device that needs the updated Quest controller models
  130314. */
  130315. static _IsQuest: boolean;
  130316. /**
  130317. * Fired when the secondary trigger on this controller is modified
  130318. */
  130319. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  130320. /**
  130321. * Fired when the thumb rest on this controller is modified
  130322. */
  130323. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  130324. /**
  130325. * Creates a new OculusTouchController from a gamepad
  130326. * @param vrGamepad the gamepad that the controller should be created from
  130327. */
  130328. constructor(vrGamepad: any);
  130329. /**
  130330. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130331. * @param scene scene in which to add meshes
  130332. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130333. */
  130334. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130335. /**
  130336. * Fired when the A button on this controller is modified
  130337. */
  130338. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130339. /**
  130340. * Fired when the B button on this controller is modified
  130341. */
  130342. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130343. /**
  130344. * Fired when the X button on this controller is modified
  130345. */
  130346. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130347. /**
  130348. * Fired when the Y button on this controller is modified
  130349. */
  130350. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130351. /**
  130352. * Called once for each button that changed state since the last frame
  130353. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  130354. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  130355. * 2) secondary trigger (same)
  130356. * 3) A (right) X (left), touch, pressed = value
  130357. * 4) B / Y
  130358. * 5) thumb rest
  130359. * @param buttonIdx Which button index changed
  130360. * @param state New state of the button
  130361. * @param changes Which properties on the state changed since last frame
  130362. */
  130363. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130364. }
  130365. }
  130366. declare module BABYLON {
  130367. /**
  130368. * Vive Controller
  130369. */
  130370. export class ViveController extends WebVRController {
  130371. /**
  130372. * Base Url for the controller model.
  130373. */
  130374. static MODEL_BASE_URL: string;
  130375. /**
  130376. * File name for the controller model.
  130377. */
  130378. static MODEL_FILENAME: string;
  130379. /**
  130380. * Creates a new ViveController from a gamepad
  130381. * @param vrGamepad the gamepad that the controller should be created from
  130382. */
  130383. constructor(vrGamepad: any);
  130384. /**
  130385. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130386. * @param scene scene in which to add meshes
  130387. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130388. */
  130389. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130390. /**
  130391. * Fired when the left button on this controller is modified
  130392. */
  130393. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130394. /**
  130395. * Fired when the right button on this controller is modified
  130396. */
  130397. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130398. /**
  130399. * Fired when the menu button on this controller is modified
  130400. */
  130401. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130402. /**
  130403. * Called once for each button that changed state since the last frame
  130404. * Vive mapping:
  130405. * 0: touchpad
  130406. * 1: trigger
  130407. * 2: left AND right buttons
  130408. * 3: menu button
  130409. * @param buttonIdx Which button index changed
  130410. * @param state New state of the button
  130411. * @param changes Which properties on the state changed since last frame
  130412. */
  130413. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130414. }
  130415. }
  130416. declare module BABYLON {
  130417. /**
  130418. * Defines the WindowsMotionController object that the state of the windows motion controller
  130419. */
  130420. export class WindowsMotionController extends WebVRController {
  130421. /**
  130422. * The base url used to load the left and right controller models
  130423. */
  130424. static MODEL_BASE_URL: string;
  130425. /**
  130426. * The name of the left controller model file
  130427. */
  130428. static MODEL_LEFT_FILENAME: string;
  130429. /**
  130430. * The name of the right controller model file
  130431. */
  130432. static MODEL_RIGHT_FILENAME: string;
  130433. /**
  130434. * The controller name prefix for this controller type
  130435. */
  130436. static readonly GAMEPAD_ID_PREFIX: string;
  130437. /**
  130438. * The controller id pattern for this controller type
  130439. */
  130440. private static readonly GAMEPAD_ID_PATTERN;
  130441. private _loadedMeshInfo;
  130442. protected readonly _mapping: {
  130443. buttons: string[];
  130444. buttonMeshNames: {
  130445. trigger: string;
  130446. menu: string;
  130447. grip: string;
  130448. thumbstick: string;
  130449. trackpad: string;
  130450. };
  130451. buttonObservableNames: {
  130452. trigger: string;
  130453. menu: string;
  130454. grip: string;
  130455. thumbstick: string;
  130456. trackpad: string;
  130457. };
  130458. axisMeshNames: string[];
  130459. pointingPoseMeshName: string;
  130460. };
  130461. /**
  130462. * Fired when the trackpad on this controller is clicked
  130463. */
  130464. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130465. /**
  130466. * Fired when the trackpad on this controller is modified
  130467. */
  130468. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130469. /**
  130470. * The current x and y values of this controller's trackpad
  130471. */
  130472. trackpad: StickValues;
  130473. /**
  130474. * Creates a new WindowsMotionController from a gamepad
  130475. * @param vrGamepad the gamepad that the controller should be created from
  130476. */
  130477. constructor(vrGamepad: any);
  130478. /**
  130479. * Fired when the trigger on this controller is modified
  130480. */
  130481. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130482. /**
  130483. * Fired when the menu button on this controller is modified
  130484. */
  130485. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130486. /**
  130487. * Fired when the grip button on this controller is modified
  130488. */
  130489. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130490. /**
  130491. * Fired when the thumbstick button on this controller is modified
  130492. */
  130493. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130494. /**
  130495. * Fired when the touchpad button on this controller is modified
  130496. */
  130497. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130498. /**
  130499. * Fired when the touchpad values on this controller are modified
  130500. */
  130501. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  130502. protected _updateTrackpad(): void;
  130503. /**
  130504. * Called once per frame by the engine.
  130505. */
  130506. update(): void;
  130507. /**
  130508. * Called once for each button that changed state since the last frame
  130509. * @param buttonIdx Which button index changed
  130510. * @param state New state of the button
  130511. * @param changes Which properties on the state changed since last frame
  130512. */
  130513. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130514. /**
  130515. * Moves the buttons on the controller mesh based on their current state
  130516. * @param buttonName the name of the button to move
  130517. * @param buttonValue the value of the button which determines the buttons new position
  130518. */
  130519. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  130520. /**
  130521. * Moves the axis on the controller mesh based on its current state
  130522. * @param axis the index of the axis
  130523. * @param axisValue the value of the axis which determines the meshes new position
  130524. * @hidden
  130525. */
  130526. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  130527. /**
  130528. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130529. * @param scene scene in which to add meshes
  130530. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130531. */
  130532. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  130533. /**
  130534. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  130535. * can be transformed by button presses and axes values, based on this._mapping.
  130536. *
  130537. * @param scene scene in which the meshes exist
  130538. * @param meshes list of meshes that make up the controller model to process
  130539. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  130540. */
  130541. private processModel;
  130542. private createMeshInfo;
  130543. /**
  130544. * Gets the ray of the controller in the direction the controller is pointing
  130545. * @param length the length the resulting ray should be
  130546. * @returns a ray in the direction the controller is pointing
  130547. */
  130548. getForwardRay(length?: number): Ray;
  130549. /**
  130550. * Disposes of the controller
  130551. */
  130552. dispose(): void;
  130553. }
  130554. /**
  130555. * This class represents a new windows motion controller in XR.
  130556. */
  130557. export class XRWindowsMotionController extends WindowsMotionController {
  130558. /**
  130559. * Changing the original WIndowsMotionController mapping to fir the new mapping
  130560. */
  130561. protected readonly _mapping: {
  130562. buttons: string[];
  130563. buttonMeshNames: {
  130564. trigger: string;
  130565. menu: string;
  130566. grip: string;
  130567. thumbstick: string;
  130568. trackpad: string;
  130569. };
  130570. buttonObservableNames: {
  130571. trigger: string;
  130572. menu: string;
  130573. grip: string;
  130574. thumbstick: string;
  130575. trackpad: string;
  130576. };
  130577. axisMeshNames: string[];
  130578. pointingPoseMeshName: string;
  130579. };
  130580. /**
  130581. * Construct a new XR-Based windows motion controller
  130582. *
  130583. * @param gamepadInfo the gamepad object from the browser
  130584. */
  130585. constructor(gamepadInfo: any);
  130586. /**
  130587. * holds the thumbstick values (X,Y)
  130588. */
  130589. thumbstickValues: StickValues;
  130590. /**
  130591. * Fired when the thumbstick on this controller is clicked
  130592. */
  130593. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  130594. /**
  130595. * Fired when the thumbstick on this controller is modified
  130596. */
  130597. onThumbstickValuesChangedObservable: Observable<StickValues>;
  130598. /**
  130599. * Fired when the touchpad button on this controller is modified
  130600. */
  130601. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130602. /**
  130603. * Fired when the touchpad values on this controller are modified
  130604. */
  130605. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130606. /**
  130607. * Fired when the thumbstick button on this controller is modified
  130608. * here to prevent breaking changes
  130609. */
  130610. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130611. /**
  130612. * updating the thumbstick(!) and not the trackpad.
  130613. * This is named this way due to the difference between WebVR and XR and to avoid
  130614. * changing the parent class.
  130615. */
  130616. protected _updateTrackpad(): void;
  130617. /**
  130618. * Disposes the class with joy
  130619. */
  130620. dispose(): void;
  130621. }
  130622. }
  130623. declare module BABYLON {
  130624. /**
  130625. * Class containing static functions to help procedurally build meshes
  130626. */
  130627. export class PolyhedronBuilder {
  130628. /**
  130629. * Creates a polyhedron mesh
  130630. * * 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
  130631. * * The parameter `size` (positive float, default 1) sets the polygon size
  130632. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130633. * * 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`
  130634. * * 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
  130635. * * 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)`)
  130636. * * 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
  130637. * * 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
  130638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130639. * * 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
  130640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130641. * @param name defines the name of the mesh
  130642. * @param options defines the options used to create the mesh
  130643. * @param scene defines the hosting scene
  130644. * @returns the polyhedron mesh
  130645. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130646. */
  130647. static CreatePolyhedron(name: string, options: {
  130648. type?: number;
  130649. size?: number;
  130650. sizeX?: number;
  130651. sizeY?: number;
  130652. sizeZ?: number;
  130653. custom?: any;
  130654. faceUV?: Vector4[];
  130655. faceColors?: Color4[];
  130656. flat?: boolean;
  130657. updatable?: boolean;
  130658. sideOrientation?: number;
  130659. frontUVs?: Vector4;
  130660. backUVs?: Vector4;
  130661. }, scene?: Nullable<Scene>): Mesh;
  130662. }
  130663. }
  130664. declare module BABYLON {
  130665. /**
  130666. * Gizmo that enables scaling a mesh along 3 axis
  130667. */
  130668. export class ScaleGizmo extends Gizmo {
  130669. /**
  130670. * Internal gizmo used for interactions on the x axis
  130671. */
  130672. xGizmo: AxisScaleGizmo;
  130673. /**
  130674. * Internal gizmo used for interactions on the y axis
  130675. */
  130676. yGizmo: AxisScaleGizmo;
  130677. /**
  130678. * Internal gizmo used for interactions on the z axis
  130679. */
  130680. zGizmo: AxisScaleGizmo;
  130681. /**
  130682. * Internal gizmo used to scale all axis equally
  130683. */
  130684. uniformScaleGizmo: AxisScaleGizmo;
  130685. private _meshAttached;
  130686. private _updateGizmoRotationToMatchAttachedMesh;
  130687. private _snapDistance;
  130688. private _scaleRatio;
  130689. private _uniformScalingMesh;
  130690. private _octahedron;
  130691. private _sensitivity;
  130692. /** Fires an event when any of it's sub gizmos are dragged */
  130693. onDragStartObservable: Observable<unknown>;
  130694. /** Fires an event when any of it's sub gizmos are released from dragging */
  130695. onDragEndObservable: Observable<unknown>;
  130696. get attachedMesh(): Nullable<AbstractMesh>;
  130697. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130698. /**
  130699. * Creates a ScaleGizmo
  130700. * @param gizmoLayer The utility layer the gizmo will be added to
  130701. */
  130702. constructor(gizmoLayer?: UtilityLayerRenderer);
  130703. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130704. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130705. /**
  130706. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130707. */
  130708. set snapDistance(value: number);
  130709. get snapDistance(): number;
  130710. /**
  130711. * Ratio for the scale of the gizmo (Default: 1)
  130712. */
  130713. set scaleRatio(value: number);
  130714. get scaleRatio(): number;
  130715. /**
  130716. * Sensitivity factor for dragging (Default: 1)
  130717. */
  130718. set sensitivity(value: number);
  130719. get sensitivity(): number;
  130720. /**
  130721. * Disposes of the gizmo
  130722. */
  130723. dispose(): void;
  130724. }
  130725. }
  130726. declare module BABYLON {
  130727. /**
  130728. * Single axis scale gizmo
  130729. */
  130730. export class AxisScaleGizmo extends Gizmo {
  130731. /**
  130732. * Drag behavior responsible for the gizmos dragging interactions
  130733. */
  130734. dragBehavior: PointerDragBehavior;
  130735. private _pointerObserver;
  130736. /**
  130737. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130738. */
  130739. snapDistance: number;
  130740. /**
  130741. * Event that fires each time the gizmo snaps to a new location.
  130742. * * snapDistance is the the change in distance
  130743. */
  130744. onSnapObservable: Observable<{
  130745. snapDistance: number;
  130746. }>;
  130747. /**
  130748. * If the scaling operation should be done on all axis (default: false)
  130749. */
  130750. uniformScaling: boolean;
  130751. /**
  130752. * Custom sensitivity value for the drag strength
  130753. */
  130754. sensitivity: number;
  130755. private _isEnabled;
  130756. private _parent;
  130757. private _arrow;
  130758. private _coloredMaterial;
  130759. private _hoverMaterial;
  130760. /**
  130761. * Creates an AxisScaleGizmo
  130762. * @param gizmoLayer The utility layer the gizmo will be added to
  130763. * @param dragAxis The axis which the gizmo will be able to scale on
  130764. * @param color The color of the gizmo
  130765. */
  130766. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  130767. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130768. /**
  130769. * If the gizmo is enabled
  130770. */
  130771. set isEnabled(value: boolean);
  130772. get isEnabled(): boolean;
  130773. /**
  130774. * Disposes of the gizmo
  130775. */
  130776. dispose(): void;
  130777. /**
  130778. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130779. * @param mesh The mesh to replace the default mesh of the gizmo
  130780. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  130781. */
  130782. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  130783. }
  130784. }
  130785. declare module BABYLON {
  130786. /**
  130787. * Bounding box gizmo
  130788. */
  130789. export class BoundingBoxGizmo extends Gizmo {
  130790. private _lineBoundingBox;
  130791. private _rotateSpheresParent;
  130792. private _scaleBoxesParent;
  130793. private _boundingDimensions;
  130794. private _renderObserver;
  130795. private _pointerObserver;
  130796. private _scaleDragSpeed;
  130797. private _tmpQuaternion;
  130798. private _tmpVector;
  130799. private _tmpRotationMatrix;
  130800. /**
  130801. * 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)
  130802. */
  130803. ignoreChildren: boolean;
  130804. /**
  130805. * 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)
  130806. */
  130807. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  130808. /**
  130809. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  130810. */
  130811. rotationSphereSize: number;
  130812. /**
  130813. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  130814. */
  130815. scaleBoxSize: number;
  130816. /**
  130817. * 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)
  130818. */
  130819. fixedDragMeshScreenSize: boolean;
  130820. /**
  130821. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  130822. */
  130823. fixedDragMeshScreenSizeDistanceFactor: number;
  130824. /**
  130825. * Fired when a rotation sphere or scale box is dragged
  130826. */
  130827. onDragStartObservable: Observable<{}>;
  130828. /**
  130829. * Fired when a scale box is dragged
  130830. */
  130831. onScaleBoxDragObservable: Observable<{}>;
  130832. /**
  130833. * Fired when a scale box drag is ended
  130834. */
  130835. onScaleBoxDragEndObservable: Observable<{}>;
  130836. /**
  130837. * Fired when a rotation sphere is dragged
  130838. */
  130839. onRotationSphereDragObservable: Observable<{}>;
  130840. /**
  130841. * Fired when a rotation sphere drag is ended
  130842. */
  130843. onRotationSphereDragEndObservable: Observable<{}>;
  130844. /**
  130845. * 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)
  130846. */
  130847. scalePivot: Nullable<Vector3>;
  130848. /**
  130849. * Mesh used as a pivot to rotate the attached mesh
  130850. */
  130851. private _anchorMesh;
  130852. private _existingMeshScale;
  130853. private _dragMesh;
  130854. private pointerDragBehavior;
  130855. private coloredMaterial;
  130856. private hoverColoredMaterial;
  130857. /**
  130858. * Sets the color of the bounding box gizmo
  130859. * @param color the color to set
  130860. */
  130861. setColor(color: Color3): void;
  130862. /**
  130863. * Creates an BoundingBoxGizmo
  130864. * @param gizmoLayer The utility layer the gizmo will be added to
  130865. * @param color The color of the gizmo
  130866. */
  130867. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  130868. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130869. private _selectNode;
  130870. /**
  130871. * Updates the bounding box information for the Gizmo
  130872. */
  130873. updateBoundingBox(): void;
  130874. private _updateRotationSpheres;
  130875. private _updateScaleBoxes;
  130876. /**
  130877. * Enables rotation on the specified axis and disables rotation on the others
  130878. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  130879. */
  130880. setEnabledRotationAxis(axis: string): void;
  130881. /**
  130882. * Enables/disables scaling
  130883. * @param enable if scaling should be enabled
  130884. * @param homogeneousScaling defines if scaling should only be homogeneous
  130885. */
  130886. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  130887. private _updateDummy;
  130888. /**
  130889. * Enables a pointer drag behavior on the bounding box of the gizmo
  130890. */
  130891. enableDragBehavior(): void;
  130892. /**
  130893. * Disposes of the gizmo
  130894. */
  130895. dispose(): void;
  130896. /**
  130897. * 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)
  130898. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  130899. * @returns the bounding box mesh with the passed in mesh as a child
  130900. */
  130901. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  130902. /**
  130903. * CustomMeshes are not supported by this gizmo
  130904. * @param mesh The mesh to replace the default mesh of the gizmo
  130905. */
  130906. setCustomMesh(mesh: Mesh): void;
  130907. }
  130908. }
  130909. declare module BABYLON {
  130910. /**
  130911. * Single plane rotation gizmo
  130912. */
  130913. export class PlaneRotationGizmo extends Gizmo {
  130914. /**
  130915. * Drag behavior responsible for the gizmos dragging interactions
  130916. */
  130917. dragBehavior: PointerDragBehavior;
  130918. private _pointerObserver;
  130919. /**
  130920. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  130921. */
  130922. snapDistance: number;
  130923. /**
  130924. * Event that fires each time the gizmo snaps to a new location.
  130925. * * snapDistance is the the change in distance
  130926. */
  130927. onSnapObservable: Observable<{
  130928. snapDistance: number;
  130929. }>;
  130930. private _isEnabled;
  130931. private _parent;
  130932. /**
  130933. * Creates a PlaneRotationGizmo
  130934. * @param gizmoLayer The utility layer the gizmo will be added to
  130935. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  130936. * @param color The color of the gizmo
  130937. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130938. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130939. */
  130940. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  130941. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130942. /**
  130943. * If the gizmo is enabled
  130944. */
  130945. set isEnabled(value: boolean);
  130946. get isEnabled(): boolean;
  130947. /**
  130948. * Disposes of the gizmo
  130949. */
  130950. dispose(): void;
  130951. }
  130952. }
  130953. declare module BABYLON {
  130954. /**
  130955. * Gizmo that enables rotating a mesh along 3 axis
  130956. */
  130957. export class RotationGizmo extends Gizmo {
  130958. /**
  130959. * Internal gizmo used for interactions on the x axis
  130960. */
  130961. xGizmo: PlaneRotationGizmo;
  130962. /**
  130963. * Internal gizmo used for interactions on the y axis
  130964. */
  130965. yGizmo: PlaneRotationGizmo;
  130966. /**
  130967. * Internal gizmo used for interactions on the z axis
  130968. */
  130969. zGizmo: PlaneRotationGizmo;
  130970. /** Fires an event when any of it's sub gizmos are dragged */
  130971. onDragStartObservable: Observable<unknown>;
  130972. /** Fires an event when any of it's sub gizmos are released from dragging */
  130973. onDragEndObservable: Observable<unknown>;
  130974. private _meshAttached;
  130975. get attachedMesh(): Nullable<AbstractMesh>;
  130976. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130977. /**
  130978. * Creates a RotationGizmo
  130979. * @param gizmoLayer The utility layer the gizmo will be added to
  130980. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130981. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130982. */
  130983. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  130984. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130985. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130986. /**
  130987. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130988. */
  130989. set snapDistance(value: number);
  130990. get snapDistance(): number;
  130991. /**
  130992. * Ratio for the scale of the gizmo (Default: 1)
  130993. */
  130994. set scaleRatio(value: number);
  130995. get scaleRatio(): number;
  130996. /**
  130997. * Disposes of the gizmo
  130998. */
  130999. dispose(): void;
  131000. /**
  131001. * CustomMeshes are not supported by this gizmo
  131002. * @param mesh The mesh to replace the default mesh of the gizmo
  131003. */
  131004. setCustomMesh(mesh: Mesh): void;
  131005. }
  131006. }
  131007. declare module BABYLON {
  131008. /**
  131009. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  131010. */
  131011. export class GizmoManager implements IDisposable {
  131012. private scene;
  131013. /**
  131014. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  131015. */
  131016. gizmos: {
  131017. positionGizmo: Nullable<PositionGizmo>;
  131018. rotationGizmo: Nullable<RotationGizmo>;
  131019. scaleGizmo: Nullable<ScaleGizmo>;
  131020. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  131021. };
  131022. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  131023. clearGizmoOnEmptyPointerEvent: boolean;
  131024. /** Fires an event when the manager is attached to a mesh */
  131025. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  131026. private _gizmosEnabled;
  131027. private _pointerObserver;
  131028. private _attachedMesh;
  131029. private _boundingBoxColor;
  131030. private _defaultUtilityLayer;
  131031. private _defaultKeepDepthUtilityLayer;
  131032. /**
  131033. * When bounding box gizmo is enabled, this can be used to track drag/end events
  131034. */
  131035. boundingBoxDragBehavior: SixDofDragBehavior;
  131036. /**
  131037. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  131038. */
  131039. attachableMeshes: Nullable<Array<AbstractMesh>>;
  131040. /**
  131041. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  131042. */
  131043. usePointerToAttachGizmos: boolean;
  131044. /**
  131045. * Utility layer that the bounding box gizmo belongs to
  131046. */
  131047. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  131048. /**
  131049. * Utility layer that all gizmos besides bounding box belong to
  131050. */
  131051. get utilityLayer(): UtilityLayerRenderer;
  131052. /**
  131053. * Instatiates a gizmo manager
  131054. * @param scene the scene to overlay the gizmos on top of
  131055. */
  131056. constructor(scene: Scene);
  131057. /**
  131058. * Attaches a set of gizmos to the specified mesh
  131059. * @param mesh The mesh the gizmo's should be attached to
  131060. */
  131061. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  131062. /**
  131063. * If the position gizmo is enabled
  131064. */
  131065. set positionGizmoEnabled(value: boolean);
  131066. get positionGizmoEnabled(): boolean;
  131067. /**
  131068. * If the rotation gizmo is enabled
  131069. */
  131070. set rotationGizmoEnabled(value: boolean);
  131071. get rotationGizmoEnabled(): boolean;
  131072. /**
  131073. * If the scale gizmo is enabled
  131074. */
  131075. set scaleGizmoEnabled(value: boolean);
  131076. get scaleGizmoEnabled(): boolean;
  131077. /**
  131078. * If the boundingBox gizmo is enabled
  131079. */
  131080. set boundingBoxGizmoEnabled(value: boolean);
  131081. get boundingBoxGizmoEnabled(): boolean;
  131082. /**
  131083. * Disposes of the gizmo manager
  131084. */
  131085. dispose(): void;
  131086. }
  131087. }
  131088. declare module BABYLON {
  131089. /**
  131090. * A directional light is defined by a direction (what a surprise!).
  131091. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  131092. * 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.
  131093. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131094. */
  131095. export class DirectionalLight extends ShadowLight {
  131096. private _shadowFrustumSize;
  131097. /**
  131098. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  131099. */
  131100. get shadowFrustumSize(): number;
  131101. /**
  131102. * Specifies a fix frustum size for the shadow generation.
  131103. */
  131104. set shadowFrustumSize(value: number);
  131105. private _shadowOrthoScale;
  131106. /**
  131107. * Gets the shadow projection scale against the optimal computed one.
  131108. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131109. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131110. */
  131111. get shadowOrthoScale(): number;
  131112. /**
  131113. * Sets the shadow projection scale against the optimal computed one.
  131114. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131115. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131116. */
  131117. set shadowOrthoScale(value: number);
  131118. /**
  131119. * Automatically compute the projection matrix to best fit (including all the casters)
  131120. * on each frame.
  131121. */
  131122. autoUpdateExtends: boolean;
  131123. /**
  131124. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  131125. * on each frame. autoUpdateExtends must be set to true for this to work
  131126. */
  131127. autoCalcShadowZBounds: boolean;
  131128. private _orthoLeft;
  131129. private _orthoRight;
  131130. private _orthoTop;
  131131. private _orthoBottom;
  131132. /**
  131133. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  131134. * The directional light is emitted from everywhere in the given direction.
  131135. * It can cast shadows.
  131136. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131137. * @param name The friendly name of the light
  131138. * @param direction The direction of the light
  131139. * @param scene The scene the light belongs to
  131140. */
  131141. constructor(name: string, direction: Vector3, scene: Scene);
  131142. /**
  131143. * Returns the string "DirectionalLight".
  131144. * @return The class name
  131145. */
  131146. getClassName(): string;
  131147. /**
  131148. * Returns the integer 1.
  131149. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131150. */
  131151. getTypeID(): number;
  131152. /**
  131153. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  131154. * Returns the DirectionalLight Shadow projection matrix.
  131155. */
  131156. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131157. /**
  131158. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  131159. * Returns the DirectionalLight Shadow projection matrix.
  131160. */
  131161. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  131162. /**
  131163. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  131164. * Returns the DirectionalLight Shadow projection matrix.
  131165. */
  131166. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131167. protected _buildUniformLayout(): void;
  131168. /**
  131169. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  131170. * @param effect The effect to update
  131171. * @param lightIndex The index of the light in the effect to update
  131172. * @returns The directional light
  131173. */
  131174. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  131175. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  131176. /**
  131177. * Gets the minZ used for shadow according to both the scene and the light.
  131178. *
  131179. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131180. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131181. * @param activeCamera The camera we are returning the min for
  131182. * @returns the depth min z
  131183. */
  131184. getDepthMinZ(activeCamera: Camera): number;
  131185. /**
  131186. * Gets the maxZ used for shadow according to both the scene and the light.
  131187. *
  131188. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131189. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131190. * @param activeCamera The camera we are returning the max for
  131191. * @returns the depth max z
  131192. */
  131193. getDepthMaxZ(activeCamera: Camera): number;
  131194. /**
  131195. * Prepares the list of defines specific to the light type.
  131196. * @param defines the list of defines
  131197. * @param lightIndex defines the index of the light for the effect
  131198. */
  131199. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131200. }
  131201. }
  131202. declare module BABYLON {
  131203. /**
  131204. * Class containing static functions to help procedurally build meshes
  131205. */
  131206. export class HemisphereBuilder {
  131207. /**
  131208. * Creates a hemisphere mesh
  131209. * @param name defines the name of the mesh
  131210. * @param options defines the options used to create the mesh
  131211. * @param scene defines the hosting scene
  131212. * @returns the hemisphere mesh
  131213. */
  131214. static CreateHemisphere(name: string, options: {
  131215. segments?: number;
  131216. diameter?: number;
  131217. sideOrientation?: number;
  131218. }, scene: any): Mesh;
  131219. }
  131220. }
  131221. declare module BABYLON {
  131222. /**
  131223. * A spot light is defined by a position, a direction, an angle, and an exponent.
  131224. * These values define a cone of light starting from the position, emitting toward the direction.
  131225. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  131226. * and the exponent defines the speed of the decay of the light with distance (reach).
  131227. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131228. */
  131229. export class SpotLight extends ShadowLight {
  131230. private _angle;
  131231. private _innerAngle;
  131232. private _cosHalfAngle;
  131233. private _lightAngleScale;
  131234. private _lightAngleOffset;
  131235. /**
  131236. * Gets the cone angle of the spot light in Radians.
  131237. */
  131238. get angle(): number;
  131239. /**
  131240. * Sets the cone angle of the spot light in Radians.
  131241. */
  131242. set angle(value: number);
  131243. /**
  131244. * Only used in gltf falloff mode, this defines the angle where
  131245. * the directional falloff will start before cutting at angle which could be seen
  131246. * as outer angle.
  131247. */
  131248. get innerAngle(): number;
  131249. /**
  131250. * Only used in gltf falloff mode, this defines the angle where
  131251. * the directional falloff will start before cutting at angle which could be seen
  131252. * as outer angle.
  131253. */
  131254. set innerAngle(value: number);
  131255. private _shadowAngleScale;
  131256. /**
  131257. * Allows scaling the angle of the light for shadow generation only.
  131258. */
  131259. get shadowAngleScale(): number;
  131260. /**
  131261. * Allows scaling the angle of the light for shadow generation only.
  131262. */
  131263. set shadowAngleScale(value: number);
  131264. /**
  131265. * The light decay speed with the distance from the emission spot.
  131266. */
  131267. exponent: number;
  131268. private _projectionTextureMatrix;
  131269. /**
  131270. * Allows reading the projecton texture
  131271. */
  131272. get projectionTextureMatrix(): Matrix;
  131273. protected _projectionTextureLightNear: number;
  131274. /**
  131275. * Gets the near clip of the Spotlight for texture projection.
  131276. */
  131277. get projectionTextureLightNear(): number;
  131278. /**
  131279. * Sets the near clip of the Spotlight for texture projection.
  131280. */
  131281. set projectionTextureLightNear(value: number);
  131282. protected _projectionTextureLightFar: number;
  131283. /**
  131284. * Gets the far clip of the Spotlight for texture projection.
  131285. */
  131286. get projectionTextureLightFar(): number;
  131287. /**
  131288. * Sets the far clip of the Spotlight for texture projection.
  131289. */
  131290. set projectionTextureLightFar(value: number);
  131291. protected _projectionTextureUpDirection: Vector3;
  131292. /**
  131293. * Gets the Up vector of the Spotlight for texture projection.
  131294. */
  131295. get projectionTextureUpDirection(): Vector3;
  131296. /**
  131297. * Sets the Up vector of the Spotlight for texture projection.
  131298. */
  131299. set projectionTextureUpDirection(value: Vector3);
  131300. private _projectionTexture;
  131301. /**
  131302. * Gets the projection texture of the light.
  131303. */
  131304. get projectionTexture(): Nullable<BaseTexture>;
  131305. /**
  131306. * Sets the projection texture of the light.
  131307. */
  131308. set projectionTexture(value: Nullable<BaseTexture>);
  131309. private _projectionTextureViewLightDirty;
  131310. private _projectionTextureProjectionLightDirty;
  131311. private _projectionTextureDirty;
  131312. private _projectionTextureViewTargetVector;
  131313. private _projectionTextureViewLightMatrix;
  131314. private _projectionTextureProjectionLightMatrix;
  131315. private _projectionTextureScalingMatrix;
  131316. /**
  131317. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  131318. * It can cast shadows.
  131319. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131320. * @param name The light friendly name
  131321. * @param position The position of the spot light in the scene
  131322. * @param direction The direction of the light in the scene
  131323. * @param angle The cone angle of the light in Radians
  131324. * @param exponent The light decay speed with the distance from the emission spot
  131325. * @param scene The scene the lights belongs to
  131326. */
  131327. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  131328. /**
  131329. * Returns the string "SpotLight".
  131330. * @returns the class name
  131331. */
  131332. getClassName(): string;
  131333. /**
  131334. * Returns the integer 2.
  131335. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131336. */
  131337. getTypeID(): number;
  131338. /**
  131339. * Overrides the direction setter to recompute the projection texture view light Matrix.
  131340. */
  131341. protected _setDirection(value: Vector3): void;
  131342. /**
  131343. * Overrides the position setter to recompute the projection texture view light Matrix.
  131344. */
  131345. protected _setPosition(value: Vector3): void;
  131346. /**
  131347. * 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.
  131348. * Returns the SpotLight.
  131349. */
  131350. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131351. protected _computeProjectionTextureViewLightMatrix(): void;
  131352. protected _computeProjectionTextureProjectionLightMatrix(): void;
  131353. /**
  131354. * Main function for light texture projection matrix computing.
  131355. */
  131356. protected _computeProjectionTextureMatrix(): void;
  131357. protected _buildUniformLayout(): void;
  131358. private _computeAngleValues;
  131359. /**
  131360. * Sets the passed Effect "effect" with the Light textures.
  131361. * @param effect The effect to update
  131362. * @param lightIndex The index of the light in the effect to update
  131363. * @returns The light
  131364. */
  131365. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  131366. /**
  131367. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  131368. * @param effect The effect to update
  131369. * @param lightIndex The index of the light in the effect to update
  131370. * @returns The spot light
  131371. */
  131372. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  131373. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  131374. /**
  131375. * Disposes the light and the associated resources.
  131376. */
  131377. dispose(): void;
  131378. /**
  131379. * Prepares the list of defines specific to the light type.
  131380. * @param defines the list of defines
  131381. * @param lightIndex defines the index of the light for the effect
  131382. */
  131383. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131384. }
  131385. }
  131386. declare module BABYLON {
  131387. /**
  131388. * Gizmo that enables viewing a light
  131389. */
  131390. export class LightGizmo extends Gizmo {
  131391. private _lightMesh;
  131392. private _material;
  131393. private _cachedPosition;
  131394. private _cachedForward;
  131395. private _attachedMeshParent;
  131396. /**
  131397. * Creates a LightGizmo
  131398. * @param gizmoLayer The utility layer the gizmo will be added to
  131399. */
  131400. constructor(gizmoLayer?: UtilityLayerRenderer);
  131401. private _light;
  131402. /**
  131403. * The light that the gizmo is attached to
  131404. */
  131405. set light(light: Nullable<Light>);
  131406. get light(): Nullable<Light>;
  131407. /**
  131408. * Gets the material used to render the light gizmo
  131409. */
  131410. get material(): StandardMaterial;
  131411. /**
  131412. * @hidden
  131413. * Updates the gizmo to match the attached mesh's position/rotation
  131414. */
  131415. protected _update(): void;
  131416. private static _Scale;
  131417. /**
  131418. * Creates the lines for a light mesh
  131419. */
  131420. private static _CreateLightLines;
  131421. /**
  131422. * Disposes of the light gizmo
  131423. */
  131424. dispose(): void;
  131425. private static _CreateHemisphericLightMesh;
  131426. private static _CreatePointLightMesh;
  131427. private static _CreateSpotLightMesh;
  131428. private static _CreateDirectionalLightMesh;
  131429. }
  131430. }
  131431. declare module BABYLON {
  131432. /** @hidden */
  131433. export var backgroundFragmentDeclaration: {
  131434. name: string;
  131435. shader: string;
  131436. };
  131437. }
  131438. declare module BABYLON {
  131439. /** @hidden */
  131440. export var backgroundUboDeclaration: {
  131441. name: string;
  131442. shader: string;
  131443. };
  131444. }
  131445. declare module BABYLON {
  131446. /** @hidden */
  131447. export var backgroundPixelShader: {
  131448. name: string;
  131449. shader: string;
  131450. };
  131451. }
  131452. declare module BABYLON {
  131453. /** @hidden */
  131454. export var backgroundVertexDeclaration: {
  131455. name: string;
  131456. shader: string;
  131457. };
  131458. }
  131459. declare module BABYLON {
  131460. /** @hidden */
  131461. export var backgroundVertexShader: {
  131462. name: string;
  131463. shader: string;
  131464. };
  131465. }
  131466. declare module BABYLON {
  131467. /**
  131468. * Background material used to create an efficient environement around your scene.
  131469. */
  131470. export class BackgroundMaterial extends PushMaterial {
  131471. /**
  131472. * Standard reflectance value at parallel view angle.
  131473. */
  131474. static StandardReflectance0: number;
  131475. /**
  131476. * Standard reflectance value at grazing angle.
  131477. */
  131478. static StandardReflectance90: number;
  131479. protected _primaryColor: Color3;
  131480. /**
  131481. * Key light Color (multiply against the environement texture)
  131482. */
  131483. primaryColor: Color3;
  131484. protected __perceptualColor: Nullable<Color3>;
  131485. /**
  131486. * Experimental Internal Use Only.
  131487. *
  131488. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  131489. * This acts as a helper to set the primary color to a more "human friendly" value.
  131490. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  131491. * output color as close as possible from the chosen value.
  131492. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  131493. * part of lighting setup.)
  131494. */
  131495. get _perceptualColor(): Nullable<Color3>;
  131496. set _perceptualColor(value: Nullable<Color3>);
  131497. protected _primaryColorShadowLevel: float;
  131498. /**
  131499. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  131500. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  131501. */
  131502. get primaryColorShadowLevel(): float;
  131503. set primaryColorShadowLevel(value: float);
  131504. protected _primaryColorHighlightLevel: float;
  131505. /**
  131506. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  131507. * The primary color is used at the level chosen to define what the white area would look.
  131508. */
  131509. get primaryColorHighlightLevel(): float;
  131510. set primaryColorHighlightLevel(value: float);
  131511. protected _reflectionTexture: Nullable<BaseTexture>;
  131512. /**
  131513. * Reflection Texture used in the material.
  131514. * Should be author in a specific way for the best result (refer to the documentation).
  131515. */
  131516. reflectionTexture: Nullable<BaseTexture>;
  131517. protected _reflectionBlur: float;
  131518. /**
  131519. * Reflection Texture level of blur.
  131520. *
  131521. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  131522. * texture twice.
  131523. */
  131524. reflectionBlur: float;
  131525. protected _diffuseTexture: Nullable<BaseTexture>;
  131526. /**
  131527. * Diffuse Texture used in the material.
  131528. * Should be author in a specific way for the best result (refer to the documentation).
  131529. */
  131530. diffuseTexture: Nullable<BaseTexture>;
  131531. protected _shadowLights: Nullable<IShadowLight[]>;
  131532. /**
  131533. * Specify the list of lights casting shadow on the material.
  131534. * All scene shadow lights will be included if null.
  131535. */
  131536. shadowLights: Nullable<IShadowLight[]>;
  131537. protected _shadowLevel: float;
  131538. /**
  131539. * Helps adjusting the shadow to a softer level if required.
  131540. * 0 means black shadows and 1 means no shadows.
  131541. */
  131542. shadowLevel: float;
  131543. protected _sceneCenter: Vector3;
  131544. /**
  131545. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  131546. * It is usually zero but might be interesting to modify according to your setup.
  131547. */
  131548. sceneCenter: Vector3;
  131549. protected _opacityFresnel: boolean;
  131550. /**
  131551. * This helps specifying that the material is falling off to the sky box at grazing angle.
  131552. * This helps ensuring a nice transition when the camera goes under the ground.
  131553. */
  131554. opacityFresnel: boolean;
  131555. protected _reflectionFresnel: boolean;
  131556. /**
  131557. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  131558. * This helps adding a mirror texture on the ground.
  131559. */
  131560. reflectionFresnel: boolean;
  131561. protected _reflectionFalloffDistance: number;
  131562. /**
  131563. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  131564. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  131565. */
  131566. reflectionFalloffDistance: number;
  131567. protected _reflectionAmount: number;
  131568. /**
  131569. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  131570. */
  131571. reflectionAmount: number;
  131572. protected _reflectionReflectance0: number;
  131573. /**
  131574. * This specifies the weight of the reflection at grazing angle.
  131575. */
  131576. reflectionReflectance0: number;
  131577. protected _reflectionReflectance90: number;
  131578. /**
  131579. * This specifies the weight of the reflection at a perpendicular point of view.
  131580. */
  131581. reflectionReflectance90: number;
  131582. /**
  131583. * Sets the reflection reflectance fresnel values according to the default standard
  131584. * empirically know to work well :-)
  131585. */
  131586. set reflectionStandardFresnelWeight(value: number);
  131587. protected _useRGBColor: boolean;
  131588. /**
  131589. * Helps to directly use the maps channels instead of their level.
  131590. */
  131591. useRGBColor: boolean;
  131592. protected _enableNoise: boolean;
  131593. /**
  131594. * This helps reducing the banding effect that could occur on the background.
  131595. */
  131596. enableNoise: boolean;
  131597. /**
  131598. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  131599. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  131600. * Recommended to be keep at 1.0 except for special cases.
  131601. */
  131602. get fovMultiplier(): number;
  131603. set fovMultiplier(value: number);
  131604. private _fovMultiplier;
  131605. /**
  131606. * Enable the FOV adjustment feature controlled by fovMultiplier.
  131607. */
  131608. useEquirectangularFOV: boolean;
  131609. private _maxSimultaneousLights;
  131610. /**
  131611. * Number of Simultaneous lights allowed on the material.
  131612. */
  131613. maxSimultaneousLights: int;
  131614. private _shadowOnly;
  131615. /**
  131616. * Make the material only render shadows
  131617. */
  131618. shadowOnly: boolean;
  131619. /**
  131620. * Default configuration related to image processing available in the Background Material.
  131621. */
  131622. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131623. /**
  131624. * Keep track of the image processing observer to allow dispose and replace.
  131625. */
  131626. private _imageProcessingObserver;
  131627. /**
  131628. * Attaches a new image processing configuration to the PBR Material.
  131629. * @param configuration (if null the scene configuration will be use)
  131630. */
  131631. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131632. /**
  131633. * Gets the image processing configuration used either in this material.
  131634. */
  131635. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  131636. /**
  131637. * Sets the Default image processing configuration used either in the this material.
  131638. *
  131639. * If sets to null, the scene one is in use.
  131640. */
  131641. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  131642. /**
  131643. * Gets wether the color curves effect is enabled.
  131644. */
  131645. get cameraColorCurvesEnabled(): boolean;
  131646. /**
  131647. * Sets wether the color curves effect is enabled.
  131648. */
  131649. set cameraColorCurvesEnabled(value: boolean);
  131650. /**
  131651. * Gets wether the color grading effect is enabled.
  131652. */
  131653. get cameraColorGradingEnabled(): boolean;
  131654. /**
  131655. * Gets wether the color grading effect is enabled.
  131656. */
  131657. set cameraColorGradingEnabled(value: boolean);
  131658. /**
  131659. * Gets wether tonemapping is enabled or not.
  131660. */
  131661. get cameraToneMappingEnabled(): boolean;
  131662. /**
  131663. * Sets wether tonemapping is enabled or not
  131664. */
  131665. set cameraToneMappingEnabled(value: boolean);
  131666. /**
  131667. * The camera exposure used on this material.
  131668. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  131669. * This corresponds to a photographic exposure.
  131670. */
  131671. get cameraExposure(): float;
  131672. /**
  131673. * The camera exposure used on this material.
  131674. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  131675. * This corresponds to a photographic exposure.
  131676. */
  131677. set cameraExposure(value: float);
  131678. /**
  131679. * Gets The camera contrast used on this material.
  131680. */
  131681. get cameraContrast(): float;
  131682. /**
  131683. * Sets The camera contrast used on this material.
  131684. */
  131685. set cameraContrast(value: float);
  131686. /**
  131687. * Gets the Color Grading 2D Lookup Texture.
  131688. */
  131689. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  131690. /**
  131691. * Sets the Color Grading 2D Lookup Texture.
  131692. */
  131693. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  131694. /**
  131695. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131696. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131697. * 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;
  131698. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131699. */
  131700. get cameraColorCurves(): Nullable<ColorCurves>;
  131701. /**
  131702. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131703. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131704. * 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;
  131705. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131706. */
  131707. set cameraColorCurves(value: Nullable<ColorCurves>);
  131708. /**
  131709. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  131710. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  131711. */
  131712. switchToBGR: boolean;
  131713. private _renderTargets;
  131714. private _reflectionControls;
  131715. private _white;
  131716. private _primaryShadowColor;
  131717. private _primaryHighlightColor;
  131718. /**
  131719. * Instantiates a Background Material in the given scene
  131720. * @param name The friendly name of the material
  131721. * @param scene The scene to add the material to
  131722. */
  131723. constructor(name: string, scene: Scene);
  131724. /**
  131725. * Gets a boolean indicating that current material needs to register RTT
  131726. */
  131727. get hasRenderTargetTextures(): boolean;
  131728. /**
  131729. * The entire material has been created in order to prevent overdraw.
  131730. * @returns false
  131731. */
  131732. needAlphaTesting(): boolean;
  131733. /**
  131734. * The entire material has been created in order to prevent overdraw.
  131735. * @returns true if blending is enable
  131736. */
  131737. needAlphaBlending(): boolean;
  131738. /**
  131739. * Checks wether the material is ready to be rendered for a given mesh.
  131740. * @param mesh The mesh to render
  131741. * @param subMesh The submesh to check against
  131742. * @param useInstances Specify wether or not the material is used with instances
  131743. * @returns true if all the dependencies are ready (Textures, Effects...)
  131744. */
  131745. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  131746. /**
  131747. * Compute the primary color according to the chosen perceptual color.
  131748. */
  131749. private _computePrimaryColorFromPerceptualColor;
  131750. /**
  131751. * Compute the highlights and shadow colors according to their chosen levels.
  131752. */
  131753. private _computePrimaryColors;
  131754. /**
  131755. * Build the uniform buffer used in the material.
  131756. */
  131757. buildUniformLayout(): void;
  131758. /**
  131759. * Unbind the material.
  131760. */
  131761. unbind(): void;
  131762. /**
  131763. * Bind only the world matrix to the material.
  131764. * @param world The world matrix to bind.
  131765. */
  131766. bindOnlyWorldMatrix(world: Matrix): void;
  131767. /**
  131768. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  131769. * @param world The world matrix to bind.
  131770. * @param subMesh The submesh to bind for.
  131771. */
  131772. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  131773. /**
  131774. * Checks to see if a texture is used in the material.
  131775. * @param texture - Base texture to use.
  131776. * @returns - Boolean specifying if a texture is used in the material.
  131777. */
  131778. hasTexture(texture: BaseTexture): boolean;
  131779. /**
  131780. * Dispose the material.
  131781. * @param forceDisposeEffect Force disposal of the associated effect.
  131782. * @param forceDisposeTextures Force disposal of the associated textures.
  131783. */
  131784. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  131785. /**
  131786. * Clones the material.
  131787. * @param name The cloned name.
  131788. * @returns The cloned material.
  131789. */
  131790. clone(name: string): BackgroundMaterial;
  131791. /**
  131792. * Serializes the current material to its JSON representation.
  131793. * @returns The JSON representation.
  131794. */
  131795. serialize(): any;
  131796. /**
  131797. * Gets the class name of the material
  131798. * @returns "BackgroundMaterial"
  131799. */
  131800. getClassName(): string;
  131801. /**
  131802. * Parse a JSON input to create back a background material.
  131803. * @param source The JSON data to parse
  131804. * @param scene The scene to create the parsed material in
  131805. * @param rootUrl The root url of the assets the material depends upon
  131806. * @returns the instantiated BackgroundMaterial.
  131807. */
  131808. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  131809. }
  131810. }
  131811. declare module BABYLON {
  131812. /**
  131813. * Represents the different options available during the creation of
  131814. * a Environment helper.
  131815. *
  131816. * This can control the default ground, skybox and image processing setup of your scene.
  131817. */
  131818. export interface IEnvironmentHelperOptions {
  131819. /**
  131820. * Specifies whether or not to create a ground.
  131821. * True by default.
  131822. */
  131823. createGround: boolean;
  131824. /**
  131825. * Specifies the ground size.
  131826. * 15 by default.
  131827. */
  131828. groundSize: number;
  131829. /**
  131830. * The texture used on the ground for the main color.
  131831. * Comes from the BabylonJS CDN by default.
  131832. *
  131833. * Remarks: Can be either a texture or a url.
  131834. */
  131835. groundTexture: string | BaseTexture;
  131836. /**
  131837. * The color mixed in the ground texture by default.
  131838. * BabylonJS clearColor by default.
  131839. */
  131840. groundColor: Color3;
  131841. /**
  131842. * Specifies the ground opacity.
  131843. * 1 by default.
  131844. */
  131845. groundOpacity: number;
  131846. /**
  131847. * Enables the ground to receive shadows.
  131848. * True by default.
  131849. */
  131850. enableGroundShadow: boolean;
  131851. /**
  131852. * Helps preventing the shadow to be fully black on the ground.
  131853. * 0.5 by default.
  131854. */
  131855. groundShadowLevel: number;
  131856. /**
  131857. * Creates a mirror texture attach to the ground.
  131858. * false by default.
  131859. */
  131860. enableGroundMirror: boolean;
  131861. /**
  131862. * Specifies the ground mirror size ratio.
  131863. * 0.3 by default as the default kernel is 64.
  131864. */
  131865. groundMirrorSizeRatio: number;
  131866. /**
  131867. * Specifies the ground mirror blur kernel size.
  131868. * 64 by default.
  131869. */
  131870. groundMirrorBlurKernel: number;
  131871. /**
  131872. * Specifies the ground mirror visibility amount.
  131873. * 1 by default
  131874. */
  131875. groundMirrorAmount: number;
  131876. /**
  131877. * Specifies the ground mirror reflectance weight.
  131878. * This uses the standard weight of the background material to setup the fresnel effect
  131879. * of the mirror.
  131880. * 1 by default.
  131881. */
  131882. groundMirrorFresnelWeight: number;
  131883. /**
  131884. * Specifies the ground mirror Falloff distance.
  131885. * This can helps reducing the size of the reflection.
  131886. * 0 by Default.
  131887. */
  131888. groundMirrorFallOffDistance: number;
  131889. /**
  131890. * Specifies the ground mirror texture type.
  131891. * Unsigned Int by Default.
  131892. */
  131893. groundMirrorTextureType: number;
  131894. /**
  131895. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  131896. * the shown objects.
  131897. */
  131898. groundYBias: number;
  131899. /**
  131900. * Specifies whether or not to create a skybox.
  131901. * True by default.
  131902. */
  131903. createSkybox: boolean;
  131904. /**
  131905. * Specifies the skybox size.
  131906. * 20 by default.
  131907. */
  131908. skyboxSize: number;
  131909. /**
  131910. * The texture used on the skybox for the main color.
  131911. * Comes from the BabylonJS CDN by default.
  131912. *
  131913. * Remarks: Can be either a texture or a url.
  131914. */
  131915. skyboxTexture: string | BaseTexture;
  131916. /**
  131917. * The color mixed in the skybox texture by default.
  131918. * BabylonJS clearColor by default.
  131919. */
  131920. skyboxColor: Color3;
  131921. /**
  131922. * The background rotation around the Y axis of the scene.
  131923. * This helps aligning the key lights of your scene with the background.
  131924. * 0 by default.
  131925. */
  131926. backgroundYRotation: number;
  131927. /**
  131928. * Compute automatically the size of the elements to best fit with the scene.
  131929. */
  131930. sizeAuto: boolean;
  131931. /**
  131932. * Default position of the rootMesh if autoSize is not true.
  131933. */
  131934. rootPosition: Vector3;
  131935. /**
  131936. * Sets up the image processing in the scene.
  131937. * true by default.
  131938. */
  131939. setupImageProcessing: boolean;
  131940. /**
  131941. * The texture used as your environment texture in the scene.
  131942. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  131943. *
  131944. * Remarks: Can be either a texture or a url.
  131945. */
  131946. environmentTexture: string | BaseTexture;
  131947. /**
  131948. * The value of the exposure to apply to the scene.
  131949. * 0.6 by default if setupImageProcessing is true.
  131950. */
  131951. cameraExposure: number;
  131952. /**
  131953. * The value of the contrast to apply to the scene.
  131954. * 1.6 by default if setupImageProcessing is true.
  131955. */
  131956. cameraContrast: number;
  131957. /**
  131958. * Specifies whether or not tonemapping should be enabled in the scene.
  131959. * true by default if setupImageProcessing is true.
  131960. */
  131961. toneMappingEnabled: boolean;
  131962. }
  131963. /**
  131964. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  131965. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  131966. * It also helps with the default setup of your imageProcessing configuration.
  131967. */
  131968. export class EnvironmentHelper {
  131969. /**
  131970. * Default ground texture URL.
  131971. */
  131972. private static _groundTextureCDNUrl;
  131973. /**
  131974. * Default skybox texture URL.
  131975. */
  131976. private static _skyboxTextureCDNUrl;
  131977. /**
  131978. * Default environment texture URL.
  131979. */
  131980. private static _environmentTextureCDNUrl;
  131981. /**
  131982. * Creates the default options for the helper.
  131983. */
  131984. private static _getDefaultOptions;
  131985. private _rootMesh;
  131986. /**
  131987. * Gets the root mesh created by the helper.
  131988. */
  131989. get rootMesh(): Mesh;
  131990. private _skybox;
  131991. /**
  131992. * Gets the skybox created by the helper.
  131993. */
  131994. get skybox(): Nullable<Mesh>;
  131995. private _skyboxTexture;
  131996. /**
  131997. * Gets the skybox texture created by the helper.
  131998. */
  131999. get skyboxTexture(): Nullable<BaseTexture>;
  132000. private _skyboxMaterial;
  132001. /**
  132002. * Gets the skybox material created by the helper.
  132003. */
  132004. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  132005. private _ground;
  132006. /**
  132007. * Gets the ground mesh created by the helper.
  132008. */
  132009. get ground(): Nullable<Mesh>;
  132010. private _groundTexture;
  132011. /**
  132012. * Gets the ground texture created by the helper.
  132013. */
  132014. get groundTexture(): Nullable<BaseTexture>;
  132015. private _groundMirror;
  132016. /**
  132017. * Gets the ground mirror created by the helper.
  132018. */
  132019. get groundMirror(): Nullable<MirrorTexture>;
  132020. /**
  132021. * Gets the ground mirror render list to helps pushing the meshes
  132022. * you wish in the ground reflection.
  132023. */
  132024. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  132025. private _groundMaterial;
  132026. /**
  132027. * Gets the ground material created by the helper.
  132028. */
  132029. get groundMaterial(): Nullable<BackgroundMaterial>;
  132030. /**
  132031. * Stores the creation options.
  132032. */
  132033. private readonly _scene;
  132034. private _options;
  132035. /**
  132036. * This observable will be notified with any error during the creation of the environment,
  132037. * mainly texture creation errors.
  132038. */
  132039. onErrorObservable: Observable<{
  132040. message?: string;
  132041. exception?: any;
  132042. }>;
  132043. /**
  132044. * constructor
  132045. * @param options Defines the options we want to customize the helper
  132046. * @param scene The scene to add the material to
  132047. */
  132048. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  132049. /**
  132050. * Updates the background according to the new options
  132051. * @param options
  132052. */
  132053. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  132054. /**
  132055. * Sets the primary color of all the available elements.
  132056. * @param color the main color to affect to the ground and the background
  132057. */
  132058. setMainColor(color: Color3): void;
  132059. /**
  132060. * Setup the image processing according to the specified options.
  132061. */
  132062. private _setupImageProcessing;
  132063. /**
  132064. * Setup the environment texture according to the specified options.
  132065. */
  132066. private _setupEnvironmentTexture;
  132067. /**
  132068. * Setup the background according to the specified options.
  132069. */
  132070. private _setupBackground;
  132071. /**
  132072. * Get the scene sizes according to the setup.
  132073. */
  132074. private _getSceneSize;
  132075. /**
  132076. * Setup the ground according to the specified options.
  132077. */
  132078. private _setupGround;
  132079. /**
  132080. * Setup the ground material according to the specified options.
  132081. */
  132082. private _setupGroundMaterial;
  132083. /**
  132084. * Setup the ground diffuse texture according to the specified options.
  132085. */
  132086. private _setupGroundDiffuseTexture;
  132087. /**
  132088. * Setup the ground mirror texture according to the specified options.
  132089. */
  132090. private _setupGroundMirrorTexture;
  132091. /**
  132092. * Setup the ground to receive the mirror texture.
  132093. */
  132094. private _setupMirrorInGroundMaterial;
  132095. /**
  132096. * Setup the skybox according to the specified options.
  132097. */
  132098. private _setupSkybox;
  132099. /**
  132100. * Setup the skybox material according to the specified options.
  132101. */
  132102. private _setupSkyboxMaterial;
  132103. /**
  132104. * Setup the skybox reflection texture according to the specified options.
  132105. */
  132106. private _setupSkyboxReflectionTexture;
  132107. private _errorHandler;
  132108. /**
  132109. * Dispose all the elements created by the Helper.
  132110. */
  132111. dispose(): void;
  132112. }
  132113. }
  132114. declare module BABYLON {
  132115. /**
  132116. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  132117. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  132118. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  132119. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  132120. */
  132121. export class PhotoDome extends TransformNode {
  132122. /**
  132123. * Define the image as a Monoscopic panoramic 360 image.
  132124. */
  132125. static readonly MODE_MONOSCOPIC: number;
  132126. /**
  132127. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132128. */
  132129. static readonly MODE_TOPBOTTOM: number;
  132130. /**
  132131. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132132. */
  132133. static readonly MODE_SIDEBYSIDE: number;
  132134. private _useDirectMapping;
  132135. /**
  132136. * The texture being displayed on the sphere
  132137. */
  132138. protected _photoTexture: Texture;
  132139. /**
  132140. * Gets or sets the texture being displayed on the sphere
  132141. */
  132142. get photoTexture(): Texture;
  132143. set photoTexture(value: Texture);
  132144. /**
  132145. * Observable raised when an error occured while loading the 360 image
  132146. */
  132147. onLoadErrorObservable: Observable<string>;
  132148. /**
  132149. * The skybox material
  132150. */
  132151. protected _material: BackgroundMaterial;
  132152. /**
  132153. * The surface used for the skybox
  132154. */
  132155. protected _mesh: Mesh;
  132156. /**
  132157. * Gets the mesh used for the skybox.
  132158. */
  132159. get mesh(): Mesh;
  132160. /**
  132161. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132162. * Also see the options.resolution property.
  132163. */
  132164. get fovMultiplier(): number;
  132165. set fovMultiplier(value: number);
  132166. private _imageMode;
  132167. /**
  132168. * Gets or set the current video mode for the video. It can be:
  132169. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  132170. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132171. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132172. */
  132173. get imageMode(): number;
  132174. set imageMode(value: number);
  132175. /**
  132176. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  132177. * @param name Element's name, child elements will append suffixes for their own names.
  132178. * @param urlsOfPhoto defines the url of the photo to display
  132179. * @param options defines an object containing optional or exposed sub element properties
  132180. * @param onError defines a callback called when an error occured while loading the texture
  132181. */
  132182. constructor(name: string, urlOfPhoto: string, options: {
  132183. resolution?: number;
  132184. size?: number;
  132185. useDirectMapping?: boolean;
  132186. faceForward?: boolean;
  132187. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  132188. private _onBeforeCameraRenderObserver;
  132189. private _changeImageMode;
  132190. /**
  132191. * Releases resources associated with this node.
  132192. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  132193. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  132194. */
  132195. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  132196. }
  132197. }
  132198. declare module BABYLON {
  132199. /**
  132200. * Class used to host RGBD texture specific utilities
  132201. */
  132202. export class RGBDTextureTools {
  132203. /**
  132204. * Expand the RGBD Texture from RGBD to Half Float if possible.
  132205. * @param texture the texture to expand.
  132206. */
  132207. static ExpandRGBDTexture(texture: Texture): void;
  132208. }
  132209. }
  132210. declare module BABYLON {
  132211. /**
  132212. * Class used to host texture specific utilities
  132213. */
  132214. export class BRDFTextureTools {
  132215. /**
  132216. * Prevents texture cache collision
  132217. */
  132218. private static _instanceNumber;
  132219. /**
  132220. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  132221. * @param scene defines the hosting scene
  132222. * @returns the environment BRDF texture
  132223. */
  132224. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  132225. private static _environmentBRDFBase64Texture;
  132226. }
  132227. }
  132228. declare module BABYLON {
  132229. /**
  132230. * @hidden
  132231. */
  132232. export interface IMaterialClearCoatDefines {
  132233. CLEARCOAT: boolean;
  132234. CLEARCOAT_DEFAULTIOR: boolean;
  132235. CLEARCOAT_TEXTURE: boolean;
  132236. CLEARCOAT_TEXTUREDIRECTUV: number;
  132237. CLEARCOAT_BUMP: boolean;
  132238. CLEARCOAT_BUMPDIRECTUV: number;
  132239. CLEARCOAT_TINT: boolean;
  132240. CLEARCOAT_TINT_TEXTURE: boolean;
  132241. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  132242. /** @hidden */
  132243. _areTexturesDirty: boolean;
  132244. }
  132245. /**
  132246. * Define the code related to the clear coat parameters of the pbr material.
  132247. */
  132248. export class PBRClearCoatConfiguration {
  132249. /**
  132250. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  132251. * The default fits with a polyurethane material.
  132252. */
  132253. private static readonly _DefaultIndexOfRefraction;
  132254. private _isEnabled;
  132255. /**
  132256. * Defines if the clear coat is enabled in the material.
  132257. */
  132258. isEnabled: boolean;
  132259. /**
  132260. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  132261. */
  132262. intensity: number;
  132263. /**
  132264. * Defines the clear coat layer roughness.
  132265. */
  132266. roughness: number;
  132267. private _indexOfRefraction;
  132268. /**
  132269. * Defines the index of refraction of the clear coat.
  132270. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  132271. * The default fits with a polyurethane material.
  132272. * Changing the default value is more performance intensive.
  132273. */
  132274. indexOfRefraction: number;
  132275. private _texture;
  132276. /**
  132277. * Stores the clear coat values in a texture.
  132278. */
  132279. texture: Nullable<BaseTexture>;
  132280. private _bumpTexture;
  132281. /**
  132282. * Define the clear coat specific bump texture.
  132283. */
  132284. bumpTexture: Nullable<BaseTexture>;
  132285. private _isTintEnabled;
  132286. /**
  132287. * Defines if the clear coat tint is enabled in the material.
  132288. */
  132289. isTintEnabled: boolean;
  132290. /**
  132291. * Defines the clear coat tint of the material.
  132292. * This is only use if tint is enabled
  132293. */
  132294. tintColor: Color3;
  132295. /**
  132296. * Defines the distance at which the tint color should be found in the
  132297. * clear coat media.
  132298. * This is only use if tint is enabled
  132299. */
  132300. tintColorAtDistance: number;
  132301. /**
  132302. * Defines the clear coat layer thickness.
  132303. * This is only use if tint is enabled
  132304. */
  132305. tintThickness: number;
  132306. private _tintTexture;
  132307. /**
  132308. * Stores the clear tint values in a texture.
  132309. * rgb is tint
  132310. * a is a thickness factor
  132311. */
  132312. tintTexture: Nullable<BaseTexture>;
  132313. /** @hidden */
  132314. private _internalMarkAllSubMeshesAsTexturesDirty;
  132315. /** @hidden */
  132316. _markAllSubMeshesAsTexturesDirty(): void;
  132317. /**
  132318. * Instantiate a new istance of clear coat configuration.
  132319. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132320. */
  132321. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132322. /**
  132323. * Gets wehter the submesh is ready to be used or not.
  132324. * @param defines the list of "defines" to update.
  132325. * @param scene defines the scene the material belongs to.
  132326. * @param engine defines the engine the material belongs to.
  132327. * @param disableBumpMap defines wether the material disables bump or not.
  132328. * @returns - boolean indicating that the submesh is ready or not.
  132329. */
  132330. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  132331. /**
  132332. * Checks to see if a texture is used in the material.
  132333. * @param defines the list of "defines" to update.
  132334. * @param scene defines the scene to the material belongs to.
  132335. */
  132336. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  132337. /**
  132338. * Binds the material data.
  132339. * @param uniformBuffer defines the Uniform buffer to fill in.
  132340. * @param scene defines the scene the material belongs to.
  132341. * @param engine defines the engine the material belongs to.
  132342. * @param disableBumpMap defines wether the material disables bump or not.
  132343. * @param isFrozen defines wether the material is frozen or not.
  132344. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  132345. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  132346. */
  132347. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  132348. /**
  132349. * Checks to see if a texture is used in the material.
  132350. * @param texture - Base texture to use.
  132351. * @returns - Boolean specifying if a texture is used in the material.
  132352. */
  132353. hasTexture(texture: BaseTexture): boolean;
  132354. /**
  132355. * Returns an array of the actively used textures.
  132356. * @param activeTextures Array of BaseTextures
  132357. */
  132358. getActiveTextures(activeTextures: BaseTexture[]): void;
  132359. /**
  132360. * Returns the animatable textures.
  132361. * @param animatables Array of animatable textures.
  132362. */
  132363. getAnimatables(animatables: IAnimatable[]): void;
  132364. /**
  132365. * Disposes the resources of the material.
  132366. * @param forceDisposeTextures - Forces the disposal of all textures.
  132367. */
  132368. dispose(forceDisposeTextures?: boolean): void;
  132369. /**
  132370. * Get the current class name of the texture useful for serialization or dynamic coding.
  132371. * @returns "PBRClearCoatConfiguration"
  132372. */
  132373. getClassName(): string;
  132374. /**
  132375. * Add fallbacks to the effect fallbacks list.
  132376. * @param defines defines the Base texture to use.
  132377. * @param fallbacks defines the current fallback list.
  132378. * @param currentRank defines the current fallback rank.
  132379. * @returns the new fallback rank.
  132380. */
  132381. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132382. /**
  132383. * Add the required uniforms to the current list.
  132384. * @param uniforms defines the current uniform list.
  132385. */
  132386. static AddUniforms(uniforms: string[]): void;
  132387. /**
  132388. * Add the required samplers to the current list.
  132389. * @param samplers defines the current sampler list.
  132390. */
  132391. static AddSamplers(samplers: string[]): void;
  132392. /**
  132393. * Add the required uniforms to the current buffer.
  132394. * @param uniformBuffer defines the current uniform buffer.
  132395. */
  132396. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132397. /**
  132398. * Makes a duplicate of the current configuration into another one.
  132399. * @param clearCoatConfiguration define the config where to copy the info
  132400. */
  132401. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  132402. /**
  132403. * Serializes this clear coat configuration.
  132404. * @returns - An object with the serialized config.
  132405. */
  132406. serialize(): any;
  132407. /**
  132408. * Parses a anisotropy Configuration from a serialized object.
  132409. * @param source - Serialized object.
  132410. * @param scene Defines the scene we are parsing for
  132411. * @param rootUrl Defines the rootUrl to load from
  132412. */
  132413. parse(source: any, scene: Scene, rootUrl: string): void;
  132414. }
  132415. }
  132416. declare module BABYLON {
  132417. /**
  132418. * @hidden
  132419. */
  132420. export interface IMaterialAnisotropicDefines {
  132421. ANISOTROPIC: boolean;
  132422. ANISOTROPIC_TEXTURE: boolean;
  132423. ANISOTROPIC_TEXTUREDIRECTUV: number;
  132424. MAINUV1: boolean;
  132425. _areTexturesDirty: boolean;
  132426. _needUVs: boolean;
  132427. }
  132428. /**
  132429. * Define the code related to the anisotropic parameters of the pbr material.
  132430. */
  132431. export class PBRAnisotropicConfiguration {
  132432. private _isEnabled;
  132433. /**
  132434. * Defines if the anisotropy is enabled in the material.
  132435. */
  132436. isEnabled: boolean;
  132437. /**
  132438. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  132439. */
  132440. intensity: number;
  132441. /**
  132442. * Defines if the effect is along the tangents, bitangents or in between.
  132443. * By default, the effect is "strectching" the highlights along the tangents.
  132444. */
  132445. direction: Vector2;
  132446. private _texture;
  132447. /**
  132448. * Stores the anisotropy values in a texture.
  132449. * rg is direction (like normal from -1 to 1)
  132450. * b is a intensity
  132451. */
  132452. texture: Nullable<BaseTexture>;
  132453. /** @hidden */
  132454. private _internalMarkAllSubMeshesAsTexturesDirty;
  132455. /** @hidden */
  132456. _markAllSubMeshesAsTexturesDirty(): void;
  132457. /**
  132458. * Instantiate a new istance of anisotropy configuration.
  132459. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132460. */
  132461. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132462. /**
  132463. * Specifies that the submesh is ready to be used.
  132464. * @param defines the list of "defines" to update.
  132465. * @param scene defines the scene the material belongs to.
  132466. * @returns - boolean indicating that the submesh is ready or not.
  132467. */
  132468. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  132469. /**
  132470. * Checks to see if a texture is used in the material.
  132471. * @param defines the list of "defines" to update.
  132472. * @param mesh the mesh we are preparing the defines for.
  132473. * @param scene defines the scene the material belongs to.
  132474. */
  132475. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  132476. /**
  132477. * Binds the material data.
  132478. * @param uniformBuffer defines the Uniform buffer to fill in.
  132479. * @param scene defines the scene the material belongs to.
  132480. * @param isFrozen defines wether the material is frozen or not.
  132481. */
  132482. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132483. /**
  132484. * Checks to see if a texture is used in the material.
  132485. * @param texture - Base texture to use.
  132486. * @returns - Boolean specifying if a texture is used in the material.
  132487. */
  132488. hasTexture(texture: BaseTexture): boolean;
  132489. /**
  132490. * Returns an array of the actively used textures.
  132491. * @param activeTextures Array of BaseTextures
  132492. */
  132493. getActiveTextures(activeTextures: BaseTexture[]): void;
  132494. /**
  132495. * Returns the animatable textures.
  132496. * @param animatables Array of animatable textures.
  132497. */
  132498. getAnimatables(animatables: IAnimatable[]): void;
  132499. /**
  132500. * Disposes the resources of the material.
  132501. * @param forceDisposeTextures - Forces the disposal of all textures.
  132502. */
  132503. dispose(forceDisposeTextures?: boolean): void;
  132504. /**
  132505. * Get the current class name of the texture useful for serialization or dynamic coding.
  132506. * @returns "PBRAnisotropicConfiguration"
  132507. */
  132508. getClassName(): string;
  132509. /**
  132510. * Add fallbacks to the effect fallbacks list.
  132511. * @param defines defines the Base texture to use.
  132512. * @param fallbacks defines the current fallback list.
  132513. * @param currentRank defines the current fallback rank.
  132514. * @returns the new fallback rank.
  132515. */
  132516. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132517. /**
  132518. * Add the required uniforms to the current list.
  132519. * @param uniforms defines the current uniform list.
  132520. */
  132521. static AddUniforms(uniforms: string[]): void;
  132522. /**
  132523. * Add the required uniforms to the current buffer.
  132524. * @param uniformBuffer defines the current uniform buffer.
  132525. */
  132526. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132527. /**
  132528. * Add the required samplers to the current list.
  132529. * @param samplers defines the current sampler list.
  132530. */
  132531. static AddSamplers(samplers: string[]): void;
  132532. /**
  132533. * Makes a duplicate of the current configuration into another one.
  132534. * @param anisotropicConfiguration define the config where to copy the info
  132535. */
  132536. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  132537. /**
  132538. * Serializes this anisotropy configuration.
  132539. * @returns - An object with the serialized config.
  132540. */
  132541. serialize(): any;
  132542. /**
  132543. * Parses a anisotropy Configuration from a serialized object.
  132544. * @param source - Serialized object.
  132545. * @param scene Defines the scene we are parsing for
  132546. * @param rootUrl Defines the rootUrl to load from
  132547. */
  132548. parse(source: any, scene: Scene, rootUrl: string): void;
  132549. }
  132550. }
  132551. declare module BABYLON {
  132552. /**
  132553. * @hidden
  132554. */
  132555. export interface IMaterialBRDFDefines {
  132556. BRDF_V_HEIGHT_CORRELATED: boolean;
  132557. MS_BRDF_ENERGY_CONSERVATION: boolean;
  132558. SPHERICAL_HARMONICS: boolean;
  132559. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  132560. /** @hidden */
  132561. _areMiscDirty: boolean;
  132562. }
  132563. /**
  132564. * Define the code related to the BRDF parameters of the pbr material.
  132565. */
  132566. export class PBRBRDFConfiguration {
  132567. /**
  132568. * Default value used for the energy conservation.
  132569. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132570. */
  132571. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  132572. /**
  132573. * Default value used for the Smith Visibility Height Correlated mode.
  132574. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132575. */
  132576. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  132577. /**
  132578. * Default value used for the IBL diffuse part.
  132579. * This can help switching back to the polynomials mode globally which is a tiny bit
  132580. * less GPU intensive at the drawback of a lower quality.
  132581. */
  132582. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  132583. /**
  132584. * Default value used for activating energy conservation for the specular workflow.
  132585. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132586. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132587. */
  132588. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  132589. private _useEnergyConservation;
  132590. /**
  132591. * Defines if the material uses energy conservation.
  132592. */
  132593. useEnergyConservation: boolean;
  132594. private _useSmithVisibilityHeightCorrelated;
  132595. /**
  132596. * LEGACY Mode set to false
  132597. * Defines if the material uses height smith correlated visibility term.
  132598. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  132599. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  132600. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  132601. * Not relying on height correlated will also disable energy conservation.
  132602. */
  132603. useSmithVisibilityHeightCorrelated: boolean;
  132604. private _useSphericalHarmonics;
  132605. /**
  132606. * LEGACY Mode set to false
  132607. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  132608. * diffuse part of the IBL.
  132609. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  132610. * to the ground truth.
  132611. */
  132612. useSphericalHarmonics: boolean;
  132613. private _useSpecularGlossinessInputEnergyConservation;
  132614. /**
  132615. * Defines if the material uses energy conservation, when the specular workflow is active.
  132616. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132617. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132618. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  132619. */
  132620. useSpecularGlossinessInputEnergyConservation: boolean;
  132621. /** @hidden */
  132622. private _internalMarkAllSubMeshesAsMiscDirty;
  132623. /** @hidden */
  132624. _markAllSubMeshesAsMiscDirty(): void;
  132625. /**
  132626. * Instantiate a new istance of clear coat configuration.
  132627. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  132628. */
  132629. constructor(markAllSubMeshesAsMiscDirty: () => void);
  132630. /**
  132631. * Checks to see if a texture is used in the material.
  132632. * @param defines the list of "defines" to update.
  132633. */
  132634. prepareDefines(defines: IMaterialBRDFDefines): void;
  132635. /**
  132636. * Get the current class name of the texture useful for serialization or dynamic coding.
  132637. * @returns "PBRClearCoatConfiguration"
  132638. */
  132639. getClassName(): string;
  132640. /**
  132641. * Makes a duplicate of the current configuration into another one.
  132642. * @param brdfConfiguration define the config where to copy the info
  132643. */
  132644. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  132645. /**
  132646. * Serializes this BRDF configuration.
  132647. * @returns - An object with the serialized config.
  132648. */
  132649. serialize(): any;
  132650. /**
  132651. * Parses a anisotropy Configuration from a serialized object.
  132652. * @param source - Serialized object.
  132653. * @param scene Defines the scene we are parsing for
  132654. * @param rootUrl Defines the rootUrl to load from
  132655. */
  132656. parse(source: any, scene: Scene, rootUrl: string): void;
  132657. }
  132658. }
  132659. declare module BABYLON {
  132660. /**
  132661. * @hidden
  132662. */
  132663. export interface IMaterialSheenDefines {
  132664. SHEEN: boolean;
  132665. SHEEN_TEXTURE: boolean;
  132666. SHEEN_TEXTUREDIRECTUV: number;
  132667. SHEEN_LINKWITHALBEDO: boolean;
  132668. SHEEN_ROUGHNESS: boolean;
  132669. SHEEN_ALBEDOSCALING: boolean;
  132670. /** @hidden */
  132671. _areTexturesDirty: boolean;
  132672. }
  132673. /**
  132674. * Define the code related to the Sheen parameters of the pbr material.
  132675. */
  132676. export class PBRSheenConfiguration {
  132677. private _isEnabled;
  132678. /**
  132679. * Defines if the material uses sheen.
  132680. */
  132681. isEnabled: boolean;
  132682. private _linkSheenWithAlbedo;
  132683. /**
  132684. * Defines if the sheen is linked to the sheen color.
  132685. */
  132686. linkSheenWithAlbedo: boolean;
  132687. /**
  132688. * Defines the sheen intensity.
  132689. */
  132690. intensity: number;
  132691. /**
  132692. * Defines the sheen color.
  132693. */
  132694. color: Color3;
  132695. private _texture;
  132696. /**
  132697. * Stores the sheen tint values in a texture.
  132698. * rgb is tint
  132699. * a is a intensity or roughness if roughness has been defined
  132700. */
  132701. texture: Nullable<BaseTexture>;
  132702. private _roughness;
  132703. /**
  132704. * Defines the sheen roughness.
  132705. * It is not taken into account if linkSheenWithAlbedo is true.
  132706. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  132707. */
  132708. roughness: Nullable<number>;
  132709. private _albedoScaling;
  132710. /**
  132711. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  132712. * It allows the strength of the sheen effect to not depend on the base color of the material,
  132713. * making it easier to setup and tweak the effect
  132714. */
  132715. albedoScaling: boolean;
  132716. /** @hidden */
  132717. private _internalMarkAllSubMeshesAsTexturesDirty;
  132718. /** @hidden */
  132719. _markAllSubMeshesAsTexturesDirty(): void;
  132720. /**
  132721. * Instantiate a new istance of clear coat configuration.
  132722. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132723. */
  132724. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132725. /**
  132726. * Specifies that the submesh is ready to be used.
  132727. * @param defines the list of "defines" to update.
  132728. * @param scene defines the scene the material belongs to.
  132729. * @returns - boolean indicating that the submesh is ready or not.
  132730. */
  132731. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  132732. /**
  132733. * Checks to see if a texture is used in the material.
  132734. * @param defines the list of "defines" to update.
  132735. * @param scene defines the scene the material belongs to.
  132736. */
  132737. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  132738. /**
  132739. * Binds the material data.
  132740. * @param uniformBuffer defines the Uniform buffer to fill in.
  132741. * @param scene defines the scene the material belongs to.
  132742. * @param isFrozen defines wether the material is frozen or not.
  132743. */
  132744. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132745. /**
  132746. * Checks to see if a texture is used in the material.
  132747. * @param texture - Base texture to use.
  132748. * @returns - Boolean specifying if a texture is used in the material.
  132749. */
  132750. hasTexture(texture: BaseTexture): boolean;
  132751. /**
  132752. * Returns an array of the actively used textures.
  132753. * @param activeTextures Array of BaseTextures
  132754. */
  132755. getActiveTextures(activeTextures: BaseTexture[]): void;
  132756. /**
  132757. * Returns the animatable textures.
  132758. * @param animatables Array of animatable textures.
  132759. */
  132760. getAnimatables(animatables: IAnimatable[]): void;
  132761. /**
  132762. * Disposes the resources of the material.
  132763. * @param forceDisposeTextures - Forces the disposal of all textures.
  132764. */
  132765. dispose(forceDisposeTextures?: boolean): void;
  132766. /**
  132767. * Get the current class name of the texture useful for serialization or dynamic coding.
  132768. * @returns "PBRSheenConfiguration"
  132769. */
  132770. getClassName(): string;
  132771. /**
  132772. * Add fallbacks to the effect fallbacks list.
  132773. * @param defines defines the Base texture to use.
  132774. * @param fallbacks defines the current fallback list.
  132775. * @param currentRank defines the current fallback rank.
  132776. * @returns the new fallback rank.
  132777. */
  132778. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132779. /**
  132780. * Add the required uniforms to the current list.
  132781. * @param uniforms defines the current uniform list.
  132782. */
  132783. static AddUniforms(uniforms: string[]): void;
  132784. /**
  132785. * Add the required uniforms to the current buffer.
  132786. * @param uniformBuffer defines the current uniform buffer.
  132787. */
  132788. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132789. /**
  132790. * Add the required samplers to the current list.
  132791. * @param samplers defines the current sampler list.
  132792. */
  132793. static AddSamplers(samplers: string[]): void;
  132794. /**
  132795. * Makes a duplicate of the current configuration into another one.
  132796. * @param sheenConfiguration define the config where to copy the info
  132797. */
  132798. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  132799. /**
  132800. * Serializes this BRDF configuration.
  132801. * @returns - An object with the serialized config.
  132802. */
  132803. serialize(): any;
  132804. /**
  132805. * Parses a anisotropy Configuration from a serialized object.
  132806. * @param source - Serialized object.
  132807. * @param scene Defines the scene we are parsing for
  132808. * @param rootUrl Defines the rootUrl to load from
  132809. */
  132810. parse(source: any, scene: Scene, rootUrl: string): void;
  132811. }
  132812. }
  132813. declare module BABYLON {
  132814. /**
  132815. * @hidden
  132816. */
  132817. export interface IMaterialSubSurfaceDefines {
  132818. SUBSURFACE: boolean;
  132819. SS_REFRACTION: boolean;
  132820. SS_TRANSLUCENCY: boolean;
  132821. SS_SCATTERING: boolean;
  132822. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132823. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132824. SS_REFRACTIONMAP_3D: boolean;
  132825. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132826. SS_LODINREFRACTIONALPHA: boolean;
  132827. SS_GAMMAREFRACTION: boolean;
  132828. SS_RGBDREFRACTION: boolean;
  132829. SS_LINEARSPECULARREFRACTION: boolean;
  132830. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132831. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132832. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132833. /** @hidden */
  132834. _areTexturesDirty: boolean;
  132835. }
  132836. /**
  132837. * Define the code related to the sub surface parameters of the pbr material.
  132838. */
  132839. export class PBRSubSurfaceConfiguration {
  132840. private _isRefractionEnabled;
  132841. /**
  132842. * Defines if the refraction is enabled in the material.
  132843. */
  132844. isRefractionEnabled: boolean;
  132845. private _isTranslucencyEnabled;
  132846. /**
  132847. * Defines if the translucency is enabled in the material.
  132848. */
  132849. isTranslucencyEnabled: boolean;
  132850. private _isScatteringEnabled;
  132851. /**
  132852. * Defines if the sub surface scattering is enabled in the material.
  132853. */
  132854. isScatteringEnabled: boolean;
  132855. private _scatteringDiffusionProfileIndex;
  132856. /**
  132857. * Diffusion profile for subsurface scattering.
  132858. * Useful for better scattering in the skins or foliages.
  132859. */
  132860. get scatteringDiffusionProfile(): Nullable<Color3>;
  132861. set scatteringDiffusionProfile(c: Nullable<Color3>);
  132862. /**
  132863. * Defines the refraction intensity of the material.
  132864. * The refraction when enabled replaces the Diffuse part of the material.
  132865. * The intensity helps transitionning between diffuse and refraction.
  132866. */
  132867. refractionIntensity: number;
  132868. /**
  132869. * Defines the translucency intensity of the material.
  132870. * When translucency has been enabled, this defines how much of the "translucency"
  132871. * is addded to the diffuse part of the material.
  132872. */
  132873. translucencyIntensity: number;
  132874. /**
  132875. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  132876. */
  132877. useAlbedoToTintRefraction: boolean;
  132878. private _thicknessTexture;
  132879. /**
  132880. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  132881. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  132882. * 0 would mean minimumThickness
  132883. * 1 would mean maximumThickness
  132884. * The other channels might be use as a mask to vary the different effects intensity.
  132885. */
  132886. thicknessTexture: Nullable<BaseTexture>;
  132887. private _refractionTexture;
  132888. /**
  132889. * Defines the texture to use for refraction.
  132890. */
  132891. refractionTexture: Nullable<BaseTexture>;
  132892. private _indexOfRefraction;
  132893. /**
  132894. * Index of refraction of the material base layer.
  132895. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132896. *
  132897. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132898. *
  132899. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132900. */
  132901. indexOfRefraction: number;
  132902. private _volumeIndexOfRefraction;
  132903. /**
  132904. * Index of refraction of the material's volume.
  132905. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132906. *
  132907. * This ONLY impacts refraction. If not provided or given a non-valid value,
  132908. * the volume will use the same IOR as the surface.
  132909. */
  132910. get volumeIndexOfRefraction(): number;
  132911. set volumeIndexOfRefraction(value: number);
  132912. private _invertRefractionY;
  132913. /**
  132914. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132915. */
  132916. invertRefractionY: boolean;
  132917. private _linkRefractionWithTransparency;
  132918. /**
  132919. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132920. * Materials half opaque for instance using refraction could benefit from this control.
  132921. */
  132922. linkRefractionWithTransparency: boolean;
  132923. /**
  132924. * Defines the minimum thickness stored in the thickness map.
  132925. * If no thickness map is defined, this value will be used to simulate thickness.
  132926. */
  132927. minimumThickness: number;
  132928. /**
  132929. * Defines the maximum thickness stored in the thickness map.
  132930. */
  132931. maximumThickness: number;
  132932. /**
  132933. * Defines the volume tint of the material.
  132934. * This is used for both translucency and scattering.
  132935. */
  132936. tintColor: Color3;
  132937. /**
  132938. * Defines the distance at which the tint color should be found in the media.
  132939. * This is used for refraction only.
  132940. */
  132941. tintColorAtDistance: number;
  132942. /**
  132943. * Defines how far each channel transmit through the media.
  132944. * It is defined as a color to simplify it selection.
  132945. */
  132946. diffusionDistance: Color3;
  132947. private _useMaskFromThicknessTexture;
  132948. /**
  132949. * Stores the intensity of the different subsurface effects in the thickness texture.
  132950. * * the green channel is the translucency intensity.
  132951. * * the blue channel is the scattering intensity.
  132952. * * the alpha channel is the refraction intensity.
  132953. */
  132954. useMaskFromThicknessTexture: boolean;
  132955. private _scene;
  132956. /** @hidden */
  132957. private _internalMarkAllSubMeshesAsTexturesDirty;
  132958. private _internalMarkScenePrePassDirty;
  132959. /** @hidden */
  132960. _markAllSubMeshesAsTexturesDirty(): void;
  132961. /** @hidden */
  132962. _markScenePrePassDirty(): void;
  132963. /**
  132964. * Instantiate a new istance of sub surface configuration.
  132965. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132966. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  132967. * @param scene The scene
  132968. */
  132969. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  132970. /**
  132971. * Gets wehter the submesh is ready to be used or not.
  132972. * @param defines the list of "defines" to update.
  132973. * @param scene defines the scene the material belongs to.
  132974. * @returns - boolean indicating that the submesh is ready or not.
  132975. */
  132976. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  132977. /**
  132978. * Checks to see if a texture is used in the material.
  132979. * @param defines the list of "defines" to update.
  132980. * @param scene defines the scene to the material belongs to.
  132981. */
  132982. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  132983. /**
  132984. * Binds the material data.
  132985. * @param uniformBuffer defines the Uniform buffer to fill in.
  132986. * @param scene defines the scene the material belongs to.
  132987. * @param engine defines the engine the material belongs to.
  132988. * @param isFrozen defines whether the material is frozen or not.
  132989. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  132990. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  132991. */
  132992. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  132993. /**
  132994. * Unbinds the material from the mesh.
  132995. * @param activeEffect defines the effect that should be unbound from.
  132996. * @returns true if unbound, otherwise false
  132997. */
  132998. unbind(activeEffect: Effect): boolean;
  132999. /**
  133000. * Returns the texture used for refraction or null if none is used.
  133001. * @param scene defines the scene the material belongs to.
  133002. * @returns - Refraction texture if present. If no refraction texture and refraction
  133003. * is linked with transparency, returns environment texture. Otherwise, returns null.
  133004. */
  133005. private _getRefractionTexture;
  133006. /**
  133007. * Returns true if alpha blending should be disabled.
  133008. */
  133009. get disableAlphaBlending(): boolean;
  133010. /**
  133011. * Fills the list of render target textures.
  133012. * @param renderTargets the list of render targets to update
  133013. */
  133014. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  133015. /**
  133016. * Checks to see if a texture is used in the material.
  133017. * @param texture - Base texture to use.
  133018. * @returns - Boolean specifying if a texture is used in the material.
  133019. */
  133020. hasTexture(texture: BaseTexture): boolean;
  133021. /**
  133022. * Gets a boolean indicating that current material needs to register RTT
  133023. * @returns true if this uses a render target otherwise false.
  133024. */
  133025. hasRenderTargetTextures(): boolean;
  133026. /**
  133027. * Returns an array of the actively used textures.
  133028. * @param activeTextures Array of BaseTextures
  133029. */
  133030. getActiveTextures(activeTextures: BaseTexture[]): void;
  133031. /**
  133032. * Returns the animatable textures.
  133033. * @param animatables Array of animatable textures.
  133034. */
  133035. getAnimatables(animatables: IAnimatable[]): void;
  133036. /**
  133037. * Disposes the resources of the material.
  133038. * @param forceDisposeTextures - Forces the disposal of all textures.
  133039. */
  133040. dispose(forceDisposeTextures?: boolean): void;
  133041. /**
  133042. * Get the current class name of the texture useful for serialization or dynamic coding.
  133043. * @returns "PBRSubSurfaceConfiguration"
  133044. */
  133045. getClassName(): string;
  133046. /**
  133047. * Add fallbacks to the effect fallbacks list.
  133048. * @param defines defines the Base texture to use.
  133049. * @param fallbacks defines the current fallback list.
  133050. * @param currentRank defines the current fallback rank.
  133051. * @returns the new fallback rank.
  133052. */
  133053. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133054. /**
  133055. * Add the required uniforms to the current list.
  133056. * @param uniforms defines the current uniform list.
  133057. */
  133058. static AddUniforms(uniforms: string[]): void;
  133059. /**
  133060. * Add the required samplers to the current list.
  133061. * @param samplers defines the current sampler list.
  133062. */
  133063. static AddSamplers(samplers: string[]): void;
  133064. /**
  133065. * Add the required uniforms to the current buffer.
  133066. * @param uniformBuffer defines the current uniform buffer.
  133067. */
  133068. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133069. /**
  133070. * Makes a duplicate of the current configuration into another one.
  133071. * @param configuration define the config where to copy the info
  133072. */
  133073. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  133074. /**
  133075. * Serializes this Sub Surface configuration.
  133076. * @returns - An object with the serialized config.
  133077. */
  133078. serialize(): any;
  133079. /**
  133080. * Parses a anisotropy Configuration from a serialized object.
  133081. * @param source - Serialized object.
  133082. * @param scene Defines the scene we are parsing for
  133083. * @param rootUrl Defines the rootUrl to load from
  133084. */
  133085. parse(source: any, scene: Scene, rootUrl: string): void;
  133086. }
  133087. }
  133088. declare module BABYLON {
  133089. /** @hidden */
  133090. export var prePassDeclaration: {
  133091. name: string;
  133092. shader: string;
  133093. };
  133094. }
  133095. declare module BABYLON {
  133096. /** @hidden */
  133097. export var pbrFragmentDeclaration: {
  133098. name: string;
  133099. shader: string;
  133100. };
  133101. }
  133102. declare module BABYLON {
  133103. /** @hidden */
  133104. export var pbrUboDeclaration: {
  133105. name: string;
  133106. shader: string;
  133107. };
  133108. }
  133109. declare module BABYLON {
  133110. /** @hidden */
  133111. export var pbrFragmentExtraDeclaration: {
  133112. name: string;
  133113. shader: string;
  133114. };
  133115. }
  133116. declare module BABYLON {
  133117. /** @hidden */
  133118. export var pbrFragmentSamplersDeclaration: {
  133119. name: string;
  133120. shader: string;
  133121. };
  133122. }
  133123. declare module BABYLON {
  133124. /** @hidden */
  133125. export var subSurfaceScatteringFunctions: {
  133126. name: string;
  133127. shader: string;
  133128. };
  133129. }
  133130. declare module BABYLON {
  133131. /** @hidden */
  133132. export var importanceSampling: {
  133133. name: string;
  133134. shader: string;
  133135. };
  133136. }
  133137. declare module BABYLON {
  133138. /** @hidden */
  133139. export var pbrHelperFunctions: {
  133140. name: string;
  133141. shader: string;
  133142. };
  133143. }
  133144. declare module BABYLON {
  133145. /** @hidden */
  133146. export var harmonicsFunctions: {
  133147. name: string;
  133148. shader: string;
  133149. };
  133150. }
  133151. declare module BABYLON {
  133152. /** @hidden */
  133153. export var pbrDirectLightingSetupFunctions: {
  133154. name: string;
  133155. shader: string;
  133156. };
  133157. }
  133158. declare module BABYLON {
  133159. /** @hidden */
  133160. export var pbrDirectLightingFalloffFunctions: {
  133161. name: string;
  133162. shader: string;
  133163. };
  133164. }
  133165. declare module BABYLON {
  133166. /** @hidden */
  133167. export var pbrBRDFFunctions: {
  133168. name: string;
  133169. shader: string;
  133170. };
  133171. }
  133172. declare module BABYLON {
  133173. /** @hidden */
  133174. export var hdrFilteringFunctions: {
  133175. name: string;
  133176. shader: string;
  133177. };
  133178. }
  133179. declare module BABYLON {
  133180. /** @hidden */
  133181. export var pbrDirectLightingFunctions: {
  133182. name: string;
  133183. shader: string;
  133184. };
  133185. }
  133186. declare module BABYLON {
  133187. /** @hidden */
  133188. export var pbrIBLFunctions: {
  133189. name: string;
  133190. shader: string;
  133191. };
  133192. }
  133193. declare module BABYLON {
  133194. /** @hidden */
  133195. export var pbrBlockAlbedoOpacity: {
  133196. name: string;
  133197. shader: string;
  133198. };
  133199. }
  133200. declare module BABYLON {
  133201. /** @hidden */
  133202. export var pbrBlockReflectivity: {
  133203. name: string;
  133204. shader: string;
  133205. };
  133206. }
  133207. declare module BABYLON {
  133208. /** @hidden */
  133209. export var pbrBlockAmbientOcclusion: {
  133210. name: string;
  133211. shader: string;
  133212. };
  133213. }
  133214. declare module BABYLON {
  133215. /** @hidden */
  133216. export var pbrBlockAlphaFresnel: {
  133217. name: string;
  133218. shader: string;
  133219. };
  133220. }
  133221. declare module BABYLON {
  133222. /** @hidden */
  133223. export var pbrBlockAnisotropic: {
  133224. name: string;
  133225. shader: string;
  133226. };
  133227. }
  133228. declare module BABYLON {
  133229. /** @hidden */
  133230. export var pbrBlockReflection: {
  133231. name: string;
  133232. shader: string;
  133233. };
  133234. }
  133235. declare module BABYLON {
  133236. /** @hidden */
  133237. export var pbrBlockSheen: {
  133238. name: string;
  133239. shader: string;
  133240. };
  133241. }
  133242. declare module BABYLON {
  133243. /** @hidden */
  133244. export var pbrBlockClearcoat: {
  133245. name: string;
  133246. shader: string;
  133247. };
  133248. }
  133249. declare module BABYLON {
  133250. /** @hidden */
  133251. export var pbrBlockSubSurface: {
  133252. name: string;
  133253. shader: string;
  133254. };
  133255. }
  133256. declare module BABYLON {
  133257. /** @hidden */
  133258. export var pbrBlockNormalGeometric: {
  133259. name: string;
  133260. shader: string;
  133261. };
  133262. }
  133263. declare module BABYLON {
  133264. /** @hidden */
  133265. export var pbrBlockNormalFinal: {
  133266. name: string;
  133267. shader: string;
  133268. };
  133269. }
  133270. declare module BABYLON {
  133271. /** @hidden */
  133272. export var pbrBlockGeometryInfo: {
  133273. name: string;
  133274. shader: string;
  133275. };
  133276. }
  133277. declare module BABYLON {
  133278. /** @hidden */
  133279. export var pbrBlockReflectance0: {
  133280. name: string;
  133281. shader: string;
  133282. };
  133283. }
  133284. declare module BABYLON {
  133285. /** @hidden */
  133286. export var pbrBlockReflectance: {
  133287. name: string;
  133288. shader: string;
  133289. };
  133290. }
  133291. declare module BABYLON {
  133292. /** @hidden */
  133293. export var pbrBlockDirectLighting: {
  133294. name: string;
  133295. shader: string;
  133296. };
  133297. }
  133298. declare module BABYLON {
  133299. /** @hidden */
  133300. export var pbrBlockFinalLitComponents: {
  133301. name: string;
  133302. shader: string;
  133303. };
  133304. }
  133305. declare module BABYLON {
  133306. /** @hidden */
  133307. export var pbrBlockFinalUnlitComponents: {
  133308. name: string;
  133309. shader: string;
  133310. };
  133311. }
  133312. declare module BABYLON {
  133313. /** @hidden */
  133314. export var pbrBlockFinalColorComposition: {
  133315. name: string;
  133316. shader: string;
  133317. };
  133318. }
  133319. declare module BABYLON {
  133320. /** @hidden */
  133321. export var pbrBlockImageProcessing: {
  133322. name: string;
  133323. shader: string;
  133324. };
  133325. }
  133326. declare module BABYLON {
  133327. /** @hidden */
  133328. export var pbrDebug: {
  133329. name: string;
  133330. shader: string;
  133331. };
  133332. }
  133333. declare module BABYLON {
  133334. /** @hidden */
  133335. export var pbrPixelShader: {
  133336. name: string;
  133337. shader: string;
  133338. };
  133339. }
  133340. declare module BABYLON {
  133341. /** @hidden */
  133342. export var pbrVertexDeclaration: {
  133343. name: string;
  133344. shader: string;
  133345. };
  133346. }
  133347. declare module BABYLON {
  133348. /** @hidden */
  133349. export var pbrVertexShader: {
  133350. name: string;
  133351. shader: string;
  133352. };
  133353. }
  133354. declare module BABYLON {
  133355. /**
  133356. * Manages the defines for the PBR Material.
  133357. * @hidden
  133358. */
  133359. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  133360. PBR: boolean;
  133361. NUM_SAMPLES: string;
  133362. REALTIME_FILTERING: boolean;
  133363. MAINUV1: boolean;
  133364. MAINUV2: boolean;
  133365. UV1: boolean;
  133366. UV2: boolean;
  133367. ALBEDO: boolean;
  133368. GAMMAALBEDO: boolean;
  133369. ALBEDODIRECTUV: number;
  133370. VERTEXCOLOR: boolean;
  133371. DETAIL: boolean;
  133372. DETAILDIRECTUV: number;
  133373. DETAIL_NORMALBLENDMETHOD: number;
  133374. AMBIENT: boolean;
  133375. AMBIENTDIRECTUV: number;
  133376. AMBIENTINGRAYSCALE: boolean;
  133377. OPACITY: boolean;
  133378. VERTEXALPHA: boolean;
  133379. OPACITYDIRECTUV: number;
  133380. OPACITYRGB: boolean;
  133381. ALPHATEST: boolean;
  133382. DEPTHPREPASS: boolean;
  133383. ALPHABLEND: boolean;
  133384. ALPHAFROMALBEDO: boolean;
  133385. ALPHATESTVALUE: string;
  133386. SPECULAROVERALPHA: boolean;
  133387. RADIANCEOVERALPHA: boolean;
  133388. ALPHAFRESNEL: boolean;
  133389. LINEARALPHAFRESNEL: boolean;
  133390. PREMULTIPLYALPHA: boolean;
  133391. EMISSIVE: boolean;
  133392. EMISSIVEDIRECTUV: number;
  133393. REFLECTIVITY: boolean;
  133394. REFLECTIVITYDIRECTUV: number;
  133395. SPECULARTERM: boolean;
  133396. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  133397. MICROSURFACEAUTOMATIC: boolean;
  133398. LODBASEDMICROSFURACE: boolean;
  133399. MICROSURFACEMAP: boolean;
  133400. MICROSURFACEMAPDIRECTUV: number;
  133401. METALLICWORKFLOW: boolean;
  133402. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  133403. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  133404. METALLNESSSTOREINMETALMAPBLUE: boolean;
  133405. AOSTOREINMETALMAPRED: boolean;
  133406. METALLIC_REFLECTANCE: boolean;
  133407. METALLIC_REFLECTANCEDIRECTUV: number;
  133408. ENVIRONMENTBRDF: boolean;
  133409. ENVIRONMENTBRDF_RGBD: boolean;
  133410. NORMAL: boolean;
  133411. TANGENT: boolean;
  133412. BUMP: boolean;
  133413. BUMPDIRECTUV: number;
  133414. OBJECTSPACE_NORMALMAP: boolean;
  133415. PARALLAX: boolean;
  133416. PARALLAXOCCLUSION: boolean;
  133417. NORMALXYSCALE: boolean;
  133418. LIGHTMAP: boolean;
  133419. LIGHTMAPDIRECTUV: number;
  133420. USELIGHTMAPASSHADOWMAP: boolean;
  133421. GAMMALIGHTMAP: boolean;
  133422. RGBDLIGHTMAP: boolean;
  133423. REFLECTION: boolean;
  133424. REFLECTIONMAP_3D: boolean;
  133425. REFLECTIONMAP_SPHERICAL: boolean;
  133426. REFLECTIONMAP_PLANAR: boolean;
  133427. REFLECTIONMAP_CUBIC: boolean;
  133428. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  133429. REFLECTIONMAP_PROJECTION: boolean;
  133430. REFLECTIONMAP_SKYBOX: boolean;
  133431. REFLECTIONMAP_EXPLICIT: boolean;
  133432. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  133433. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  133434. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  133435. INVERTCUBICMAP: boolean;
  133436. USESPHERICALFROMREFLECTIONMAP: boolean;
  133437. USEIRRADIANCEMAP: boolean;
  133438. SPHERICAL_HARMONICS: boolean;
  133439. USESPHERICALINVERTEX: boolean;
  133440. REFLECTIONMAP_OPPOSITEZ: boolean;
  133441. LODINREFLECTIONALPHA: boolean;
  133442. GAMMAREFLECTION: boolean;
  133443. RGBDREFLECTION: boolean;
  133444. LINEARSPECULARREFLECTION: boolean;
  133445. RADIANCEOCCLUSION: boolean;
  133446. HORIZONOCCLUSION: boolean;
  133447. INSTANCES: boolean;
  133448. THIN_INSTANCES: boolean;
  133449. PREPASS: boolean;
  133450. SCENE_MRT_COUNT: number;
  133451. NUM_BONE_INFLUENCERS: number;
  133452. BonesPerMesh: number;
  133453. BONETEXTURE: boolean;
  133454. NONUNIFORMSCALING: boolean;
  133455. MORPHTARGETS: boolean;
  133456. MORPHTARGETS_NORMAL: boolean;
  133457. MORPHTARGETS_TANGENT: boolean;
  133458. MORPHTARGETS_UV: boolean;
  133459. NUM_MORPH_INFLUENCERS: number;
  133460. IMAGEPROCESSING: boolean;
  133461. VIGNETTE: boolean;
  133462. VIGNETTEBLENDMODEMULTIPLY: boolean;
  133463. VIGNETTEBLENDMODEOPAQUE: boolean;
  133464. TONEMAPPING: boolean;
  133465. TONEMAPPING_ACES: boolean;
  133466. CONTRAST: boolean;
  133467. COLORCURVES: boolean;
  133468. COLORGRADING: boolean;
  133469. COLORGRADING3D: boolean;
  133470. SAMPLER3DGREENDEPTH: boolean;
  133471. SAMPLER3DBGRMAP: boolean;
  133472. IMAGEPROCESSINGPOSTPROCESS: boolean;
  133473. EXPOSURE: boolean;
  133474. MULTIVIEW: boolean;
  133475. USEPHYSICALLIGHTFALLOFF: boolean;
  133476. USEGLTFLIGHTFALLOFF: boolean;
  133477. TWOSIDEDLIGHTING: boolean;
  133478. SHADOWFLOAT: boolean;
  133479. CLIPPLANE: boolean;
  133480. CLIPPLANE2: boolean;
  133481. CLIPPLANE3: boolean;
  133482. CLIPPLANE4: boolean;
  133483. CLIPPLANE5: boolean;
  133484. CLIPPLANE6: boolean;
  133485. POINTSIZE: boolean;
  133486. FOG: boolean;
  133487. LOGARITHMICDEPTH: boolean;
  133488. FORCENORMALFORWARD: boolean;
  133489. SPECULARAA: boolean;
  133490. CLEARCOAT: boolean;
  133491. CLEARCOAT_DEFAULTIOR: boolean;
  133492. CLEARCOAT_TEXTURE: boolean;
  133493. CLEARCOAT_TEXTUREDIRECTUV: number;
  133494. CLEARCOAT_BUMP: boolean;
  133495. CLEARCOAT_BUMPDIRECTUV: number;
  133496. CLEARCOAT_TINT: boolean;
  133497. CLEARCOAT_TINT_TEXTURE: boolean;
  133498. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133499. ANISOTROPIC: boolean;
  133500. ANISOTROPIC_TEXTURE: boolean;
  133501. ANISOTROPIC_TEXTUREDIRECTUV: number;
  133502. BRDF_V_HEIGHT_CORRELATED: boolean;
  133503. MS_BRDF_ENERGY_CONSERVATION: boolean;
  133504. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  133505. SHEEN: boolean;
  133506. SHEEN_TEXTURE: boolean;
  133507. SHEEN_TEXTUREDIRECTUV: number;
  133508. SHEEN_LINKWITHALBEDO: boolean;
  133509. SHEEN_ROUGHNESS: boolean;
  133510. SHEEN_ALBEDOSCALING: boolean;
  133511. SUBSURFACE: boolean;
  133512. SS_REFRACTION: boolean;
  133513. SS_TRANSLUCENCY: boolean;
  133514. SS_SCATTERING: boolean;
  133515. SS_THICKNESSANDMASK_TEXTURE: boolean;
  133516. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  133517. SS_REFRACTIONMAP_3D: boolean;
  133518. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  133519. SS_LODINREFRACTIONALPHA: boolean;
  133520. SS_GAMMAREFRACTION: boolean;
  133521. SS_RGBDREFRACTION: boolean;
  133522. SS_LINEARSPECULARREFRACTION: boolean;
  133523. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  133524. SS_ALBEDOFORREFRACTIONTINT: boolean;
  133525. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  133526. UNLIT: boolean;
  133527. DEBUGMODE: number;
  133528. /**
  133529. * Initializes the PBR Material defines.
  133530. */
  133531. constructor();
  133532. /**
  133533. * Resets the PBR Material defines.
  133534. */
  133535. reset(): void;
  133536. }
  133537. /**
  133538. * The Physically based material base class of BJS.
  133539. *
  133540. * This offers the main features of a standard PBR material.
  133541. * For more information, please refer to the documentation :
  133542. * https://doc.babylonjs.com/how_to/physically_based_rendering
  133543. */
  133544. export abstract class PBRBaseMaterial extends PushMaterial {
  133545. /**
  133546. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  133547. */
  133548. static readonly PBRMATERIAL_OPAQUE: number;
  133549. /**
  133550. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  133551. */
  133552. static readonly PBRMATERIAL_ALPHATEST: number;
  133553. /**
  133554. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133555. */
  133556. static readonly PBRMATERIAL_ALPHABLEND: number;
  133557. /**
  133558. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133559. * They are also discarded below the alpha cutoff threshold to improve performances.
  133560. */
  133561. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  133562. /**
  133563. * Defines the default value of how much AO map is occluding the analytical lights
  133564. * (point spot...).
  133565. */
  133566. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  133567. /**
  133568. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  133569. */
  133570. static readonly LIGHTFALLOFF_PHYSICAL: number;
  133571. /**
  133572. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  133573. * to enhance interoperability with other engines.
  133574. */
  133575. static readonly LIGHTFALLOFF_GLTF: number;
  133576. /**
  133577. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  133578. * to enhance interoperability with other materials.
  133579. */
  133580. static readonly LIGHTFALLOFF_STANDARD: number;
  133581. /**
  133582. * Intensity of the direct lights e.g. the four lights available in your scene.
  133583. * This impacts both the direct diffuse and specular highlights.
  133584. */
  133585. protected _directIntensity: number;
  133586. /**
  133587. * Intensity of the emissive part of the material.
  133588. * This helps controlling the emissive effect without modifying the emissive color.
  133589. */
  133590. protected _emissiveIntensity: number;
  133591. /**
  133592. * Intensity of the environment e.g. how much the environment will light the object
  133593. * either through harmonics for rough material or through the refelction for shiny ones.
  133594. */
  133595. protected _environmentIntensity: number;
  133596. /**
  133597. * This is a special control allowing the reduction of the specular highlights coming from the
  133598. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  133599. */
  133600. protected _specularIntensity: number;
  133601. /**
  133602. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  133603. */
  133604. private _lightingInfos;
  133605. /**
  133606. * Debug Control allowing disabling the bump map on this material.
  133607. */
  133608. protected _disableBumpMap: boolean;
  133609. /**
  133610. * AKA Diffuse Texture in standard nomenclature.
  133611. */
  133612. protected _albedoTexture: Nullable<BaseTexture>;
  133613. /**
  133614. * AKA Occlusion Texture in other nomenclature.
  133615. */
  133616. protected _ambientTexture: Nullable<BaseTexture>;
  133617. /**
  133618. * AKA Occlusion Texture Intensity in other nomenclature.
  133619. */
  133620. protected _ambientTextureStrength: number;
  133621. /**
  133622. * Defines how much the AO map is occluding the analytical lights (point spot...).
  133623. * 1 means it completely occludes it
  133624. * 0 mean it has no impact
  133625. */
  133626. protected _ambientTextureImpactOnAnalyticalLights: number;
  133627. /**
  133628. * Stores the alpha values in a texture.
  133629. */
  133630. protected _opacityTexture: Nullable<BaseTexture>;
  133631. /**
  133632. * Stores the reflection values in a texture.
  133633. */
  133634. protected _reflectionTexture: Nullable<BaseTexture>;
  133635. /**
  133636. * Stores the emissive values in a texture.
  133637. */
  133638. protected _emissiveTexture: Nullable<BaseTexture>;
  133639. /**
  133640. * AKA Specular texture in other nomenclature.
  133641. */
  133642. protected _reflectivityTexture: Nullable<BaseTexture>;
  133643. /**
  133644. * Used to switch from specular/glossiness to metallic/roughness workflow.
  133645. */
  133646. protected _metallicTexture: Nullable<BaseTexture>;
  133647. /**
  133648. * Specifies the metallic scalar of the metallic/roughness workflow.
  133649. * Can also be used to scale the metalness values of the metallic texture.
  133650. */
  133651. protected _metallic: Nullable<number>;
  133652. /**
  133653. * Specifies the roughness scalar of the metallic/roughness workflow.
  133654. * Can also be used to scale the roughness values of the metallic texture.
  133655. */
  133656. protected _roughness: Nullable<number>;
  133657. /**
  133658. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  133659. * By default the indexOfrefraction is used to compute F0;
  133660. *
  133661. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  133662. *
  133663. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  133664. * F90 = metallicReflectanceColor;
  133665. */
  133666. protected _metallicF0Factor: number;
  133667. /**
  133668. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  133669. * By default the F90 is always 1;
  133670. *
  133671. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  133672. *
  133673. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  133674. * F90 = metallicReflectanceColor;
  133675. */
  133676. protected _metallicReflectanceColor: Color3;
  133677. /**
  133678. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  133679. * This is multiply against the scalar values defined in the material.
  133680. */
  133681. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  133682. /**
  133683. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  133684. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  133685. */
  133686. protected _microSurfaceTexture: Nullable<BaseTexture>;
  133687. /**
  133688. * Stores surface normal data used to displace a mesh in a texture.
  133689. */
  133690. protected _bumpTexture: Nullable<BaseTexture>;
  133691. /**
  133692. * Stores the pre-calculated light information of a mesh in a texture.
  133693. */
  133694. protected _lightmapTexture: Nullable<BaseTexture>;
  133695. /**
  133696. * The color of a material in ambient lighting.
  133697. */
  133698. protected _ambientColor: Color3;
  133699. /**
  133700. * AKA Diffuse Color in other nomenclature.
  133701. */
  133702. protected _albedoColor: Color3;
  133703. /**
  133704. * AKA Specular Color in other nomenclature.
  133705. */
  133706. protected _reflectivityColor: Color3;
  133707. /**
  133708. * The color applied when light is reflected from a material.
  133709. */
  133710. protected _reflectionColor: Color3;
  133711. /**
  133712. * The color applied when light is emitted from a material.
  133713. */
  133714. protected _emissiveColor: Color3;
  133715. /**
  133716. * AKA Glossiness in other nomenclature.
  133717. */
  133718. protected _microSurface: number;
  133719. /**
  133720. * Specifies that the material will use the light map as a show map.
  133721. */
  133722. protected _useLightmapAsShadowmap: boolean;
  133723. /**
  133724. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133725. * makes the reflect vector face the model (under horizon).
  133726. */
  133727. protected _useHorizonOcclusion: boolean;
  133728. /**
  133729. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133730. * too much the area relying on ambient texture to define their ambient occlusion.
  133731. */
  133732. protected _useRadianceOcclusion: boolean;
  133733. /**
  133734. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133735. */
  133736. protected _useAlphaFromAlbedoTexture: boolean;
  133737. /**
  133738. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  133739. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133740. */
  133741. protected _useSpecularOverAlpha: boolean;
  133742. /**
  133743. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133744. */
  133745. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133746. /**
  133747. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133748. */
  133749. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  133750. /**
  133751. * Specifies if the metallic texture contains the roughness information in its green channel.
  133752. */
  133753. protected _useRoughnessFromMetallicTextureGreen: boolean;
  133754. /**
  133755. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133756. */
  133757. protected _useMetallnessFromMetallicTextureBlue: boolean;
  133758. /**
  133759. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133760. */
  133761. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  133762. /**
  133763. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133764. */
  133765. protected _useAmbientInGrayScale: boolean;
  133766. /**
  133767. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133768. * The material will try to infer what glossiness each pixel should be.
  133769. */
  133770. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  133771. /**
  133772. * Defines the falloff type used in this material.
  133773. * It by default is Physical.
  133774. */
  133775. protected _lightFalloff: number;
  133776. /**
  133777. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133778. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133779. */
  133780. protected _useRadianceOverAlpha: boolean;
  133781. /**
  133782. * Allows using an object space normal map (instead of tangent space).
  133783. */
  133784. protected _useObjectSpaceNormalMap: boolean;
  133785. /**
  133786. * Allows using the bump map in parallax mode.
  133787. */
  133788. protected _useParallax: boolean;
  133789. /**
  133790. * Allows using the bump map in parallax occlusion mode.
  133791. */
  133792. protected _useParallaxOcclusion: boolean;
  133793. /**
  133794. * Controls the scale bias of the parallax mode.
  133795. */
  133796. protected _parallaxScaleBias: number;
  133797. /**
  133798. * If sets to true, disables all the lights affecting the material.
  133799. */
  133800. protected _disableLighting: boolean;
  133801. /**
  133802. * Number of Simultaneous lights allowed on the material.
  133803. */
  133804. protected _maxSimultaneousLights: number;
  133805. /**
  133806. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133807. */
  133808. protected _invertNormalMapX: boolean;
  133809. /**
  133810. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133811. */
  133812. protected _invertNormalMapY: boolean;
  133813. /**
  133814. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133815. */
  133816. protected _twoSidedLighting: boolean;
  133817. /**
  133818. * Defines the alpha limits in alpha test mode.
  133819. */
  133820. protected _alphaCutOff: number;
  133821. /**
  133822. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133823. */
  133824. protected _forceAlphaTest: boolean;
  133825. /**
  133826. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133827. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133828. */
  133829. protected _useAlphaFresnel: boolean;
  133830. /**
  133831. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133832. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133833. */
  133834. protected _useLinearAlphaFresnel: boolean;
  133835. /**
  133836. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  133837. * from cos thetav and roughness:
  133838. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  133839. */
  133840. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  133841. /**
  133842. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133843. */
  133844. protected _forceIrradianceInFragment: boolean;
  133845. private _realTimeFiltering;
  133846. /**
  133847. * Enables realtime filtering on the texture.
  133848. */
  133849. get realTimeFiltering(): boolean;
  133850. set realTimeFiltering(b: boolean);
  133851. private _realTimeFilteringQuality;
  133852. /**
  133853. * Quality switch for realtime filtering
  133854. */
  133855. get realTimeFilteringQuality(): number;
  133856. set realTimeFilteringQuality(n: number);
  133857. /**
  133858. * Should this material render to several textures at once
  133859. */
  133860. get shouldRenderToMRT(): boolean;
  133861. /**
  133862. * Force normal to face away from face.
  133863. */
  133864. protected _forceNormalForward: boolean;
  133865. /**
  133866. * Enables specular anti aliasing in the PBR shader.
  133867. * It will both interacts on the Geometry for analytical and IBL lighting.
  133868. * It also prefilter the roughness map based on the bump values.
  133869. */
  133870. protected _enableSpecularAntiAliasing: boolean;
  133871. /**
  133872. * Default configuration related to image processing available in the PBR Material.
  133873. */
  133874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133875. /**
  133876. * Keep track of the image processing observer to allow dispose and replace.
  133877. */
  133878. private _imageProcessingObserver;
  133879. /**
  133880. * Attaches a new image processing configuration to the PBR Material.
  133881. * @param configuration
  133882. */
  133883. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133884. /**
  133885. * Stores the available render targets.
  133886. */
  133887. private _renderTargets;
  133888. /**
  133889. * Sets the global ambient color for the material used in lighting calculations.
  133890. */
  133891. private _globalAmbientColor;
  133892. /**
  133893. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  133894. */
  133895. private _useLogarithmicDepth;
  133896. /**
  133897. * If set to true, no lighting calculations will be applied.
  133898. */
  133899. private _unlit;
  133900. private _debugMode;
  133901. /**
  133902. * @hidden
  133903. * This is reserved for the inspector.
  133904. * Defines the material debug mode.
  133905. * It helps seeing only some components of the material while troubleshooting.
  133906. */
  133907. debugMode: number;
  133908. /**
  133909. * @hidden
  133910. * This is reserved for the inspector.
  133911. * Specify from where on screen the debug mode should start.
  133912. * The value goes from -1 (full screen) to 1 (not visible)
  133913. * It helps with side by side comparison against the final render
  133914. * This defaults to -1
  133915. */
  133916. private debugLimit;
  133917. /**
  133918. * @hidden
  133919. * This is reserved for the inspector.
  133920. * As the default viewing range might not be enough (if the ambient is really small for instance)
  133921. * You can use the factor to better multiply the final value.
  133922. */
  133923. private debugFactor;
  133924. /**
  133925. * Defines the clear coat layer parameters for the material.
  133926. */
  133927. readonly clearCoat: PBRClearCoatConfiguration;
  133928. /**
  133929. * Defines the anisotropic parameters for the material.
  133930. */
  133931. readonly anisotropy: PBRAnisotropicConfiguration;
  133932. /**
  133933. * Defines the BRDF parameters for the material.
  133934. */
  133935. readonly brdf: PBRBRDFConfiguration;
  133936. /**
  133937. * Defines the Sheen parameters for the material.
  133938. */
  133939. readonly sheen: PBRSheenConfiguration;
  133940. /**
  133941. * Defines the SubSurface parameters for the material.
  133942. */
  133943. readonly subSurface: PBRSubSurfaceConfiguration;
  133944. /**
  133945. * Defines the detail map parameters for the material.
  133946. */
  133947. readonly detailMap: DetailMapConfiguration;
  133948. protected _rebuildInParallel: boolean;
  133949. /**
  133950. * Instantiates a new PBRMaterial instance.
  133951. *
  133952. * @param name The material name
  133953. * @param scene The scene the material will be use in.
  133954. */
  133955. constructor(name: string, scene: Scene);
  133956. /**
  133957. * Gets a boolean indicating that current material needs to register RTT
  133958. */
  133959. get hasRenderTargetTextures(): boolean;
  133960. /**
  133961. * Gets the name of the material class.
  133962. */
  133963. getClassName(): string;
  133964. /**
  133965. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133966. */
  133967. get useLogarithmicDepth(): boolean;
  133968. /**
  133969. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133970. */
  133971. set useLogarithmicDepth(value: boolean);
  133972. /**
  133973. * Returns true if alpha blending should be disabled.
  133974. */
  133975. protected get _disableAlphaBlending(): boolean;
  133976. /**
  133977. * Specifies whether or not this material should be rendered in alpha blend mode.
  133978. */
  133979. needAlphaBlending(): boolean;
  133980. /**
  133981. * Specifies whether or not this material should be rendered in alpha test mode.
  133982. */
  133983. needAlphaTesting(): boolean;
  133984. /**
  133985. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  133986. */
  133987. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  133988. /**
  133989. * Gets the texture used for the alpha test.
  133990. */
  133991. getAlphaTestTexture(): Nullable<BaseTexture>;
  133992. /**
  133993. * Specifies that the submesh is ready to be used.
  133994. * @param mesh - BJS mesh.
  133995. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  133996. * @param useInstances - Specifies that instances should be used.
  133997. * @returns - boolean indicating that the submesh is ready or not.
  133998. */
  133999. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134000. /**
  134001. * Specifies if the material uses metallic roughness workflow.
  134002. * @returns boolean specifiying if the material uses metallic roughness workflow.
  134003. */
  134004. isMetallicWorkflow(): boolean;
  134005. private _prepareEffect;
  134006. private _prepareDefines;
  134007. /**
  134008. * Force shader compilation
  134009. */
  134010. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  134011. /**
  134012. * Initializes the uniform buffer layout for the shader.
  134013. */
  134014. buildUniformLayout(): void;
  134015. /**
  134016. * Unbinds the material from the mesh
  134017. */
  134018. unbind(): void;
  134019. /**
  134020. * Binds the submesh data.
  134021. * @param world - The world matrix.
  134022. * @param mesh - The BJS mesh.
  134023. * @param subMesh - A submesh of the BJS mesh.
  134024. */
  134025. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134026. /**
  134027. * Returns the animatable textures.
  134028. * @returns - Array of animatable textures.
  134029. */
  134030. getAnimatables(): IAnimatable[];
  134031. /**
  134032. * Returns the texture used for reflections.
  134033. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  134034. */
  134035. private _getReflectionTexture;
  134036. /**
  134037. * Returns an array of the actively used textures.
  134038. * @returns - Array of BaseTextures
  134039. */
  134040. getActiveTextures(): BaseTexture[];
  134041. /**
  134042. * Checks to see if a texture is used in the material.
  134043. * @param texture - Base texture to use.
  134044. * @returns - Boolean specifying if a texture is used in the material.
  134045. */
  134046. hasTexture(texture: BaseTexture): boolean;
  134047. /**
  134048. * Disposes the resources of the material.
  134049. * @param forceDisposeEffect - Forces the disposal of effects.
  134050. * @param forceDisposeTextures - Forces the disposal of all textures.
  134051. */
  134052. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134053. }
  134054. }
  134055. declare module BABYLON {
  134056. /**
  134057. * The Physically based material of BJS.
  134058. *
  134059. * This offers the main features of a standard PBR material.
  134060. * For more information, please refer to the documentation :
  134061. * https://doc.babylonjs.com/how_to/physically_based_rendering
  134062. */
  134063. export class PBRMaterial extends PBRBaseMaterial {
  134064. /**
  134065. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  134066. */
  134067. static readonly PBRMATERIAL_OPAQUE: number;
  134068. /**
  134069. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  134070. */
  134071. static readonly PBRMATERIAL_ALPHATEST: number;
  134072. /**
  134073. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134074. */
  134075. static readonly PBRMATERIAL_ALPHABLEND: number;
  134076. /**
  134077. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134078. * They are also discarded below the alpha cutoff threshold to improve performances.
  134079. */
  134080. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  134081. /**
  134082. * Defines the default value of how much AO map is occluding the analytical lights
  134083. * (point spot...).
  134084. */
  134085. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  134086. /**
  134087. * Intensity of the direct lights e.g. the four lights available in your scene.
  134088. * This impacts both the direct diffuse and specular highlights.
  134089. */
  134090. directIntensity: number;
  134091. /**
  134092. * Intensity of the emissive part of the material.
  134093. * This helps controlling the emissive effect without modifying the emissive color.
  134094. */
  134095. emissiveIntensity: number;
  134096. /**
  134097. * Intensity of the environment e.g. how much the environment will light the object
  134098. * either through harmonics for rough material or through the refelction for shiny ones.
  134099. */
  134100. environmentIntensity: number;
  134101. /**
  134102. * This is a special control allowing the reduction of the specular highlights coming from the
  134103. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  134104. */
  134105. specularIntensity: number;
  134106. /**
  134107. * Debug Control allowing disabling the bump map on this material.
  134108. */
  134109. disableBumpMap: boolean;
  134110. /**
  134111. * AKA Diffuse Texture in standard nomenclature.
  134112. */
  134113. albedoTexture: BaseTexture;
  134114. /**
  134115. * AKA Occlusion Texture in other nomenclature.
  134116. */
  134117. ambientTexture: BaseTexture;
  134118. /**
  134119. * AKA Occlusion Texture Intensity in other nomenclature.
  134120. */
  134121. ambientTextureStrength: number;
  134122. /**
  134123. * Defines how much the AO map is occluding the analytical lights (point spot...).
  134124. * 1 means it completely occludes it
  134125. * 0 mean it has no impact
  134126. */
  134127. ambientTextureImpactOnAnalyticalLights: number;
  134128. /**
  134129. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  134130. */
  134131. opacityTexture: BaseTexture;
  134132. /**
  134133. * Stores the reflection values in a texture.
  134134. */
  134135. reflectionTexture: Nullable<BaseTexture>;
  134136. /**
  134137. * Stores the emissive values in a texture.
  134138. */
  134139. emissiveTexture: BaseTexture;
  134140. /**
  134141. * AKA Specular texture in other nomenclature.
  134142. */
  134143. reflectivityTexture: BaseTexture;
  134144. /**
  134145. * Used to switch from specular/glossiness to metallic/roughness workflow.
  134146. */
  134147. metallicTexture: BaseTexture;
  134148. /**
  134149. * Specifies the metallic scalar of the metallic/roughness workflow.
  134150. * Can also be used to scale the metalness values of the metallic texture.
  134151. */
  134152. metallic: Nullable<number>;
  134153. /**
  134154. * Specifies the roughness scalar of the metallic/roughness workflow.
  134155. * Can also be used to scale the roughness values of the metallic texture.
  134156. */
  134157. roughness: Nullable<number>;
  134158. /**
  134159. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  134160. * By default the indexOfrefraction is used to compute F0;
  134161. *
  134162. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  134163. *
  134164. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  134165. * F90 = metallicReflectanceColor;
  134166. */
  134167. metallicF0Factor: number;
  134168. /**
  134169. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  134170. * By default the F90 is always 1;
  134171. *
  134172. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  134173. *
  134174. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  134175. * F90 = metallicReflectanceColor;
  134176. */
  134177. metallicReflectanceColor: Color3;
  134178. /**
  134179. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  134180. * This is multiply against the scalar values defined in the material.
  134181. */
  134182. metallicReflectanceTexture: Nullable<BaseTexture>;
  134183. /**
  134184. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  134185. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  134186. */
  134187. microSurfaceTexture: BaseTexture;
  134188. /**
  134189. * Stores surface normal data used to displace a mesh in a texture.
  134190. */
  134191. bumpTexture: BaseTexture;
  134192. /**
  134193. * Stores the pre-calculated light information of a mesh in a texture.
  134194. */
  134195. lightmapTexture: BaseTexture;
  134196. /**
  134197. * Stores the refracted light information in a texture.
  134198. */
  134199. get refractionTexture(): Nullable<BaseTexture>;
  134200. set refractionTexture(value: Nullable<BaseTexture>);
  134201. /**
  134202. * The color of a material in ambient lighting.
  134203. */
  134204. ambientColor: Color3;
  134205. /**
  134206. * AKA Diffuse Color in other nomenclature.
  134207. */
  134208. albedoColor: Color3;
  134209. /**
  134210. * AKA Specular Color in other nomenclature.
  134211. */
  134212. reflectivityColor: Color3;
  134213. /**
  134214. * The color reflected from the material.
  134215. */
  134216. reflectionColor: Color3;
  134217. /**
  134218. * The color emitted from the material.
  134219. */
  134220. emissiveColor: Color3;
  134221. /**
  134222. * AKA Glossiness in other nomenclature.
  134223. */
  134224. microSurface: number;
  134225. /**
  134226. * Index of refraction of the material base layer.
  134227. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134228. *
  134229. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134230. *
  134231. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134232. */
  134233. get indexOfRefraction(): number;
  134234. set indexOfRefraction(value: number);
  134235. /**
  134236. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134237. */
  134238. get invertRefractionY(): boolean;
  134239. set invertRefractionY(value: boolean);
  134240. /**
  134241. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134242. * Materials half opaque for instance using refraction could benefit from this control.
  134243. */
  134244. get linkRefractionWithTransparency(): boolean;
  134245. set linkRefractionWithTransparency(value: boolean);
  134246. /**
  134247. * If true, the light map contains occlusion information instead of lighting info.
  134248. */
  134249. useLightmapAsShadowmap: boolean;
  134250. /**
  134251. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  134252. */
  134253. useAlphaFromAlbedoTexture: boolean;
  134254. /**
  134255. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  134256. */
  134257. forceAlphaTest: boolean;
  134258. /**
  134259. * Defines the alpha limits in alpha test mode.
  134260. */
  134261. alphaCutOff: number;
  134262. /**
  134263. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  134264. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  134265. */
  134266. useSpecularOverAlpha: boolean;
  134267. /**
  134268. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  134269. */
  134270. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  134271. /**
  134272. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  134273. */
  134274. useRoughnessFromMetallicTextureAlpha: boolean;
  134275. /**
  134276. * Specifies if the metallic texture contains the roughness information in its green channel.
  134277. */
  134278. useRoughnessFromMetallicTextureGreen: boolean;
  134279. /**
  134280. * Specifies if the metallic texture contains the metallness information in its blue channel.
  134281. */
  134282. useMetallnessFromMetallicTextureBlue: boolean;
  134283. /**
  134284. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  134285. */
  134286. useAmbientOcclusionFromMetallicTextureRed: boolean;
  134287. /**
  134288. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  134289. */
  134290. useAmbientInGrayScale: boolean;
  134291. /**
  134292. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  134293. * The material will try to infer what glossiness each pixel should be.
  134294. */
  134295. useAutoMicroSurfaceFromReflectivityMap: boolean;
  134296. /**
  134297. * BJS is using an harcoded light falloff based on a manually sets up range.
  134298. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  134299. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  134300. */
  134301. get usePhysicalLightFalloff(): boolean;
  134302. /**
  134303. * BJS is using an harcoded light falloff based on a manually sets up range.
  134304. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  134305. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  134306. */
  134307. set usePhysicalLightFalloff(value: boolean);
  134308. /**
  134309. * In order to support the falloff compatibility with gltf, a special mode has been added
  134310. * to reproduce the gltf light falloff.
  134311. */
  134312. get useGLTFLightFalloff(): boolean;
  134313. /**
  134314. * In order to support the falloff compatibility with gltf, a special mode has been added
  134315. * to reproduce the gltf light falloff.
  134316. */
  134317. set useGLTFLightFalloff(value: boolean);
  134318. /**
  134319. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  134320. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  134321. */
  134322. useRadianceOverAlpha: boolean;
  134323. /**
  134324. * Allows using an object space normal map (instead of tangent space).
  134325. */
  134326. useObjectSpaceNormalMap: boolean;
  134327. /**
  134328. * Allows using the bump map in parallax mode.
  134329. */
  134330. useParallax: boolean;
  134331. /**
  134332. * Allows using the bump map in parallax occlusion mode.
  134333. */
  134334. useParallaxOcclusion: boolean;
  134335. /**
  134336. * Controls the scale bias of the parallax mode.
  134337. */
  134338. parallaxScaleBias: number;
  134339. /**
  134340. * If sets to true, disables all the lights affecting the material.
  134341. */
  134342. disableLighting: boolean;
  134343. /**
  134344. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  134345. */
  134346. forceIrradianceInFragment: boolean;
  134347. /**
  134348. * Number of Simultaneous lights allowed on the material.
  134349. */
  134350. maxSimultaneousLights: number;
  134351. /**
  134352. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  134353. */
  134354. invertNormalMapX: boolean;
  134355. /**
  134356. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  134357. */
  134358. invertNormalMapY: boolean;
  134359. /**
  134360. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  134361. */
  134362. twoSidedLighting: boolean;
  134363. /**
  134364. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134365. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  134366. */
  134367. useAlphaFresnel: boolean;
  134368. /**
  134369. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134370. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  134371. */
  134372. useLinearAlphaFresnel: boolean;
  134373. /**
  134374. * Let user defines the brdf lookup texture used for IBL.
  134375. * A default 8bit version is embedded but you could point at :
  134376. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  134377. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  134378. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  134379. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  134380. */
  134381. environmentBRDFTexture: Nullable<BaseTexture>;
  134382. /**
  134383. * Force normal to face away from face.
  134384. */
  134385. forceNormalForward: boolean;
  134386. /**
  134387. * Enables specular anti aliasing in the PBR shader.
  134388. * It will both interacts on the Geometry for analytical and IBL lighting.
  134389. * It also prefilter the roughness map based on the bump values.
  134390. */
  134391. enableSpecularAntiAliasing: boolean;
  134392. /**
  134393. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  134394. * makes the reflect vector face the model (under horizon).
  134395. */
  134396. useHorizonOcclusion: boolean;
  134397. /**
  134398. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  134399. * too much the area relying on ambient texture to define their ambient occlusion.
  134400. */
  134401. useRadianceOcclusion: boolean;
  134402. /**
  134403. * If set to true, no lighting calculations will be applied.
  134404. */
  134405. unlit: boolean;
  134406. /**
  134407. * Gets the image processing configuration used either in this material.
  134408. */
  134409. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  134410. /**
  134411. * Sets the Default image processing configuration used either in the this material.
  134412. *
  134413. * If sets to null, the scene one is in use.
  134414. */
  134415. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  134416. /**
  134417. * Gets wether the color curves effect is enabled.
  134418. */
  134419. get cameraColorCurvesEnabled(): boolean;
  134420. /**
  134421. * Sets wether the color curves effect is enabled.
  134422. */
  134423. set cameraColorCurvesEnabled(value: boolean);
  134424. /**
  134425. * Gets wether the color grading effect is enabled.
  134426. */
  134427. get cameraColorGradingEnabled(): boolean;
  134428. /**
  134429. * Gets wether the color grading effect is enabled.
  134430. */
  134431. set cameraColorGradingEnabled(value: boolean);
  134432. /**
  134433. * Gets wether tonemapping is enabled or not.
  134434. */
  134435. get cameraToneMappingEnabled(): boolean;
  134436. /**
  134437. * Sets wether tonemapping is enabled or not
  134438. */
  134439. set cameraToneMappingEnabled(value: boolean);
  134440. /**
  134441. * The camera exposure used on this material.
  134442. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134443. * This corresponds to a photographic exposure.
  134444. */
  134445. get cameraExposure(): number;
  134446. /**
  134447. * The camera exposure used on this material.
  134448. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134449. * This corresponds to a photographic exposure.
  134450. */
  134451. set cameraExposure(value: number);
  134452. /**
  134453. * Gets The camera contrast used on this material.
  134454. */
  134455. get cameraContrast(): number;
  134456. /**
  134457. * Sets The camera contrast used on this material.
  134458. */
  134459. set cameraContrast(value: number);
  134460. /**
  134461. * Gets the Color Grading 2D Lookup Texture.
  134462. */
  134463. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134464. /**
  134465. * Sets the Color Grading 2D Lookup Texture.
  134466. */
  134467. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134468. /**
  134469. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134470. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134471. * 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;
  134472. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134473. */
  134474. get cameraColorCurves(): Nullable<ColorCurves>;
  134475. /**
  134476. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134477. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134478. * 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;
  134479. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134480. */
  134481. set cameraColorCurves(value: Nullable<ColorCurves>);
  134482. /**
  134483. * Instantiates a new PBRMaterial instance.
  134484. *
  134485. * @param name The material name
  134486. * @param scene The scene the material will be use in.
  134487. */
  134488. constructor(name: string, scene: Scene);
  134489. /**
  134490. * Returns the name of this material class.
  134491. */
  134492. getClassName(): string;
  134493. /**
  134494. * Makes a duplicate of the current material.
  134495. * @param name - name to use for the new material.
  134496. */
  134497. clone(name: string): PBRMaterial;
  134498. /**
  134499. * Serializes this PBR Material.
  134500. * @returns - An object with the serialized material.
  134501. */
  134502. serialize(): any;
  134503. /**
  134504. * Parses a PBR Material from a serialized object.
  134505. * @param source - Serialized object.
  134506. * @param scene - BJS scene instance.
  134507. * @param rootUrl - url for the scene object
  134508. * @returns - PBRMaterial
  134509. */
  134510. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  134511. }
  134512. }
  134513. declare module BABYLON {
  134514. /**
  134515. * Direct draw surface info
  134516. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  134517. */
  134518. export interface DDSInfo {
  134519. /**
  134520. * Width of the texture
  134521. */
  134522. width: number;
  134523. /**
  134524. * Width of the texture
  134525. */
  134526. height: number;
  134527. /**
  134528. * Number of Mipmaps for the texture
  134529. * @see https://en.wikipedia.org/wiki/Mipmap
  134530. */
  134531. mipmapCount: number;
  134532. /**
  134533. * If the textures format is a known fourCC format
  134534. * @see https://www.fourcc.org/
  134535. */
  134536. isFourCC: boolean;
  134537. /**
  134538. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  134539. */
  134540. isRGB: boolean;
  134541. /**
  134542. * If the texture is a lumincance format
  134543. */
  134544. isLuminance: boolean;
  134545. /**
  134546. * If this is a cube texture
  134547. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  134548. */
  134549. isCube: boolean;
  134550. /**
  134551. * If the texture is a compressed format eg. FOURCC_DXT1
  134552. */
  134553. isCompressed: boolean;
  134554. /**
  134555. * The dxgiFormat of the texture
  134556. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  134557. */
  134558. dxgiFormat: number;
  134559. /**
  134560. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  134561. */
  134562. textureType: number;
  134563. /**
  134564. * Sphericle polynomial created for the dds texture
  134565. */
  134566. sphericalPolynomial?: SphericalPolynomial;
  134567. }
  134568. /**
  134569. * Class used to provide DDS decompression tools
  134570. */
  134571. export class DDSTools {
  134572. /**
  134573. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  134574. */
  134575. static StoreLODInAlphaChannel: boolean;
  134576. /**
  134577. * Gets DDS information from an array buffer
  134578. * @param data defines the array buffer view to read data from
  134579. * @returns the DDS information
  134580. */
  134581. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  134582. private static _FloatView;
  134583. private static _Int32View;
  134584. private static _ToHalfFloat;
  134585. private static _FromHalfFloat;
  134586. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  134587. private static _GetHalfFloatRGBAArrayBuffer;
  134588. private static _GetFloatRGBAArrayBuffer;
  134589. private static _GetFloatAsUIntRGBAArrayBuffer;
  134590. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  134591. private static _GetRGBAArrayBuffer;
  134592. private static _ExtractLongWordOrder;
  134593. private static _GetRGBArrayBuffer;
  134594. private static _GetLuminanceArrayBuffer;
  134595. /**
  134596. * Uploads DDS Levels to a Babylon Texture
  134597. * @hidden
  134598. */
  134599. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  134600. }
  134601. interface ThinEngine {
  134602. /**
  134603. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  134604. * @param rootUrl defines the url where the file to load is located
  134605. * @param scene defines the current scene
  134606. * @param lodScale defines scale to apply to the mip map selection
  134607. * @param lodOffset defines offset to apply to the mip map selection
  134608. * @param onLoad defines an optional callback raised when the texture is loaded
  134609. * @param onError defines an optional callback raised if there is an issue to load the texture
  134610. * @param format defines the format of the data
  134611. * @param forcedExtension defines the extension to use to pick the right loader
  134612. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  134613. * @returns the cube texture as an InternalTexture
  134614. */
  134615. 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;
  134616. }
  134617. }
  134618. declare module BABYLON {
  134619. /**
  134620. * Implementation of the DDS Texture Loader.
  134621. * @hidden
  134622. */
  134623. export class _DDSTextureLoader implements IInternalTextureLoader {
  134624. /**
  134625. * Defines wether the loader supports cascade loading the different faces.
  134626. */
  134627. readonly supportCascades: boolean;
  134628. /**
  134629. * This returns if the loader support the current file information.
  134630. * @param extension defines the file extension of the file being loaded
  134631. * @returns true if the loader can load the specified file
  134632. */
  134633. canLoad(extension: string): boolean;
  134634. /**
  134635. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134636. * @param data contains the texture data
  134637. * @param texture defines the BabylonJS internal texture
  134638. * @param createPolynomials will be true if polynomials have been requested
  134639. * @param onLoad defines the callback to trigger once the texture is ready
  134640. * @param onError defines the callback to trigger in case of error
  134641. */
  134642. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134643. /**
  134644. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134645. * @param data contains the texture data
  134646. * @param texture defines the BabylonJS internal texture
  134647. * @param callback defines the method to call once ready to upload
  134648. */
  134649. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134650. }
  134651. }
  134652. declare module BABYLON {
  134653. /**
  134654. * Implementation of the ENV Texture Loader.
  134655. * @hidden
  134656. */
  134657. export class _ENVTextureLoader implements IInternalTextureLoader {
  134658. /**
  134659. * Defines wether the loader supports cascade loading the different faces.
  134660. */
  134661. readonly supportCascades: boolean;
  134662. /**
  134663. * This returns if the loader support the current file information.
  134664. * @param extension defines the file extension of the file being loaded
  134665. * @returns true if the loader can load the specified file
  134666. */
  134667. canLoad(extension: string): boolean;
  134668. /**
  134669. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134670. * @param data contains the texture data
  134671. * @param texture defines the BabylonJS internal texture
  134672. * @param createPolynomials will be true if polynomials have been requested
  134673. * @param onLoad defines the callback to trigger once the texture is ready
  134674. * @param onError defines the callback to trigger in case of error
  134675. */
  134676. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134677. /**
  134678. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134679. * @param data contains the texture data
  134680. * @param texture defines the BabylonJS internal texture
  134681. * @param callback defines the method to call once ready to upload
  134682. */
  134683. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134684. }
  134685. }
  134686. declare module BABYLON {
  134687. /**
  134688. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  134689. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  134690. */
  134691. export class KhronosTextureContainer {
  134692. /** contents of the KTX container file */
  134693. data: ArrayBufferView;
  134694. private static HEADER_LEN;
  134695. private static COMPRESSED_2D;
  134696. private static COMPRESSED_3D;
  134697. private static TEX_2D;
  134698. private static TEX_3D;
  134699. /**
  134700. * Gets the openGL type
  134701. */
  134702. glType: number;
  134703. /**
  134704. * Gets the openGL type size
  134705. */
  134706. glTypeSize: number;
  134707. /**
  134708. * Gets the openGL format
  134709. */
  134710. glFormat: number;
  134711. /**
  134712. * Gets the openGL internal format
  134713. */
  134714. glInternalFormat: number;
  134715. /**
  134716. * Gets the base internal format
  134717. */
  134718. glBaseInternalFormat: number;
  134719. /**
  134720. * Gets image width in pixel
  134721. */
  134722. pixelWidth: number;
  134723. /**
  134724. * Gets image height in pixel
  134725. */
  134726. pixelHeight: number;
  134727. /**
  134728. * Gets image depth in pixels
  134729. */
  134730. pixelDepth: number;
  134731. /**
  134732. * Gets the number of array elements
  134733. */
  134734. numberOfArrayElements: number;
  134735. /**
  134736. * Gets the number of faces
  134737. */
  134738. numberOfFaces: number;
  134739. /**
  134740. * Gets the number of mipmap levels
  134741. */
  134742. numberOfMipmapLevels: number;
  134743. /**
  134744. * Gets the bytes of key value data
  134745. */
  134746. bytesOfKeyValueData: number;
  134747. /**
  134748. * Gets the load type
  134749. */
  134750. loadType: number;
  134751. /**
  134752. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  134753. */
  134754. isInvalid: boolean;
  134755. /**
  134756. * Creates a new KhronosTextureContainer
  134757. * @param data contents of the KTX container file
  134758. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  134759. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  134760. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  134761. */
  134762. constructor(
  134763. /** contents of the KTX container file */
  134764. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  134765. /**
  134766. * Uploads KTX content to a Babylon Texture.
  134767. * It is assumed that the texture has already been created & is currently bound
  134768. * @hidden
  134769. */
  134770. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  134771. private _upload2DCompressedLevels;
  134772. /**
  134773. * Checks if the given data starts with a KTX file identifier.
  134774. * @param data the data to check
  134775. * @returns true if the data is a KTX file or false otherwise
  134776. */
  134777. static IsValid(data: ArrayBufferView): boolean;
  134778. }
  134779. }
  134780. declare module BABYLON {
  134781. /**
  134782. * Class for loading KTX2 files
  134783. * !!! Experimental Extension Subject to Changes !!!
  134784. * @hidden
  134785. */
  134786. export class KhronosTextureContainer2 {
  134787. private static _ModulePromise;
  134788. private static _TranscodeFormat;
  134789. constructor(engine: ThinEngine);
  134790. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  134791. private _determineTranscodeFormat;
  134792. /**
  134793. * Checks if the given data starts with a KTX2 file identifier.
  134794. * @param data the data to check
  134795. * @returns true if the data is a KTX2 file or false otherwise
  134796. */
  134797. static IsValid(data: ArrayBufferView): boolean;
  134798. }
  134799. }
  134800. declare module BABYLON {
  134801. /**
  134802. * Implementation of the KTX Texture Loader.
  134803. * @hidden
  134804. */
  134805. export class _KTXTextureLoader implements IInternalTextureLoader {
  134806. /**
  134807. * Defines wether the loader supports cascade loading the different faces.
  134808. */
  134809. readonly supportCascades: boolean;
  134810. /**
  134811. * This returns if the loader support the current file information.
  134812. * @param extension defines the file extension of the file being loaded
  134813. * @param mimeType defines the optional mime type of the file being loaded
  134814. * @returns true if the loader can load the specified file
  134815. */
  134816. canLoad(extension: string, mimeType?: string): boolean;
  134817. /**
  134818. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134819. * @param data contains the texture data
  134820. * @param texture defines the BabylonJS internal texture
  134821. * @param createPolynomials will be true if polynomials have been requested
  134822. * @param onLoad defines the callback to trigger once the texture is ready
  134823. * @param onError defines the callback to trigger in case of error
  134824. */
  134825. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134826. /**
  134827. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134828. * @param data contains the texture data
  134829. * @param texture defines the BabylonJS internal texture
  134830. * @param callback defines the method to call once ready to upload
  134831. */
  134832. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  134833. }
  134834. }
  134835. declare module BABYLON {
  134836. /** @hidden */
  134837. export var _forceSceneHelpersToBundle: boolean;
  134838. interface Scene {
  134839. /**
  134840. * Creates a default light for the scene.
  134841. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  134842. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  134843. */
  134844. createDefaultLight(replace?: boolean): void;
  134845. /**
  134846. * Creates a default camera for the scene.
  134847. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  134848. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134849. * @param replace has default false, when true replaces the active camera in the scene
  134850. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  134851. */
  134852. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134853. /**
  134854. * Creates a default camera and a default light.
  134855. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  134856. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134857. * @param replace has the default false, when true replaces the active camera/light in the scene
  134858. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  134859. */
  134860. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134861. /**
  134862. * Creates a new sky box
  134863. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  134864. * @param environmentTexture defines the texture to use as environment texture
  134865. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  134866. * @param scale defines the overall scale of the skybox
  134867. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  134868. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  134869. * @returns a new mesh holding the sky box
  134870. */
  134871. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  134872. /**
  134873. * Creates a new environment
  134874. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  134875. * @param options defines the options you can use to configure the environment
  134876. * @returns the new EnvironmentHelper
  134877. */
  134878. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  134879. /**
  134880. * Creates a new VREXperienceHelper
  134881. * @see https://doc.babylonjs.com/how_to/webvr_helper
  134882. * @param webVROptions defines the options used to create the new VREXperienceHelper
  134883. * @returns a new VREXperienceHelper
  134884. */
  134885. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  134886. /**
  134887. * Creates a new WebXRDefaultExperience
  134888. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  134889. * @param options experience options
  134890. * @returns a promise for a new WebXRDefaultExperience
  134891. */
  134892. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134893. }
  134894. }
  134895. declare module BABYLON {
  134896. /**
  134897. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  134898. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  134899. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  134900. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134901. */
  134902. export class VideoDome extends TransformNode {
  134903. /**
  134904. * Define the video source as a Monoscopic panoramic 360 video.
  134905. */
  134906. static readonly MODE_MONOSCOPIC: number;
  134907. /**
  134908. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134909. */
  134910. static readonly MODE_TOPBOTTOM: number;
  134911. /**
  134912. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134913. */
  134914. static readonly MODE_SIDEBYSIDE: number;
  134915. private _halfDome;
  134916. private _useDirectMapping;
  134917. /**
  134918. * The video texture being displayed on the sphere
  134919. */
  134920. protected _videoTexture: VideoTexture;
  134921. /**
  134922. * Gets the video texture being displayed on the sphere
  134923. */
  134924. get videoTexture(): VideoTexture;
  134925. /**
  134926. * The skybox material
  134927. */
  134928. protected _material: BackgroundMaterial;
  134929. /**
  134930. * The surface used for the skybox
  134931. */
  134932. protected _mesh: Mesh;
  134933. /**
  134934. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  134935. */
  134936. private _halfDomeMask;
  134937. /**
  134938. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134939. * Also see the options.resolution property.
  134940. */
  134941. get fovMultiplier(): number;
  134942. set fovMultiplier(value: number);
  134943. private _videoMode;
  134944. /**
  134945. * Gets or set the current video mode for the video. It can be:
  134946. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  134947. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134948. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134949. */
  134950. get videoMode(): number;
  134951. set videoMode(value: number);
  134952. /**
  134953. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  134954. *
  134955. */
  134956. get halfDome(): boolean;
  134957. /**
  134958. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  134959. */
  134960. set halfDome(enabled: boolean);
  134961. /**
  134962. * Oberserver used in Stereoscopic VR Mode.
  134963. */
  134964. private _onBeforeCameraRenderObserver;
  134965. /**
  134966. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  134967. * @param name Element's name, child elements will append suffixes for their own names.
  134968. * @param urlsOrVideo defines the url(s) or the video element to use
  134969. * @param options An object containing optional or exposed sub element properties
  134970. */
  134971. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  134972. resolution?: number;
  134973. clickToPlay?: boolean;
  134974. autoPlay?: boolean;
  134975. loop?: boolean;
  134976. size?: number;
  134977. poster?: string;
  134978. faceForward?: boolean;
  134979. useDirectMapping?: boolean;
  134980. halfDomeMode?: boolean;
  134981. }, scene: Scene);
  134982. private _changeVideoMode;
  134983. /**
  134984. * Releases resources associated with this node.
  134985. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134986. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134987. */
  134988. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134989. }
  134990. }
  134991. declare module BABYLON {
  134992. /**
  134993. * This class can be used to get instrumentation data from a Babylon engine
  134994. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134995. */
  134996. export class EngineInstrumentation implements IDisposable {
  134997. /**
  134998. * Define the instrumented engine.
  134999. */
  135000. engine: Engine;
  135001. private _captureGPUFrameTime;
  135002. private _gpuFrameTimeToken;
  135003. private _gpuFrameTime;
  135004. private _captureShaderCompilationTime;
  135005. private _shaderCompilationTime;
  135006. private _onBeginFrameObserver;
  135007. private _onEndFrameObserver;
  135008. private _onBeforeShaderCompilationObserver;
  135009. private _onAfterShaderCompilationObserver;
  135010. /**
  135011. * Gets the perf counter used for GPU frame time
  135012. */
  135013. get gpuFrameTimeCounter(): PerfCounter;
  135014. /**
  135015. * Gets the GPU frame time capture status
  135016. */
  135017. get captureGPUFrameTime(): boolean;
  135018. /**
  135019. * Enable or disable the GPU frame time capture
  135020. */
  135021. set captureGPUFrameTime(value: boolean);
  135022. /**
  135023. * Gets the perf counter used for shader compilation time
  135024. */
  135025. get shaderCompilationTimeCounter(): PerfCounter;
  135026. /**
  135027. * Gets the shader compilation time capture status
  135028. */
  135029. get captureShaderCompilationTime(): boolean;
  135030. /**
  135031. * Enable or disable the shader compilation time capture
  135032. */
  135033. set captureShaderCompilationTime(value: boolean);
  135034. /**
  135035. * Instantiates a new engine instrumentation.
  135036. * This class can be used to get instrumentation data from a Babylon engine
  135037. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  135038. * @param engine Defines the engine to instrument
  135039. */
  135040. constructor(
  135041. /**
  135042. * Define the instrumented engine.
  135043. */
  135044. engine: Engine);
  135045. /**
  135046. * Dispose and release associated resources.
  135047. */
  135048. dispose(): void;
  135049. }
  135050. }
  135051. declare module BABYLON {
  135052. /**
  135053. * This class can be used to get instrumentation data from a Babylon engine
  135054. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135055. */
  135056. export class SceneInstrumentation implements IDisposable {
  135057. /**
  135058. * Defines the scene to instrument
  135059. */
  135060. scene: Scene;
  135061. private _captureActiveMeshesEvaluationTime;
  135062. private _activeMeshesEvaluationTime;
  135063. private _captureRenderTargetsRenderTime;
  135064. private _renderTargetsRenderTime;
  135065. private _captureFrameTime;
  135066. private _frameTime;
  135067. private _captureRenderTime;
  135068. private _renderTime;
  135069. private _captureInterFrameTime;
  135070. private _interFrameTime;
  135071. private _captureParticlesRenderTime;
  135072. private _particlesRenderTime;
  135073. private _captureSpritesRenderTime;
  135074. private _spritesRenderTime;
  135075. private _capturePhysicsTime;
  135076. private _physicsTime;
  135077. private _captureAnimationsTime;
  135078. private _animationsTime;
  135079. private _captureCameraRenderTime;
  135080. private _cameraRenderTime;
  135081. private _onBeforeActiveMeshesEvaluationObserver;
  135082. private _onAfterActiveMeshesEvaluationObserver;
  135083. private _onBeforeRenderTargetsRenderObserver;
  135084. private _onAfterRenderTargetsRenderObserver;
  135085. private _onAfterRenderObserver;
  135086. private _onBeforeDrawPhaseObserver;
  135087. private _onAfterDrawPhaseObserver;
  135088. private _onBeforeAnimationsObserver;
  135089. private _onBeforeParticlesRenderingObserver;
  135090. private _onAfterParticlesRenderingObserver;
  135091. private _onBeforeSpritesRenderingObserver;
  135092. private _onAfterSpritesRenderingObserver;
  135093. private _onBeforePhysicsObserver;
  135094. private _onAfterPhysicsObserver;
  135095. private _onAfterAnimationsObserver;
  135096. private _onBeforeCameraRenderObserver;
  135097. private _onAfterCameraRenderObserver;
  135098. /**
  135099. * Gets the perf counter used for active meshes evaluation time
  135100. */
  135101. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  135102. /**
  135103. * Gets the active meshes evaluation time capture status
  135104. */
  135105. get captureActiveMeshesEvaluationTime(): boolean;
  135106. /**
  135107. * Enable or disable the active meshes evaluation time capture
  135108. */
  135109. set captureActiveMeshesEvaluationTime(value: boolean);
  135110. /**
  135111. * Gets the perf counter used for render targets render time
  135112. */
  135113. get renderTargetsRenderTimeCounter(): PerfCounter;
  135114. /**
  135115. * Gets the render targets render time capture status
  135116. */
  135117. get captureRenderTargetsRenderTime(): boolean;
  135118. /**
  135119. * Enable or disable the render targets render time capture
  135120. */
  135121. set captureRenderTargetsRenderTime(value: boolean);
  135122. /**
  135123. * Gets the perf counter used for particles render time
  135124. */
  135125. get particlesRenderTimeCounter(): PerfCounter;
  135126. /**
  135127. * Gets the particles render time capture status
  135128. */
  135129. get captureParticlesRenderTime(): boolean;
  135130. /**
  135131. * Enable or disable the particles render time capture
  135132. */
  135133. set captureParticlesRenderTime(value: boolean);
  135134. /**
  135135. * Gets the perf counter used for sprites render time
  135136. */
  135137. get spritesRenderTimeCounter(): PerfCounter;
  135138. /**
  135139. * Gets the sprites render time capture status
  135140. */
  135141. get captureSpritesRenderTime(): boolean;
  135142. /**
  135143. * Enable or disable the sprites render time capture
  135144. */
  135145. set captureSpritesRenderTime(value: boolean);
  135146. /**
  135147. * Gets the perf counter used for physics time
  135148. */
  135149. get physicsTimeCounter(): PerfCounter;
  135150. /**
  135151. * Gets the physics time capture status
  135152. */
  135153. get capturePhysicsTime(): boolean;
  135154. /**
  135155. * Enable or disable the physics time capture
  135156. */
  135157. set capturePhysicsTime(value: boolean);
  135158. /**
  135159. * Gets the perf counter used for animations time
  135160. */
  135161. get animationsTimeCounter(): PerfCounter;
  135162. /**
  135163. * Gets the animations time capture status
  135164. */
  135165. get captureAnimationsTime(): boolean;
  135166. /**
  135167. * Enable or disable the animations time capture
  135168. */
  135169. set captureAnimationsTime(value: boolean);
  135170. /**
  135171. * Gets the perf counter used for frame time capture
  135172. */
  135173. get frameTimeCounter(): PerfCounter;
  135174. /**
  135175. * Gets the frame time capture status
  135176. */
  135177. get captureFrameTime(): boolean;
  135178. /**
  135179. * Enable or disable the frame time capture
  135180. */
  135181. set captureFrameTime(value: boolean);
  135182. /**
  135183. * Gets the perf counter used for inter-frames time capture
  135184. */
  135185. get interFrameTimeCounter(): PerfCounter;
  135186. /**
  135187. * Gets the inter-frames time capture status
  135188. */
  135189. get captureInterFrameTime(): boolean;
  135190. /**
  135191. * Enable or disable the inter-frames time capture
  135192. */
  135193. set captureInterFrameTime(value: boolean);
  135194. /**
  135195. * Gets the perf counter used for render time capture
  135196. */
  135197. get renderTimeCounter(): PerfCounter;
  135198. /**
  135199. * Gets the render time capture status
  135200. */
  135201. get captureRenderTime(): boolean;
  135202. /**
  135203. * Enable or disable the render time capture
  135204. */
  135205. set captureRenderTime(value: boolean);
  135206. /**
  135207. * Gets the perf counter used for camera render time capture
  135208. */
  135209. get cameraRenderTimeCounter(): PerfCounter;
  135210. /**
  135211. * Gets the camera render time capture status
  135212. */
  135213. get captureCameraRenderTime(): boolean;
  135214. /**
  135215. * Enable or disable the camera render time capture
  135216. */
  135217. set captureCameraRenderTime(value: boolean);
  135218. /**
  135219. * Gets the perf counter used for draw calls
  135220. */
  135221. get drawCallsCounter(): PerfCounter;
  135222. /**
  135223. * Instantiates a new scene instrumentation.
  135224. * This class can be used to get instrumentation data from a Babylon engine
  135225. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135226. * @param scene Defines the scene to instrument
  135227. */
  135228. constructor(
  135229. /**
  135230. * Defines the scene to instrument
  135231. */
  135232. scene: Scene);
  135233. /**
  135234. * Dispose and release associated resources.
  135235. */
  135236. dispose(): void;
  135237. }
  135238. }
  135239. declare module BABYLON {
  135240. /** @hidden */
  135241. export var glowMapGenerationPixelShader: {
  135242. name: string;
  135243. shader: string;
  135244. };
  135245. }
  135246. declare module BABYLON {
  135247. /** @hidden */
  135248. export var glowMapGenerationVertexShader: {
  135249. name: string;
  135250. shader: string;
  135251. };
  135252. }
  135253. declare module BABYLON {
  135254. /**
  135255. * Effect layer options. This helps customizing the behaviour
  135256. * of the effect layer.
  135257. */
  135258. export interface IEffectLayerOptions {
  135259. /**
  135260. * Multiplication factor apply to the canvas size to compute the render target size
  135261. * used to generated the objects (the smaller the faster).
  135262. */
  135263. mainTextureRatio: number;
  135264. /**
  135265. * Enforces a fixed size texture to ensure effect stability across devices.
  135266. */
  135267. mainTextureFixedSize?: number;
  135268. /**
  135269. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  135270. */
  135271. alphaBlendingMode: number;
  135272. /**
  135273. * The camera attached to the layer.
  135274. */
  135275. camera: Nullable<Camera>;
  135276. /**
  135277. * The rendering group to draw the layer in.
  135278. */
  135279. renderingGroupId: number;
  135280. }
  135281. /**
  135282. * The effect layer Helps adding post process effect blended with the main pass.
  135283. *
  135284. * This can be for instance use to generate glow or higlight effects on the scene.
  135285. *
  135286. * The effect layer class can not be used directly and is intented to inherited from to be
  135287. * customized per effects.
  135288. */
  135289. export abstract class EffectLayer {
  135290. private _vertexBuffers;
  135291. private _indexBuffer;
  135292. private _cachedDefines;
  135293. private _effectLayerMapGenerationEffect;
  135294. private _effectLayerOptions;
  135295. private _mergeEffect;
  135296. protected _scene: Scene;
  135297. protected _engine: Engine;
  135298. protected _maxSize: number;
  135299. protected _mainTextureDesiredSize: ISize;
  135300. protected _mainTexture: RenderTargetTexture;
  135301. protected _shouldRender: boolean;
  135302. protected _postProcesses: PostProcess[];
  135303. protected _textures: BaseTexture[];
  135304. protected _emissiveTextureAndColor: {
  135305. texture: Nullable<BaseTexture>;
  135306. color: Color4;
  135307. };
  135308. /**
  135309. * The name of the layer
  135310. */
  135311. name: string;
  135312. /**
  135313. * The clear color of the texture used to generate the glow map.
  135314. */
  135315. neutralColor: Color4;
  135316. /**
  135317. * Specifies whether the highlight layer is enabled or not.
  135318. */
  135319. isEnabled: boolean;
  135320. /**
  135321. * Gets the camera attached to the layer.
  135322. */
  135323. get camera(): Nullable<Camera>;
  135324. /**
  135325. * Gets the rendering group id the layer should render in.
  135326. */
  135327. get renderingGroupId(): number;
  135328. set renderingGroupId(renderingGroupId: number);
  135329. /**
  135330. * An event triggered when the effect layer has been disposed.
  135331. */
  135332. onDisposeObservable: Observable<EffectLayer>;
  135333. /**
  135334. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  135335. */
  135336. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  135337. /**
  135338. * An event triggered when the generated texture is being merged in the scene.
  135339. */
  135340. onBeforeComposeObservable: Observable<EffectLayer>;
  135341. /**
  135342. * An event triggered when the mesh is rendered into the effect render target.
  135343. */
  135344. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  135345. /**
  135346. * An event triggered after the mesh has been rendered into the effect render target.
  135347. */
  135348. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  135349. /**
  135350. * An event triggered when the generated texture has been merged in the scene.
  135351. */
  135352. onAfterComposeObservable: Observable<EffectLayer>;
  135353. /**
  135354. * An event triggered when the efffect layer changes its size.
  135355. */
  135356. onSizeChangedObservable: Observable<EffectLayer>;
  135357. /** @hidden */
  135358. static _SceneComponentInitialization: (scene: Scene) => void;
  135359. /**
  135360. * Instantiates a new effect Layer and references it in the scene.
  135361. * @param name The name of the layer
  135362. * @param scene The scene to use the layer in
  135363. */
  135364. constructor(
  135365. /** The Friendly of the effect in the scene */
  135366. name: string, scene: Scene);
  135367. /**
  135368. * Get the effect name of the layer.
  135369. * @return The effect name
  135370. */
  135371. abstract getEffectName(): string;
  135372. /**
  135373. * Checks for the readiness of the element composing the layer.
  135374. * @param subMesh the mesh to check for
  135375. * @param useInstances specify whether or not to use instances to render the mesh
  135376. * @return true if ready otherwise, false
  135377. */
  135378. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135379. /**
  135380. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135381. * @returns true if the effect requires stencil during the main canvas render pass.
  135382. */
  135383. abstract needStencil(): boolean;
  135384. /**
  135385. * Create the merge effect. This is the shader use to blit the information back
  135386. * to the main canvas at the end of the scene rendering.
  135387. * @returns The effect containing the shader used to merge the effect on the main canvas
  135388. */
  135389. protected abstract _createMergeEffect(): Effect;
  135390. /**
  135391. * Creates the render target textures and post processes used in the effect layer.
  135392. */
  135393. protected abstract _createTextureAndPostProcesses(): void;
  135394. /**
  135395. * Implementation specific of rendering the generating effect on the main canvas.
  135396. * @param effect The effect used to render through
  135397. */
  135398. protected abstract _internalRender(effect: Effect): void;
  135399. /**
  135400. * Sets the required values for both the emissive texture and and the main color.
  135401. */
  135402. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135403. /**
  135404. * Free any resources and references associated to a mesh.
  135405. * Internal use
  135406. * @param mesh The mesh to free.
  135407. */
  135408. abstract _disposeMesh(mesh: Mesh): void;
  135409. /**
  135410. * Serializes this layer (Glow or Highlight for example)
  135411. * @returns a serialized layer object
  135412. */
  135413. abstract serialize?(): any;
  135414. /**
  135415. * Initializes the effect layer with the required options.
  135416. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  135417. */
  135418. protected _init(options: Partial<IEffectLayerOptions>): void;
  135419. /**
  135420. * Generates the index buffer of the full screen quad blending to the main canvas.
  135421. */
  135422. private _generateIndexBuffer;
  135423. /**
  135424. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  135425. */
  135426. private _generateVertexBuffer;
  135427. /**
  135428. * Sets the main texture desired size which is the closest power of two
  135429. * of the engine canvas size.
  135430. */
  135431. private _setMainTextureSize;
  135432. /**
  135433. * Creates the main texture for the effect layer.
  135434. */
  135435. protected _createMainTexture(): void;
  135436. /**
  135437. * Adds specific effects defines.
  135438. * @param defines The defines to add specifics to.
  135439. */
  135440. protected _addCustomEffectDefines(defines: string[]): void;
  135441. /**
  135442. * Checks for the readiness of the element composing the layer.
  135443. * @param subMesh the mesh to check for
  135444. * @param useInstances specify whether or not to use instances to render the mesh
  135445. * @param emissiveTexture the associated emissive texture used to generate the glow
  135446. * @return true if ready otherwise, false
  135447. */
  135448. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  135449. /**
  135450. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  135451. */
  135452. render(): void;
  135453. /**
  135454. * Determine if a given mesh will be used in the current effect.
  135455. * @param mesh mesh to test
  135456. * @returns true if the mesh will be used
  135457. */
  135458. hasMesh(mesh: AbstractMesh): boolean;
  135459. /**
  135460. * Returns true if the layer contains information to display, otherwise false.
  135461. * @returns true if the glow layer should be rendered
  135462. */
  135463. shouldRender(): boolean;
  135464. /**
  135465. * Returns true if the mesh should render, otherwise false.
  135466. * @param mesh The mesh to render
  135467. * @returns true if it should render otherwise false
  135468. */
  135469. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  135470. /**
  135471. * Returns true if the mesh can be rendered, otherwise false.
  135472. * @param mesh The mesh to render
  135473. * @param material The material used on the mesh
  135474. * @returns true if it can be rendered otherwise false
  135475. */
  135476. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135477. /**
  135478. * Returns true if the mesh should render, otherwise false.
  135479. * @param mesh The mesh to render
  135480. * @returns true if it should render otherwise false
  135481. */
  135482. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  135483. /**
  135484. * Renders the submesh passed in parameter to the generation map.
  135485. */
  135486. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  135487. /**
  135488. * Defines whether the current material of the mesh should be use to render the effect.
  135489. * @param mesh defines the current mesh to render
  135490. */
  135491. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135492. /**
  135493. * Rebuild the required buffers.
  135494. * @hidden Internal use only.
  135495. */
  135496. _rebuild(): void;
  135497. /**
  135498. * Dispose only the render target textures and post process.
  135499. */
  135500. private _disposeTextureAndPostProcesses;
  135501. /**
  135502. * Dispose the highlight layer and free resources.
  135503. */
  135504. dispose(): void;
  135505. /**
  135506. * Gets the class name of the effect layer
  135507. * @returns the string with the class name of the effect layer
  135508. */
  135509. getClassName(): string;
  135510. /**
  135511. * Creates an effect layer from parsed effect layer data
  135512. * @param parsedEffectLayer defines effect layer data
  135513. * @param scene defines the current scene
  135514. * @param rootUrl defines the root URL containing the effect layer information
  135515. * @returns a parsed effect Layer
  135516. */
  135517. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  135518. }
  135519. }
  135520. declare module BABYLON {
  135521. interface AbstractScene {
  135522. /**
  135523. * The list of effect layers (highlights/glow) added to the scene
  135524. * @see https://doc.babylonjs.com/how_to/highlight_layer
  135525. * @see https://doc.babylonjs.com/how_to/glow_layer
  135526. */
  135527. effectLayers: Array<EffectLayer>;
  135528. /**
  135529. * Removes the given effect layer from this scene.
  135530. * @param toRemove defines the effect layer to remove
  135531. * @returns the index of the removed effect layer
  135532. */
  135533. removeEffectLayer(toRemove: EffectLayer): number;
  135534. /**
  135535. * Adds the given effect layer to this scene
  135536. * @param newEffectLayer defines the effect layer to add
  135537. */
  135538. addEffectLayer(newEffectLayer: EffectLayer): void;
  135539. }
  135540. /**
  135541. * Defines the layer scene component responsible to manage any effect layers
  135542. * in a given scene.
  135543. */
  135544. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  135545. /**
  135546. * The component name helpfull to identify the component in the list of scene components.
  135547. */
  135548. readonly name: string;
  135549. /**
  135550. * The scene the component belongs to.
  135551. */
  135552. scene: Scene;
  135553. private _engine;
  135554. private _renderEffects;
  135555. private _needStencil;
  135556. private _previousStencilState;
  135557. /**
  135558. * Creates a new instance of the component for the given scene
  135559. * @param scene Defines the scene to register the component in
  135560. */
  135561. constructor(scene: Scene);
  135562. /**
  135563. * Registers the component in a given scene
  135564. */
  135565. register(): void;
  135566. /**
  135567. * Rebuilds the elements related to this component in case of
  135568. * context lost for instance.
  135569. */
  135570. rebuild(): void;
  135571. /**
  135572. * Serializes the component data to the specified json object
  135573. * @param serializationObject The object to serialize to
  135574. */
  135575. serialize(serializationObject: any): void;
  135576. /**
  135577. * Adds all the elements from the container to the scene
  135578. * @param container the container holding the elements
  135579. */
  135580. addFromContainer(container: AbstractScene): void;
  135581. /**
  135582. * Removes all the elements in the container from the scene
  135583. * @param container contains the elements to remove
  135584. * @param dispose if the removed element should be disposed (default: false)
  135585. */
  135586. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135587. /**
  135588. * Disposes the component and the associated ressources.
  135589. */
  135590. dispose(): void;
  135591. private _isReadyForMesh;
  135592. private _renderMainTexture;
  135593. private _setStencil;
  135594. private _setStencilBack;
  135595. private _draw;
  135596. private _drawCamera;
  135597. private _drawRenderingGroup;
  135598. }
  135599. }
  135600. declare module BABYLON {
  135601. /** @hidden */
  135602. export var glowMapMergePixelShader: {
  135603. name: string;
  135604. shader: string;
  135605. };
  135606. }
  135607. declare module BABYLON {
  135608. /** @hidden */
  135609. export var glowMapMergeVertexShader: {
  135610. name: string;
  135611. shader: string;
  135612. };
  135613. }
  135614. declare module BABYLON {
  135615. interface AbstractScene {
  135616. /**
  135617. * Return a the first highlight layer of the scene with a given name.
  135618. * @param name The name of the highlight layer to look for.
  135619. * @return The highlight layer if found otherwise null.
  135620. */
  135621. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  135622. }
  135623. /**
  135624. * Glow layer options. This helps customizing the behaviour
  135625. * of the glow layer.
  135626. */
  135627. export interface IGlowLayerOptions {
  135628. /**
  135629. * Multiplication factor apply to the canvas size to compute the render target size
  135630. * used to generated the glowing objects (the smaller the faster).
  135631. */
  135632. mainTextureRatio: number;
  135633. /**
  135634. * Enforces a fixed size texture to ensure resize independant blur.
  135635. */
  135636. mainTextureFixedSize?: number;
  135637. /**
  135638. * How big is the kernel of the blur texture.
  135639. */
  135640. blurKernelSize: number;
  135641. /**
  135642. * The camera attached to the layer.
  135643. */
  135644. camera: Nullable<Camera>;
  135645. /**
  135646. * Enable MSAA by chosing the number of samples.
  135647. */
  135648. mainTextureSamples?: number;
  135649. /**
  135650. * The rendering group to draw the layer in.
  135651. */
  135652. renderingGroupId: number;
  135653. }
  135654. /**
  135655. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  135656. *
  135657. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  135658. *
  135659. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  135660. */
  135661. export class GlowLayer extends EffectLayer {
  135662. /**
  135663. * Effect Name of the layer.
  135664. */
  135665. static readonly EffectName: string;
  135666. /**
  135667. * The default blur kernel size used for the glow.
  135668. */
  135669. static DefaultBlurKernelSize: number;
  135670. /**
  135671. * The default texture size ratio used for the glow.
  135672. */
  135673. static DefaultTextureRatio: number;
  135674. /**
  135675. * Sets the kernel size of the blur.
  135676. */
  135677. set blurKernelSize(value: number);
  135678. /**
  135679. * Gets the kernel size of the blur.
  135680. */
  135681. get blurKernelSize(): number;
  135682. /**
  135683. * Sets the glow intensity.
  135684. */
  135685. set intensity(value: number);
  135686. /**
  135687. * Gets the glow intensity.
  135688. */
  135689. get intensity(): number;
  135690. private _options;
  135691. private _intensity;
  135692. private _horizontalBlurPostprocess1;
  135693. private _verticalBlurPostprocess1;
  135694. private _horizontalBlurPostprocess2;
  135695. private _verticalBlurPostprocess2;
  135696. private _blurTexture1;
  135697. private _blurTexture2;
  135698. private _postProcesses1;
  135699. private _postProcesses2;
  135700. private _includedOnlyMeshes;
  135701. private _excludedMeshes;
  135702. private _meshesUsingTheirOwnMaterials;
  135703. /**
  135704. * Callback used to let the user override the color selection on a per mesh basis
  135705. */
  135706. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  135707. /**
  135708. * Callback used to let the user override the texture selection on a per mesh basis
  135709. */
  135710. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  135711. /**
  135712. * Instantiates a new glow Layer and references it to the scene.
  135713. * @param name The name of the layer
  135714. * @param scene The scene to use the layer in
  135715. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  135716. */
  135717. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  135718. /**
  135719. * Get the effect name of the layer.
  135720. * @return The effect name
  135721. */
  135722. getEffectName(): string;
  135723. /**
  135724. * Create the merge effect. This is the shader use to blit the information back
  135725. * to the main canvas at the end of the scene rendering.
  135726. */
  135727. protected _createMergeEffect(): Effect;
  135728. /**
  135729. * Creates the render target textures and post processes used in the glow layer.
  135730. */
  135731. protected _createTextureAndPostProcesses(): void;
  135732. /**
  135733. * Checks for the readiness of the element composing the layer.
  135734. * @param subMesh the mesh to check for
  135735. * @param useInstances specify wether or not to use instances to render the mesh
  135736. * @param emissiveTexture the associated emissive texture used to generate the glow
  135737. * @return true if ready otherwise, false
  135738. */
  135739. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135740. /**
  135741. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135742. */
  135743. needStencil(): boolean;
  135744. /**
  135745. * Returns true if the mesh can be rendered, otherwise false.
  135746. * @param mesh The mesh to render
  135747. * @param material The material used on the mesh
  135748. * @returns true if it can be rendered otherwise false
  135749. */
  135750. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135751. /**
  135752. * Implementation specific of rendering the generating effect on the main canvas.
  135753. * @param effect The effect used to render through
  135754. */
  135755. protected _internalRender(effect: Effect): void;
  135756. /**
  135757. * Sets the required values for both the emissive texture and and the main color.
  135758. */
  135759. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135760. /**
  135761. * Returns true if the mesh should render, otherwise false.
  135762. * @param mesh The mesh to render
  135763. * @returns true if it should render otherwise false
  135764. */
  135765. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135766. /**
  135767. * Adds specific effects defines.
  135768. * @param defines The defines to add specifics to.
  135769. */
  135770. protected _addCustomEffectDefines(defines: string[]): void;
  135771. /**
  135772. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  135773. * @param mesh The mesh to exclude from the glow layer
  135774. */
  135775. addExcludedMesh(mesh: Mesh): void;
  135776. /**
  135777. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  135778. * @param mesh The mesh to remove
  135779. */
  135780. removeExcludedMesh(mesh: Mesh): void;
  135781. /**
  135782. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  135783. * @param mesh The mesh to include in the glow layer
  135784. */
  135785. addIncludedOnlyMesh(mesh: Mesh): void;
  135786. /**
  135787. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  135788. * @param mesh The mesh to remove
  135789. */
  135790. removeIncludedOnlyMesh(mesh: Mesh): void;
  135791. /**
  135792. * Determine if a given mesh will be used in the glow layer
  135793. * @param mesh The mesh to test
  135794. * @returns true if the mesh will be highlighted by the current glow layer
  135795. */
  135796. hasMesh(mesh: AbstractMesh): boolean;
  135797. /**
  135798. * Defines whether the current material of the mesh should be use to render the effect.
  135799. * @param mesh defines the current mesh to render
  135800. */
  135801. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135802. /**
  135803. * Add a mesh to be rendered through its own material and not with emissive only.
  135804. * @param mesh The mesh for which we need to use its material
  135805. */
  135806. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  135807. /**
  135808. * Remove a mesh from being rendered through its own material and not with emissive only.
  135809. * @param mesh The mesh for which we need to not use its material
  135810. */
  135811. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  135812. /**
  135813. * Free any resources and references associated to a mesh.
  135814. * Internal use
  135815. * @param mesh The mesh to free.
  135816. * @hidden
  135817. */
  135818. _disposeMesh(mesh: Mesh): void;
  135819. /**
  135820. * Gets the class name of the effect layer
  135821. * @returns the string with the class name of the effect layer
  135822. */
  135823. getClassName(): string;
  135824. /**
  135825. * Serializes this glow layer
  135826. * @returns a serialized glow layer object
  135827. */
  135828. serialize(): any;
  135829. /**
  135830. * Creates a Glow Layer from parsed glow layer data
  135831. * @param parsedGlowLayer defines glow layer data
  135832. * @param scene defines the current scene
  135833. * @param rootUrl defines the root URL containing the glow layer information
  135834. * @returns a parsed Glow Layer
  135835. */
  135836. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  135837. }
  135838. }
  135839. declare module BABYLON {
  135840. /** @hidden */
  135841. export var glowBlurPostProcessPixelShader: {
  135842. name: string;
  135843. shader: string;
  135844. };
  135845. }
  135846. declare module BABYLON {
  135847. interface AbstractScene {
  135848. /**
  135849. * Return a the first highlight layer of the scene with a given name.
  135850. * @param name The name of the highlight layer to look for.
  135851. * @return The highlight layer if found otherwise null.
  135852. */
  135853. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  135854. }
  135855. /**
  135856. * Highlight layer options. This helps customizing the behaviour
  135857. * of the highlight layer.
  135858. */
  135859. export interface IHighlightLayerOptions {
  135860. /**
  135861. * Multiplication factor apply to the canvas size to compute the render target size
  135862. * used to generated the glowing objects (the smaller the faster).
  135863. */
  135864. mainTextureRatio: number;
  135865. /**
  135866. * Enforces a fixed size texture to ensure resize independant blur.
  135867. */
  135868. mainTextureFixedSize?: number;
  135869. /**
  135870. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  135871. * of the picture to blur (the smaller the faster).
  135872. */
  135873. blurTextureSizeRatio: number;
  135874. /**
  135875. * How big in texel of the blur texture is the vertical blur.
  135876. */
  135877. blurVerticalSize: number;
  135878. /**
  135879. * How big in texel of the blur texture is the horizontal blur.
  135880. */
  135881. blurHorizontalSize: number;
  135882. /**
  135883. * Alpha blending mode used to apply the blur. Default is combine.
  135884. */
  135885. alphaBlendingMode: number;
  135886. /**
  135887. * The camera attached to the layer.
  135888. */
  135889. camera: Nullable<Camera>;
  135890. /**
  135891. * Should we display highlight as a solid stroke?
  135892. */
  135893. isStroke?: boolean;
  135894. /**
  135895. * The rendering group to draw the layer in.
  135896. */
  135897. renderingGroupId: number;
  135898. }
  135899. /**
  135900. * The highlight layer Helps adding a glow effect around a mesh.
  135901. *
  135902. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  135903. * glowy meshes to your scene.
  135904. *
  135905. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  135906. */
  135907. export class HighlightLayer extends EffectLayer {
  135908. name: string;
  135909. /**
  135910. * Effect Name of the highlight layer.
  135911. */
  135912. static readonly EffectName: string;
  135913. /**
  135914. * The neutral color used during the preparation of the glow effect.
  135915. * This is black by default as the blend operation is a blend operation.
  135916. */
  135917. static NeutralColor: Color4;
  135918. /**
  135919. * Stencil value used for glowing meshes.
  135920. */
  135921. static GlowingMeshStencilReference: number;
  135922. /**
  135923. * Stencil value used for the other meshes in the scene.
  135924. */
  135925. static NormalMeshStencilReference: number;
  135926. /**
  135927. * Specifies whether or not the inner glow is ACTIVE in the layer.
  135928. */
  135929. innerGlow: boolean;
  135930. /**
  135931. * Specifies whether or not the outer glow is ACTIVE in the layer.
  135932. */
  135933. outerGlow: boolean;
  135934. /**
  135935. * Specifies the horizontal size of the blur.
  135936. */
  135937. set blurHorizontalSize(value: number);
  135938. /**
  135939. * Specifies the vertical size of the blur.
  135940. */
  135941. set blurVerticalSize(value: number);
  135942. /**
  135943. * Gets the horizontal size of the blur.
  135944. */
  135945. get blurHorizontalSize(): number;
  135946. /**
  135947. * Gets the vertical size of the blur.
  135948. */
  135949. get blurVerticalSize(): number;
  135950. /**
  135951. * An event triggered when the highlight layer is being blurred.
  135952. */
  135953. onBeforeBlurObservable: Observable<HighlightLayer>;
  135954. /**
  135955. * An event triggered when the highlight layer has been blurred.
  135956. */
  135957. onAfterBlurObservable: Observable<HighlightLayer>;
  135958. private _instanceGlowingMeshStencilReference;
  135959. private _options;
  135960. private _downSamplePostprocess;
  135961. private _horizontalBlurPostprocess;
  135962. private _verticalBlurPostprocess;
  135963. private _blurTexture;
  135964. private _meshes;
  135965. private _excludedMeshes;
  135966. /**
  135967. * Instantiates a new highlight Layer and references it to the scene..
  135968. * @param name The name of the layer
  135969. * @param scene The scene to use the layer in
  135970. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  135971. */
  135972. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  135973. /**
  135974. * Get the effect name of the layer.
  135975. * @return The effect name
  135976. */
  135977. getEffectName(): string;
  135978. /**
  135979. * Create the merge effect. This is the shader use to blit the information back
  135980. * to the main canvas at the end of the scene rendering.
  135981. */
  135982. protected _createMergeEffect(): Effect;
  135983. /**
  135984. * Creates the render target textures and post processes used in the highlight layer.
  135985. */
  135986. protected _createTextureAndPostProcesses(): void;
  135987. /**
  135988. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  135989. */
  135990. needStencil(): boolean;
  135991. /**
  135992. * Checks for the readiness of the element composing the layer.
  135993. * @param subMesh the mesh to check for
  135994. * @param useInstances specify wether or not to use instances to render the mesh
  135995. * @param emissiveTexture the associated emissive texture used to generate the glow
  135996. * @return true if ready otherwise, false
  135997. */
  135998. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135999. /**
  136000. * Implementation specific of rendering the generating effect on the main canvas.
  136001. * @param effect The effect used to render through
  136002. */
  136003. protected _internalRender(effect: Effect): void;
  136004. /**
  136005. * Returns true if the layer contains information to display, otherwise false.
  136006. */
  136007. shouldRender(): boolean;
  136008. /**
  136009. * Returns true if the mesh should render, otherwise false.
  136010. * @param mesh The mesh to render
  136011. * @returns true if it should render otherwise false
  136012. */
  136013. protected _shouldRenderMesh(mesh: Mesh): boolean;
  136014. /**
  136015. * Returns true if the mesh can be rendered, otherwise false.
  136016. * @param mesh The mesh to render
  136017. * @param material The material used on the mesh
  136018. * @returns true if it can be rendered otherwise false
  136019. */
  136020. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136021. /**
  136022. * Adds specific effects defines.
  136023. * @param defines The defines to add specifics to.
  136024. */
  136025. protected _addCustomEffectDefines(defines: string[]): void;
  136026. /**
  136027. * Sets the required values for both the emissive texture and and the main color.
  136028. */
  136029. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136030. /**
  136031. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  136032. * @param mesh The mesh to exclude from the highlight layer
  136033. */
  136034. addExcludedMesh(mesh: Mesh): void;
  136035. /**
  136036. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  136037. * @param mesh The mesh to highlight
  136038. */
  136039. removeExcludedMesh(mesh: Mesh): void;
  136040. /**
  136041. * Determine if a given mesh will be highlighted by the current HighlightLayer
  136042. * @param mesh mesh to test
  136043. * @returns true if the mesh will be highlighted by the current HighlightLayer
  136044. */
  136045. hasMesh(mesh: AbstractMesh): boolean;
  136046. /**
  136047. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  136048. * @param mesh The mesh to highlight
  136049. * @param color The color of the highlight
  136050. * @param glowEmissiveOnly Extract the glow from the emissive texture
  136051. */
  136052. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  136053. /**
  136054. * Remove a mesh from the highlight layer in order to make it stop glowing.
  136055. * @param mesh The mesh to highlight
  136056. */
  136057. removeMesh(mesh: Mesh): void;
  136058. /**
  136059. * Remove all the meshes currently referenced in the highlight layer
  136060. */
  136061. removeAllMeshes(): void;
  136062. /**
  136063. * Force the stencil to the normal expected value for none glowing parts
  136064. */
  136065. private _defaultStencilReference;
  136066. /**
  136067. * Free any resources and references associated to a mesh.
  136068. * Internal use
  136069. * @param mesh The mesh to free.
  136070. * @hidden
  136071. */
  136072. _disposeMesh(mesh: Mesh): void;
  136073. /**
  136074. * Dispose the highlight layer and free resources.
  136075. */
  136076. dispose(): void;
  136077. /**
  136078. * Gets the class name of the effect layer
  136079. * @returns the string with the class name of the effect layer
  136080. */
  136081. getClassName(): string;
  136082. /**
  136083. * Serializes this Highlight layer
  136084. * @returns a serialized Highlight layer object
  136085. */
  136086. serialize(): any;
  136087. /**
  136088. * Creates a Highlight layer from parsed Highlight layer data
  136089. * @param parsedHightlightLayer defines the Highlight layer data
  136090. * @param scene defines the current scene
  136091. * @param rootUrl defines the root URL containing the Highlight layer information
  136092. * @returns a parsed Highlight layer
  136093. */
  136094. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  136095. }
  136096. }
  136097. declare module BABYLON {
  136098. interface AbstractScene {
  136099. /**
  136100. * The list of layers (background and foreground) of the scene
  136101. */
  136102. layers: Array<Layer>;
  136103. }
  136104. /**
  136105. * Defines the layer scene component responsible to manage any layers
  136106. * in a given scene.
  136107. */
  136108. export class LayerSceneComponent implements ISceneComponent {
  136109. /**
  136110. * The component name helpfull to identify the component in the list of scene components.
  136111. */
  136112. readonly name: string;
  136113. /**
  136114. * The scene the component belongs to.
  136115. */
  136116. scene: Scene;
  136117. private _engine;
  136118. /**
  136119. * Creates a new instance of the component for the given scene
  136120. * @param scene Defines the scene to register the component in
  136121. */
  136122. constructor(scene: Scene);
  136123. /**
  136124. * Registers the component in a given scene
  136125. */
  136126. register(): void;
  136127. /**
  136128. * Rebuilds the elements related to this component in case of
  136129. * context lost for instance.
  136130. */
  136131. rebuild(): void;
  136132. /**
  136133. * Disposes the component and the associated ressources.
  136134. */
  136135. dispose(): void;
  136136. private _draw;
  136137. private _drawCameraPredicate;
  136138. private _drawCameraBackground;
  136139. private _drawCameraForeground;
  136140. private _drawRenderTargetPredicate;
  136141. private _drawRenderTargetBackground;
  136142. private _drawRenderTargetForeground;
  136143. /**
  136144. * Adds all the elements from the container to the scene
  136145. * @param container the container holding the elements
  136146. */
  136147. addFromContainer(container: AbstractScene): void;
  136148. /**
  136149. * Removes all the elements in the container from the scene
  136150. * @param container contains the elements to remove
  136151. * @param dispose if the removed element should be disposed (default: false)
  136152. */
  136153. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136154. }
  136155. }
  136156. declare module BABYLON {
  136157. /** @hidden */
  136158. export var layerPixelShader: {
  136159. name: string;
  136160. shader: string;
  136161. };
  136162. }
  136163. declare module BABYLON {
  136164. /** @hidden */
  136165. export var layerVertexShader: {
  136166. name: string;
  136167. shader: string;
  136168. };
  136169. }
  136170. declare module BABYLON {
  136171. /**
  136172. * This represents a full screen 2d layer.
  136173. * This can be useful to display a picture in the background of your scene for instance.
  136174. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136175. */
  136176. export class Layer {
  136177. /**
  136178. * Define the name of the layer.
  136179. */
  136180. name: string;
  136181. /**
  136182. * Define the texture the layer should display.
  136183. */
  136184. texture: Nullable<Texture>;
  136185. /**
  136186. * Is the layer in background or foreground.
  136187. */
  136188. isBackground: boolean;
  136189. /**
  136190. * Define the color of the layer (instead of texture).
  136191. */
  136192. color: Color4;
  136193. /**
  136194. * Define the scale of the layer in order to zoom in out of the texture.
  136195. */
  136196. scale: Vector2;
  136197. /**
  136198. * Define an offset for the layer in order to shift the texture.
  136199. */
  136200. offset: Vector2;
  136201. /**
  136202. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  136203. */
  136204. alphaBlendingMode: number;
  136205. /**
  136206. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  136207. * Alpha test will not mix with the background color in case of transparency.
  136208. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  136209. */
  136210. alphaTest: boolean;
  136211. /**
  136212. * Define a mask to restrict the layer to only some of the scene cameras.
  136213. */
  136214. layerMask: number;
  136215. /**
  136216. * Define the list of render target the layer is visible into.
  136217. */
  136218. renderTargetTextures: RenderTargetTexture[];
  136219. /**
  136220. * Define if the layer is only used in renderTarget or if it also
  136221. * renders in the main frame buffer of the canvas.
  136222. */
  136223. renderOnlyInRenderTargetTextures: boolean;
  136224. private _scene;
  136225. private _vertexBuffers;
  136226. private _indexBuffer;
  136227. private _effect;
  136228. private _previousDefines;
  136229. /**
  136230. * An event triggered when the layer is disposed.
  136231. */
  136232. onDisposeObservable: Observable<Layer>;
  136233. private _onDisposeObserver;
  136234. /**
  136235. * Back compatibility with callback before the onDisposeObservable existed.
  136236. * The set callback will be triggered when the layer has been disposed.
  136237. */
  136238. set onDispose(callback: () => void);
  136239. /**
  136240. * An event triggered before rendering the scene
  136241. */
  136242. onBeforeRenderObservable: Observable<Layer>;
  136243. private _onBeforeRenderObserver;
  136244. /**
  136245. * Back compatibility with callback before the onBeforeRenderObservable existed.
  136246. * The set callback will be triggered just before rendering the layer.
  136247. */
  136248. set onBeforeRender(callback: () => void);
  136249. /**
  136250. * An event triggered after rendering the scene
  136251. */
  136252. onAfterRenderObservable: Observable<Layer>;
  136253. private _onAfterRenderObserver;
  136254. /**
  136255. * Back compatibility with callback before the onAfterRenderObservable existed.
  136256. * The set callback will be triggered just after rendering the layer.
  136257. */
  136258. set onAfterRender(callback: () => void);
  136259. /**
  136260. * Instantiates a new layer.
  136261. * This represents a full screen 2d layer.
  136262. * This can be useful to display a picture in the background of your scene for instance.
  136263. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136264. * @param name Define the name of the layer in the scene
  136265. * @param imgUrl Define the url of the texture to display in the layer
  136266. * @param scene Define the scene the layer belongs to
  136267. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  136268. * @param color Defines a color for the layer
  136269. */
  136270. constructor(
  136271. /**
  136272. * Define the name of the layer.
  136273. */
  136274. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  136275. private _createIndexBuffer;
  136276. /** @hidden */
  136277. _rebuild(): void;
  136278. /**
  136279. * Renders the layer in the scene.
  136280. */
  136281. render(): void;
  136282. /**
  136283. * Disposes and releases the associated ressources.
  136284. */
  136285. dispose(): void;
  136286. }
  136287. }
  136288. declare module BABYLON {
  136289. /** @hidden */
  136290. export var lensFlarePixelShader: {
  136291. name: string;
  136292. shader: string;
  136293. };
  136294. }
  136295. declare module BABYLON {
  136296. /** @hidden */
  136297. export var lensFlareVertexShader: {
  136298. name: string;
  136299. shader: string;
  136300. };
  136301. }
  136302. declare module BABYLON {
  136303. /**
  136304. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  136305. * It is usually composed of several `lensFlare`.
  136306. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136307. */
  136308. export class LensFlareSystem {
  136309. /**
  136310. * Define the name of the lens flare system
  136311. */
  136312. name: string;
  136313. /**
  136314. * List of lens flares used in this system.
  136315. */
  136316. lensFlares: LensFlare[];
  136317. /**
  136318. * Define a limit from the border the lens flare can be visible.
  136319. */
  136320. borderLimit: number;
  136321. /**
  136322. * Define a viewport border we do not want to see the lens flare in.
  136323. */
  136324. viewportBorder: number;
  136325. /**
  136326. * Define a predicate which could limit the list of meshes able to occlude the effect.
  136327. */
  136328. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  136329. /**
  136330. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  136331. */
  136332. layerMask: number;
  136333. /**
  136334. * Define the id of the lens flare system in the scene.
  136335. * (equal to name by default)
  136336. */
  136337. id: string;
  136338. private _scene;
  136339. private _emitter;
  136340. private _vertexBuffers;
  136341. private _indexBuffer;
  136342. private _effect;
  136343. private _positionX;
  136344. private _positionY;
  136345. private _isEnabled;
  136346. /** @hidden */
  136347. static _SceneComponentInitialization: (scene: Scene) => void;
  136348. /**
  136349. * Instantiates a lens flare system.
  136350. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  136351. * It is usually composed of several `lensFlare`.
  136352. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136353. * @param name Define the name of the lens flare system in the scene
  136354. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  136355. * @param scene Define the scene the lens flare system belongs to
  136356. */
  136357. constructor(
  136358. /**
  136359. * Define the name of the lens flare system
  136360. */
  136361. name: string, emitter: any, scene: Scene);
  136362. /**
  136363. * Define if the lens flare system is enabled.
  136364. */
  136365. get isEnabled(): boolean;
  136366. set isEnabled(value: boolean);
  136367. /**
  136368. * Get the scene the effects belongs to.
  136369. * @returns the scene holding the lens flare system
  136370. */
  136371. getScene(): Scene;
  136372. /**
  136373. * Get the emitter of the lens flare system.
  136374. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  136375. * @returns the emitter of the lens flare system
  136376. */
  136377. getEmitter(): any;
  136378. /**
  136379. * Set the emitter of the lens flare system.
  136380. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  136381. * @param newEmitter Define the new emitter of the system
  136382. */
  136383. setEmitter(newEmitter: any): void;
  136384. /**
  136385. * Get the lens flare system emitter position.
  136386. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  136387. * @returns the position
  136388. */
  136389. getEmitterPosition(): Vector3;
  136390. /**
  136391. * @hidden
  136392. */
  136393. computeEffectivePosition(globalViewport: Viewport): boolean;
  136394. /** @hidden */
  136395. _isVisible(): boolean;
  136396. /**
  136397. * @hidden
  136398. */
  136399. render(): boolean;
  136400. /**
  136401. * Dispose and release the lens flare with its associated resources.
  136402. */
  136403. dispose(): void;
  136404. /**
  136405. * Parse a lens flare system from a JSON repressentation
  136406. * @param parsedLensFlareSystem Define the JSON to parse
  136407. * @param scene Define the scene the parsed system should be instantiated in
  136408. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  136409. * @returns the parsed system
  136410. */
  136411. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  136412. /**
  136413. * Serialize the current Lens Flare System into a JSON representation.
  136414. * @returns the serialized JSON
  136415. */
  136416. serialize(): any;
  136417. }
  136418. }
  136419. declare module BABYLON {
  136420. /**
  136421. * This represents one of the lens effect in a `lensFlareSystem`.
  136422. * It controls one of the indiviual texture used in the effect.
  136423. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136424. */
  136425. export class LensFlare {
  136426. /**
  136427. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136428. */
  136429. size: number;
  136430. /**
  136431. * 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.
  136432. */
  136433. position: number;
  136434. /**
  136435. * Define the lens color.
  136436. */
  136437. color: Color3;
  136438. /**
  136439. * Define the lens texture.
  136440. */
  136441. texture: Nullable<Texture>;
  136442. /**
  136443. * Define the alpha mode to render this particular lens.
  136444. */
  136445. alphaMode: number;
  136446. private _system;
  136447. /**
  136448. * Creates a new Lens Flare.
  136449. * This represents one of the lens effect in a `lensFlareSystem`.
  136450. * It controls one of the indiviual texture used in the effect.
  136451. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136452. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  136453. * @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.
  136454. * @param color Define the lens color
  136455. * @param imgUrl Define the lens texture url
  136456. * @param system Define the `lensFlareSystem` this flare is part of
  136457. * @returns The newly created Lens Flare
  136458. */
  136459. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  136460. /**
  136461. * Instantiates a new Lens Flare.
  136462. * This represents one of the lens effect in a `lensFlareSystem`.
  136463. * It controls one of the indiviual texture used in the effect.
  136464. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136465. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  136466. * @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.
  136467. * @param color Define the lens color
  136468. * @param imgUrl Define the lens texture url
  136469. * @param system Define the `lensFlareSystem` this flare is part of
  136470. */
  136471. constructor(
  136472. /**
  136473. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136474. */
  136475. size: number,
  136476. /**
  136477. * 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.
  136478. */
  136479. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  136480. /**
  136481. * Dispose and release the lens flare with its associated resources.
  136482. */
  136483. dispose(): void;
  136484. }
  136485. }
  136486. declare module BABYLON {
  136487. interface AbstractScene {
  136488. /**
  136489. * The list of lens flare system added to the scene
  136490. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136491. */
  136492. lensFlareSystems: Array<LensFlareSystem>;
  136493. /**
  136494. * Removes the given lens flare system from this scene.
  136495. * @param toRemove The lens flare system to remove
  136496. * @returns The index of the removed lens flare system
  136497. */
  136498. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  136499. /**
  136500. * Adds the given lens flare system to this scene
  136501. * @param newLensFlareSystem The lens flare system to add
  136502. */
  136503. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  136504. /**
  136505. * Gets a lens flare system using its name
  136506. * @param name defines the name to look for
  136507. * @returns the lens flare system or null if not found
  136508. */
  136509. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  136510. /**
  136511. * Gets a lens flare system using its id
  136512. * @param id defines the id to look for
  136513. * @returns the lens flare system or null if not found
  136514. */
  136515. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  136516. }
  136517. /**
  136518. * Defines the lens flare scene component responsible to manage any lens flares
  136519. * in a given scene.
  136520. */
  136521. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  136522. /**
  136523. * The component name helpfull to identify the component in the list of scene components.
  136524. */
  136525. readonly name: string;
  136526. /**
  136527. * The scene the component belongs to.
  136528. */
  136529. scene: Scene;
  136530. /**
  136531. * Creates a new instance of the component for the given scene
  136532. * @param scene Defines the scene to register the component in
  136533. */
  136534. constructor(scene: Scene);
  136535. /**
  136536. * Registers the component in a given scene
  136537. */
  136538. register(): void;
  136539. /**
  136540. * Rebuilds the elements related to this component in case of
  136541. * context lost for instance.
  136542. */
  136543. rebuild(): void;
  136544. /**
  136545. * Adds all the elements from the container to the scene
  136546. * @param container the container holding the elements
  136547. */
  136548. addFromContainer(container: AbstractScene): void;
  136549. /**
  136550. * Removes all the elements in the container from the scene
  136551. * @param container contains the elements to remove
  136552. * @param dispose if the removed element should be disposed (default: false)
  136553. */
  136554. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136555. /**
  136556. * Serializes the component data to the specified json object
  136557. * @param serializationObject The object to serialize to
  136558. */
  136559. serialize(serializationObject: any): void;
  136560. /**
  136561. * Disposes the component and the associated ressources.
  136562. */
  136563. dispose(): void;
  136564. private _draw;
  136565. }
  136566. }
  136567. declare module BABYLON {
  136568. /** @hidden */
  136569. export var depthPixelShader: {
  136570. name: string;
  136571. shader: string;
  136572. };
  136573. }
  136574. declare module BABYLON {
  136575. /** @hidden */
  136576. export var depthVertexShader: {
  136577. name: string;
  136578. shader: string;
  136579. };
  136580. }
  136581. declare module BABYLON {
  136582. /**
  136583. * This represents a depth renderer in Babylon.
  136584. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  136585. */
  136586. export class DepthRenderer {
  136587. private _scene;
  136588. private _depthMap;
  136589. private _effect;
  136590. private readonly _storeNonLinearDepth;
  136591. private readonly _clearColor;
  136592. /** Get if the depth renderer is using packed depth or not */
  136593. readonly isPacked: boolean;
  136594. private _cachedDefines;
  136595. private _camera;
  136596. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  136597. enabled: boolean;
  136598. /**
  136599. * Specifiess that the depth renderer will only be used within
  136600. * the camera it is created for.
  136601. * This can help forcing its rendering during the camera processing.
  136602. */
  136603. useOnlyInActiveCamera: boolean;
  136604. /** @hidden */
  136605. static _SceneComponentInitialization: (scene: Scene) => void;
  136606. /**
  136607. * Instantiates a depth renderer
  136608. * @param scene The scene the renderer belongs to
  136609. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  136610. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  136611. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  136612. */
  136613. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  136614. /**
  136615. * Creates the depth rendering effect and checks if the effect is ready.
  136616. * @param subMesh The submesh to be used to render the depth map of
  136617. * @param useInstances If multiple world instances should be used
  136618. * @returns if the depth renderer is ready to render the depth map
  136619. */
  136620. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136621. /**
  136622. * Gets the texture which the depth map will be written to.
  136623. * @returns The depth map texture
  136624. */
  136625. getDepthMap(): RenderTargetTexture;
  136626. /**
  136627. * Disposes of the depth renderer.
  136628. */
  136629. dispose(): void;
  136630. }
  136631. }
  136632. declare module BABYLON {
  136633. /** @hidden */
  136634. export var minmaxReduxPixelShader: {
  136635. name: string;
  136636. shader: string;
  136637. };
  136638. }
  136639. declare module BABYLON {
  136640. /**
  136641. * This class computes a min/max reduction from a texture: it means it computes the minimum
  136642. * and maximum values from all values of the texture.
  136643. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  136644. * The source values are read from the red channel of the texture.
  136645. */
  136646. export class MinMaxReducer {
  136647. /**
  136648. * Observable triggered when the computation has been performed
  136649. */
  136650. onAfterReductionPerformed: Observable<{
  136651. min: number;
  136652. max: number;
  136653. }>;
  136654. protected _camera: Camera;
  136655. protected _sourceTexture: Nullable<RenderTargetTexture>;
  136656. protected _reductionSteps: Nullable<Array<PostProcess>>;
  136657. protected _postProcessManager: PostProcessManager;
  136658. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  136659. protected _forceFullscreenViewport: boolean;
  136660. /**
  136661. * Creates a min/max reducer
  136662. * @param camera The camera to use for the post processes
  136663. */
  136664. constructor(camera: Camera);
  136665. /**
  136666. * Gets the texture used to read the values from.
  136667. */
  136668. get sourceTexture(): Nullable<RenderTargetTexture>;
  136669. /**
  136670. * Sets the source texture to read the values from.
  136671. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  136672. * because in such textures '1' value must not be taken into account to compute the maximum
  136673. * as this value is used to clear the texture.
  136674. * Note that the computation is not activated by calling this function, you must call activate() for that!
  136675. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  136676. * @param depthRedux Indicates if the texture is a depth texture or not
  136677. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  136678. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136679. */
  136680. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136681. /**
  136682. * Defines the refresh rate of the computation.
  136683. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136684. */
  136685. get refreshRate(): number;
  136686. set refreshRate(value: number);
  136687. protected _activated: boolean;
  136688. /**
  136689. * Gets the activation status of the reducer
  136690. */
  136691. get activated(): boolean;
  136692. /**
  136693. * Activates the reduction computation.
  136694. * When activated, the observers registered in onAfterReductionPerformed are
  136695. * called after the compuation is performed
  136696. */
  136697. activate(): void;
  136698. /**
  136699. * Deactivates the reduction computation.
  136700. */
  136701. deactivate(): void;
  136702. /**
  136703. * Disposes the min/max reducer
  136704. * @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.
  136705. */
  136706. dispose(disposeAll?: boolean): void;
  136707. }
  136708. }
  136709. declare module BABYLON {
  136710. /**
  136711. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  136712. */
  136713. export class DepthReducer extends MinMaxReducer {
  136714. private _depthRenderer;
  136715. private _depthRendererId;
  136716. /**
  136717. * Gets the depth renderer used for the computation.
  136718. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  136719. */
  136720. get depthRenderer(): Nullable<DepthRenderer>;
  136721. /**
  136722. * Creates a depth reducer
  136723. * @param camera The camera used to render the depth texture
  136724. */
  136725. constructor(camera: Camera);
  136726. /**
  136727. * Sets the depth renderer to use to generate the depth map
  136728. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  136729. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  136730. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136731. */
  136732. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  136733. /** @hidden */
  136734. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136735. /**
  136736. * Activates the reduction computation.
  136737. * When activated, the observers registered in onAfterReductionPerformed are
  136738. * called after the compuation is performed
  136739. */
  136740. activate(): void;
  136741. /**
  136742. * Deactivates the reduction computation.
  136743. */
  136744. deactivate(): void;
  136745. /**
  136746. * Disposes the depth reducer
  136747. * @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.
  136748. */
  136749. dispose(disposeAll?: boolean): void;
  136750. }
  136751. }
  136752. declare module BABYLON {
  136753. /**
  136754. * A CSM implementation allowing casting shadows on large scenes.
  136755. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136756. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  136757. */
  136758. export class CascadedShadowGenerator extends ShadowGenerator {
  136759. private static readonly frustumCornersNDCSpace;
  136760. /**
  136761. * Name of the CSM class
  136762. */
  136763. static CLASSNAME: string;
  136764. /**
  136765. * Defines the default number of cascades used by the CSM.
  136766. */
  136767. static readonly DEFAULT_CASCADES_COUNT: number;
  136768. /**
  136769. * Defines the minimum number of cascades used by the CSM.
  136770. */
  136771. static readonly MIN_CASCADES_COUNT: number;
  136772. /**
  136773. * Defines the maximum number of cascades used by the CSM.
  136774. */
  136775. static readonly MAX_CASCADES_COUNT: number;
  136776. protected _validateFilter(filter: number): number;
  136777. /**
  136778. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  136779. */
  136780. penumbraDarkness: number;
  136781. private _numCascades;
  136782. /**
  136783. * Gets or set the number of cascades used by the CSM.
  136784. */
  136785. get numCascades(): number;
  136786. set numCascades(value: number);
  136787. /**
  136788. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  136789. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  136790. */
  136791. stabilizeCascades: boolean;
  136792. private _freezeShadowCastersBoundingInfo;
  136793. private _freezeShadowCastersBoundingInfoObservable;
  136794. /**
  136795. * Enables or disables the shadow casters bounding info computation.
  136796. * If your shadow casters don't move, you can disable this feature.
  136797. * If it is enabled, the bounding box computation is done every frame.
  136798. */
  136799. get freezeShadowCastersBoundingInfo(): boolean;
  136800. set freezeShadowCastersBoundingInfo(freeze: boolean);
  136801. private _scbiMin;
  136802. private _scbiMax;
  136803. protected _computeShadowCastersBoundingInfo(): void;
  136804. protected _shadowCastersBoundingInfo: BoundingInfo;
  136805. /**
  136806. * Gets or sets the shadow casters bounding info.
  136807. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  136808. * so that the system won't overwrite the bounds you provide
  136809. */
  136810. get shadowCastersBoundingInfo(): BoundingInfo;
  136811. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  136812. protected _breaksAreDirty: boolean;
  136813. protected _minDistance: number;
  136814. protected _maxDistance: number;
  136815. /**
  136816. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  136817. *
  136818. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  136819. * If you don't know these values, simply leave them to their defaults and don't call this function.
  136820. * @param min minimal distance for the breaks (default to 0.)
  136821. * @param max maximal distance for the breaks (default to 1.)
  136822. */
  136823. setMinMaxDistance(min: number, max: number): void;
  136824. /** Gets the minimal distance used in the cascade break computation */
  136825. get minDistance(): number;
  136826. /** Gets the maximal distance used in the cascade break computation */
  136827. get maxDistance(): number;
  136828. /**
  136829. * Gets the class name of that object
  136830. * @returns "CascadedShadowGenerator"
  136831. */
  136832. getClassName(): string;
  136833. private _cascadeMinExtents;
  136834. private _cascadeMaxExtents;
  136835. /**
  136836. * Gets a cascade minimum extents
  136837. * @param cascadeIndex index of the cascade
  136838. * @returns the minimum cascade extents
  136839. */
  136840. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  136841. /**
  136842. * Gets a cascade maximum extents
  136843. * @param cascadeIndex index of the cascade
  136844. * @returns the maximum cascade extents
  136845. */
  136846. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  136847. private _cascades;
  136848. private _currentLayer;
  136849. private _viewSpaceFrustumsZ;
  136850. private _viewMatrices;
  136851. private _projectionMatrices;
  136852. private _transformMatrices;
  136853. private _transformMatricesAsArray;
  136854. private _frustumLengths;
  136855. private _lightSizeUVCorrection;
  136856. private _depthCorrection;
  136857. private _frustumCornersWorldSpace;
  136858. private _frustumCenter;
  136859. private _shadowCameraPos;
  136860. private _shadowMaxZ;
  136861. /**
  136862. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  136863. * It defaults to camera.maxZ
  136864. */
  136865. get shadowMaxZ(): number;
  136866. /**
  136867. * Sets the shadow max z distance.
  136868. */
  136869. set shadowMaxZ(value: number);
  136870. protected _debug: boolean;
  136871. /**
  136872. * Gets or sets the debug flag.
  136873. * When enabled, the cascades are materialized by different colors on the screen.
  136874. */
  136875. get debug(): boolean;
  136876. set debug(dbg: boolean);
  136877. private _depthClamp;
  136878. /**
  136879. * Gets or sets the depth clamping value.
  136880. *
  136881. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  136882. * to account for the shadow casters far away.
  136883. *
  136884. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  136885. */
  136886. get depthClamp(): boolean;
  136887. set depthClamp(value: boolean);
  136888. private _cascadeBlendPercentage;
  136889. /**
  136890. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  136891. * It defaults to 0.1 (10% blending).
  136892. */
  136893. get cascadeBlendPercentage(): number;
  136894. set cascadeBlendPercentage(value: number);
  136895. private _lambda;
  136896. /**
  136897. * Gets or set the lambda parameter.
  136898. * This parameter is used to split the camera frustum and create the cascades.
  136899. * 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.
  136900. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  136901. */
  136902. get lambda(): number;
  136903. set lambda(value: number);
  136904. /**
  136905. * Gets the view matrix corresponding to a given cascade
  136906. * @param cascadeNum cascade to retrieve the view matrix from
  136907. * @returns the cascade view matrix
  136908. */
  136909. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  136910. /**
  136911. * Gets the projection matrix corresponding to a given cascade
  136912. * @param cascadeNum cascade to retrieve the projection matrix from
  136913. * @returns the cascade projection matrix
  136914. */
  136915. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  136916. /**
  136917. * Gets the transformation matrix corresponding to a given cascade
  136918. * @param cascadeNum cascade to retrieve the transformation matrix from
  136919. * @returns the cascade transformation matrix
  136920. */
  136921. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  136922. private _depthRenderer;
  136923. /**
  136924. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  136925. *
  136926. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  136927. *
  136928. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  136929. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  136930. * @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
  136931. */
  136932. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  136933. private _depthReducer;
  136934. private _autoCalcDepthBounds;
  136935. /**
  136936. * Gets or sets the autoCalcDepthBounds property.
  136937. *
  136938. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  136939. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  136940. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  136941. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  136942. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  136943. */
  136944. get autoCalcDepthBounds(): boolean;
  136945. set autoCalcDepthBounds(value: boolean);
  136946. /**
  136947. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  136948. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136949. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  136950. * for setting the refresh rate on the renderer yourself!
  136951. */
  136952. get autoCalcDepthBoundsRefreshRate(): number;
  136953. set autoCalcDepthBoundsRefreshRate(value: number);
  136954. /**
  136955. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  136956. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  136957. * you change the camera near/far planes!
  136958. */
  136959. splitFrustum(): void;
  136960. private _splitFrustum;
  136961. private _computeMatrices;
  136962. private _computeFrustumInWorldSpace;
  136963. private _computeCascadeFrustum;
  136964. /**
  136965. * Support test.
  136966. */
  136967. static get IsSupported(): boolean;
  136968. /** @hidden */
  136969. static _SceneComponentInitialization: (scene: Scene) => void;
  136970. /**
  136971. * Creates a Cascaded Shadow Generator object.
  136972. * A ShadowGenerator is the required tool to use the shadows.
  136973. * Each directional light casting shadows needs to use its own ShadowGenerator.
  136974. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136975. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  136976. * @param light The directional light object generating the shadows.
  136977. * @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.
  136978. */
  136979. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  136980. protected _initializeGenerator(): void;
  136981. protected _createTargetRenderTexture(): void;
  136982. protected _initializeShadowMap(): void;
  136983. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  136984. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  136985. /**
  136986. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  136987. * @param defines Defines of the material we want to update
  136988. * @param lightIndex Index of the light in the enabled light list of the material
  136989. */
  136990. prepareDefines(defines: any, lightIndex: number): void;
  136991. /**
  136992. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  136993. * defined in the generator but impacting the effect).
  136994. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  136995. * @param effect The effect we are binfing the information for
  136996. */
  136997. bindShadowLight(lightIndex: string, effect: Effect): void;
  136998. /**
  136999. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  137000. * (eq to view projection * shadow projection matrices)
  137001. * @returns The transform matrix used to create the shadow map
  137002. */
  137003. getTransformMatrix(): Matrix;
  137004. /**
  137005. * Disposes the ShadowGenerator.
  137006. * Returns nothing.
  137007. */
  137008. dispose(): void;
  137009. /**
  137010. * Serializes the shadow generator setup to a json object.
  137011. * @returns The serialized JSON object
  137012. */
  137013. serialize(): any;
  137014. /**
  137015. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  137016. * @param parsedShadowGenerator The JSON object to parse
  137017. * @param scene The scene to create the shadow map for
  137018. * @returns The parsed shadow generator
  137019. */
  137020. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  137021. }
  137022. }
  137023. declare module BABYLON {
  137024. /**
  137025. * Defines the shadow generator component responsible to manage any shadow generators
  137026. * in a given scene.
  137027. */
  137028. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  137029. /**
  137030. * The component name helpfull to identify the component in the list of scene components.
  137031. */
  137032. readonly name: string;
  137033. /**
  137034. * The scene the component belongs to.
  137035. */
  137036. scene: Scene;
  137037. /**
  137038. * Creates a new instance of the component for the given scene
  137039. * @param scene Defines the scene to register the component in
  137040. */
  137041. constructor(scene: Scene);
  137042. /**
  137043. * Registers the component in a given scene
  137044. */
  137045. register(): void;
  137046. /**
  137047. * Rebuilds the elements related to this component in case of
  137048. * context lost for instance.
  137049. */
  137050. rebuild(): void;
  137051. /**
  137052. * Serializes the component data to the specified json object
  137053. * @param serializationObject The object to serialize to
  137054. */
  137055. serialize(serializationObject: any): void;
  137056. /**
  137057. * Adds all the elements from the container to the scene
  137058. * @param container the container holding the elements
  137059. */
  137060. addFromContainer(container: AbstractScene): void;
  137061. /**
  137062. * Removes all the elements in the container from the scene
  137063. * @param container contains the elements to remove
  137064. * @param dispose if the removed element should be disposed (default: false)
  137065. */
  137066. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137067. /**
  137068. * Rebuilds the elements related to this component in case of
  137069. * context lost for instance.
  137070. */
  137071. dispose(): void;
  137072. private _gatherRenderTargets;
  137073. }
  137074. }
  137075. declare module BABYLON {
  137076. /**
  137077. * A point light is a light defined by an unique point in world space.
  137078. * The light is emitted in every direction from this point.
  137079. * A good example of a point light is a standard light bulb.
  137080. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137081. */
  137082. export class PointLight extends ShadowLight {
  137083. private _shadowAngle;
  137084. /**
  137085. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137086. * This specifies what angle the shadow will use to be created.
  137087. *
  137088. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137089. */
  137090. get shadowAngle(): number;
  137091. /**
  137092. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137093. * This specifies what angle the shadow will use to be created.
  137094. *
  137095. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137096. */
  137097. set shadowAngle(value: number);
  137098. /**
  137099. * Gets the direction if it has been set.
  137100. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137101. */
  137102. get direction(): Vector3;
  137103. /**
  137104. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137105. */
  137106. set direction(value: Vector3);
  137107. /**
  137108. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  137109. * A PointLight emits the light in every direction.
  137110. * It can cast shadows.
  137111. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  137112. * ```javascript
  137113. * var pointLight = new PointLight("pl", camera.position, scene);
  137114. * ```
  137115. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137116. * @param name The light friendly name
  137117. * @param position The position of the point light in the scene
  137118. * @param scene The scene the lights belongs to
  137119. */
  137120. constructor(name: string, position: Vector3, scene: Scene);
  137121. /**
  137122. * Returns the string "PointLight"
  137123. * @returns the class name
  137124. */
  137125. getClassName(): string;
  137126. /**
  137127. * Returns the integer 0.
  137128. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137129. */
  137130. getTypeID(): number;
  137131. /**
  137132. * Specifies wether or not the shadowmap should be a cube texture.
  137133. * @returns true if the shadowmap needs to be a cube texture.
  137134. */
  137135. needCube(): boolean;
  137136. /**
  137137. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  137138. * @param faceIndex The index of the face we are computed the direction to generate shadow
  137139. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  137140. */
  137141. getShadowDirection(faceIndex?: number): Vector3;
  137142. /**
  137143. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  137144. * - fov = PI / 2
  137145. * - aspect ratio : 1.0
  137146. * - z-near and far equal to the active camera minZ and maxZ.
  137147. * Returns the PointLight.
  137148. */
  137149. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137150. protected _buildUniformLayout(): void;
  137151. /**
  137152. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  137153. * @param effect The effect to update
  137154. * @param lightIndex The index of the light in the effect to update
  137155. * @returns The point light
  137156. */
  137157. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  137158. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  137159. /**
  137160. * Prepares the list of defines specific to the light type.
  137161. * @param defines the list of defines
  137162. * @param lightIndex defines the index of the light for the effect
  137163. */
  137164. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137165. }
  137166. }
  137167. declare module BABYLON {
  137168. /**
  137169. * Header information of HDR texture files.
  137170. */
  137171. export interface HDRInfo {
  137172. /**
  137173. * The height of the texture in pixels.
  137174. */
  137175. height: number;
  137176. /**
  137177. * The width of the texture in pixels.
  137178. */
  137179. width: number;
  137180. /**
  137181. * The index of the beginning of the data in the binary file.
  137182. */
  137183. dataPosition: number;
  137184. }
  137185. /**
  137186. * This groups tools to convert HDR texture to native colors array.
  137187. */
  137188. export class HDRTools {
  137189. private static Ldexp;
  137190. private static Rgbe2float;
  137191. private static readStringLine;
  137192. /**
  137193. * Reads header information from an RGBE texture stored in a native array.
  137194. * More information on this format are available here:
  137195. * https://en.wikipedia.org/wiki/RGBE_image_format
  137196. *
  137197. * @param uint8array The binary file stored in native array.
  137198. * @return The header information.
  137199. */
  137200. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  137201. /**
  137202. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  137203. * This RGBE texture needs to store the information as a panorama.
  137204. *
  137205. * More information on this format are available here:
  137206. * https://en.wikipedia.org/wiki/RGBE_image_format
  137207. *
  137208. * @param buffer The binary file stored in an array buffer.
  137209. * @param size The expected size of the extracted cubemap.
  137210. * @return The Cube Map information.
  137211. */
  137212. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  137213. /**
  137214. * Returns the pixels data extracted from an RGBE texture.
  137215. * This pixels will be stored left to right up to down in the R G B order in one array.
  137216. *
  137217. * More information on this format are available here:
  137218. * https://en.wikipedia.org/wiki/RGBE_image_format
  137219. *
  137220. * @param uint8array The binary file stored in an array buffer.
  137221. * @param hdrInfo The header information of the file.
  137222. * @return The pixels data in RGB right to left up to down order.
  137223. */
  137224. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  137225. private static RGBE_ReadPixels_RLE;
  137226. }
  137227. }
  137228. declare module BABYLON {
  137229. /**
  137230. * Effect Render Options
  137231. */
  137232. export interface IEffectRendererOptions {
  137233. /**
  137234. * Defines the vertices positions.
  137235. */
  137236. positions?: number[];
  137237. /**
  137238. * Defines the indices.
  137239. */
  137240. indices?: number[];
  137241. }
  137242. /**
  137243. * Helper class to render one or more effects.
  137244. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  137245. */
  137246. export class EffectRenderer {
  137247. private engine;
  137248. private static _DefaultOptions;
  137249. private _vertexBuffers;
  137250. private _indexBuffer;
  137251. private _fullscreenViewport;
  137252. /**
  137253. * Creates an effect renderer
  137254. * @param engine the engine to use for rendering
  137255. * @param options defines the options of the effect renderer
  137256. */
  137257. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  137258. /**
  137259. * Sets the current viewport in normalized coordinates 0-1
  137260. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  137261. */
  137262. setViewport(viewport?: Viewport): void;
  137263. /**
  137264. * Binds the embedded attributes buffer to the effect.
  137265. * @param effect Defines the effect to bind the attributes for
  137266. */
  137267. bindBuffers(effect: Effect): void;
  137268. /**
  137269. * Sets the current effect wrapper to use during draw.
  137270. * The effect needs to be ready before calling this api.
  137271. * This also sets the default full screen position attribute.
  137272. * @param effectWrapper Defines the effect to draw with
  137273. */
  137274. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  137275. /**
  137276. * Restores engine states
  137277. */
  137278. restoreStates(): void;
  137279. /**
  137280. * Draws a full screen quad.
  137281. */
  137282. draw(): void;
  137283. private isRenderTargetTexture;
  137284. /**
  137285. * renders one or more effects to a specified texture
  137286. * @param effectWrapper the effect to renderer
  137287. * @param outputTexture texture to draw to, if null it will render to the screen.
  137288. */
  137289. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  137290. /**
  137291. * Disposes of the effect renderer
  137292. */
  137293. dispose(): void;
  137294. }
  137295. /**
  137296. * Options to create an EffectWrapper
  137297. */
  137298. interface EffectWrapperCreationOptions {
  137299. /**
  137300. * Engine to use to create the effect
  137301. */
  137302. engine: ThinEngine;
  137303. /**
  137304. * Fragment shader for the effect
  137305. */
  137306. fragmentShader: string;
  137307. /**
  137308. * Use the shader store instead of direct source code
  137309. */
  137310. useShaderStore?: boolean;
  137311. /**
  137312. * Vertex shader for the effect
  137313. */
  137314. vertexShader?: string;
  137315. /**
  137316. * Attributes to use in the shader
  137317. */
  137318. attributeNames?: Array<string>;
  137319. /**
  137320. * Uniforms to use in the shader
  137321. */
  137322. uniformNames?: Array<string>;
  137323. /**
  137324. * Texture sampler names to use in the shader
  137325. */
  137326. samplerNames?: Array<string>;
  137327. /**
  137328. * Defines to use in the shader
  137329. */
  137330. defines?: Array<string>;
  137331. /**
  137332. * Callback when effect is compiled
  137333. */
  137334. onCompiled?: Nullable<(effect: Effect) => void>;
  137335. /**
  137336. * The friendly name of the effect displayed in Spector.
  137337. */
  137338. name?: string;
  137339. }
  137340. /**
  137341. * Wraps an effect to be used for rendering
  137342. */
  137343. export class EffectWrapper {
  137344. /**
  137345. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  137346. */
  137347. onApplyObservable: Observable<{}>;
  137348. /**
  137349. * The underlying effect
  137350. */
  137351. effect: Effect;
  137352. /**
  137353. * Creates an effect to be renderer
  137354. * @param creationOptions options to create the effect
  137355. */
  137356. constructor(creationOptions: EffectWrapperCreationOptions);
  137357. /**
  137358. * Disposes of the effect wrapper
  137359. */
  137360. dispose(): void;
  137361. }
  137362. }
  137363. declare module BABYLON {
  137364. /** @hidden */
  137365. export var hdrFilteringVertexShader: {
  137366. name: string;
  137367. shader: string;
  137368. };
  137369. }
  137370. declare module BABYLON {
  137371. /** @hidden */
  137372. export var hdrFilteringPixelShader: {
  137373. name: string;
  137374. shader: string;
  137375. };
  137376. }
  137377. declare module BABYLON {
  137378. /**
  137379. * Options for texture filtering
  137380. */
  137381. interface IHDRFilteringOptions {
  137382. /**
  137383. * Scales pixel intensity for the input HDR map.
  137384. */
  137385. hdrScale?: number;
  137386. /**
  137387. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  137388. */
  137389. quality?: number;
  137390. }
  137391. /**
  137392. * Filters HDR maps to get correct renderings of PBR reflections
  137393. */
  137394. export class HDRFiltering {
  137395. private _engine;
  137396. private _effectRenderer;
  137397. private _effectWrapper;
  137398. private _lodGenerationOffset;
  137399. private _lodGenerationScale;
  137400. /**
  137401. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  137402. * you care about baking speed.
  137403. */
  137404. quality: number;
  137405. /**
  137406. * Scales pixel intensity for the input HDR map.
  137407. */
  137408. hdrScale: number;
  137409. /**
  137410. * Instantiates HDR filter for reflection maps
  137411. *
  137412. * @param engine Thin engine
  137413. * @param options Options
  137414. */
  137415. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  137416. private _createRenderTarget;
  137417. private _prefilterInternal;
  137418. private _createEffect;
  137419. /**
  137420. * Get a value indicating if the filter is ready to be used
  137421. * @param texture Texture to filter
  137422. * @returns true if the filter is ready
  137423. */
  137424. isReady(texture: BaseTexture): boolean;
  137425. /**
  137426. * Prefilters a cube texture to have mipmap levels representing roughness values.
  137427. * Prefiltering will be invoked at the end of next rendering pass.
  137428. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  137429. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  137430. * @param texture Texture to filter
  137431. * @param onFinished Callback when filtering is done
  137432. * @return Promise called when prefiltering is done
  137433. */
  137434. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  137435. }
  137436. }
  137437. declare module BABYLON {
  137438. /**
  137439. * This represents a texture coming from an HDR input.
  137440. *
  137441. * The only supported format is currently panorama picture stored in RGBE format.
  137442. * Example of such files can be found on HDRLib: http://hdrlib.com/
  137443. */
  137444. export class HDRCubeTexture extends BaseTexture {
  137445. private static _facesMapping;
  137446. private _generateHarmonics;
  137447. private _noMipmap;
  137448. private _prefilterOnLoad;
  137449. private _textureMatrix;
  137450. private _size;
  137451. private _onLoad;
  137452. private _onError;
  137453. /**
  137454. * The texture URL.
  137455. */
  137456. url: string;
  137457. /**
  137458. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  137459. */
  137460. coordinatesMode: number;
  137461. protected _isBlocking: boolean;
  137462. /**
  137463. * Sets wether or not the texture is blocking during loading.
  137464. */
  137465. set isBlocking(value: boolean);
  137466. /**
  137467. * Gets wether or not the texture is blocking during loading.
  137468. */
  137469. get isBlocking(): boolean;
  137470. protected _rotationY: number;
  137471. /**
  137472. * Sets texture matrix rotation angle around Y axis in radians.
  137473. */
  137474. set rotationY(value: number);
  137475. /**
  137476. * Gets texture matrix rotation angle around Y axis radians.
  137477. */
  137478. get rotationY(): number;
  137479. /**
  137480. * Gets or sets the center of the bounding box associated with the cube texture
  137481. * It must define where the camera used to render the texture was set
  137482. */
  137483. boundingBoxPosition: Vector3;
  137484. private _boundingBoxSize;
  137485. /**
  137486. * Gets or sets the size of the bounding box associated with the cube texture
  137487. * When defined, the cubemap will switch to local mode
  137488. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  137489. * @example https://www.babylonjs-playground.com/#RNASML
  137490. */
  137491. set boundingBoxSize(value: Vector3);
  137492. get boundingBoxSize(): Vector3;
  137493. /**
  137494. * Instantiates an HDRTexture from the following parameters.
  137495. *
  137496. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  137497. * @param sceneOrEngine The scene or engine the texture will be used in
  137498. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137499. * @param noMipmap Forces to not generate the mipmap if true
  137500. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  137501. * @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)
  137502. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  137503. */
  137504. 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>);
  137505. /**
  137506. * Get the current class name of the texture useful for serialization or dynamic coding.
  137507. * @returns "HDRCubeTexture"
  137508. */
  137509. getClassName(): string;
  137510. /**
  137511. * Occurs when the file is raw .hdr file.
  137512. */
  137513. private loadTexture;
  137514. clone(): HDRCubeTexture;
  137515. delayLoad(): void;
  137516. /**
  137517. * Get the texture reflection matrix used to rotate/transform the reflection.
  137518. * @returns the reflection matrix
  137519. */
  137520. getReflectionTextureMatrix(): Matrix;
  137521. /**
  137522. * Set the texture reflection matrix used to rotate/transform the reflection.
  137523. * @param value Define the reflection matrix to set
  137524. */
  137525. setReflectionTextureMatrix(value: Matrix): void;
  137526. /**
  137527. * Parses a JSON representation of an HDR Texture in order to create the texture
  137528. * @param parsedTexture Define the JSON representation
  137529. * @param scene Define the scene the texture should be created in
  137530. * @param rootUrl Define the root url in case we need to load relative dependencies
  137531. * @returns the newly created texture after parsing
  137532. */
  137533. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  137534. serialize(): any;
  137535. }
  137536. }
  137537. declare module BABYLON {
  137538. /**
  137539. * Class used to control physics engine
  137540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137541. */
  137542. export class PhysicsEngine implements IPhysicsEngine {
  137543. private _physicsPlugin;
  137544. /**
  137545. * Global value used to control the smallest number supported by the simulation
  137546. */
  137547. static Epsilon: number;
  137548. private _impostors;
  137549. private _joints;
  137550. private _subTimeStep;
  137551. /**
  137552. * Gets the gravity vector used by the simulation
  137553. */
  137554. gravity: Vector3;
  137555. /**
  137556. * Factory used to create the default physics plugin.
  137557. * @returns The default physics plugin
  137558. */
  137559. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  137560. /**
  137561. * Creates a new Physics Engine
  137562. * @param gravity defines the gravity vector used by the simulation
  137563. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  137564. */
  137565. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  137566. /**
  137567. * Sets the gravity vector used by the simulation
  137568. * @param gravity defines the gravity vector to use
  137569. */
  137570. setGravity(gravity: Vector3): void;
  137571. /**
  137572. * Set the time step of the physics engine.
  137573. * Default is 1/60.
  137574. * To slow it down, enter 1/600 for example.
  137575. * To speed it up, 1/30
  137576. * @param newTimeStep defines the new timestep to apply to this world.
  137577. */
  137578. setTimeStep(newTimeStep?: number): void;
  137579. /**
  137580. * Get the time step of the physics engine.
  137581. * @returns the current time step
  137582. */
  137583. getTimeStep(): number;
  137584. /**
  137585. * Set the sub time step of the physics engine.
  137586. * Default is 0 meaning there is no sub steps
  137587. * To increase physics resolution precision, set a small value (like 1 ms)
  137588. * @param subTimeStep defines the new sub timestep used for physics resolution.
  137589. */
  137590. setSubTimeStep(subTimeStep?: number): void;
  137591. /**
  137592. * Get the sub time step of the physics engine.
  137593. * @returns the current sub time step
  137594. */
  137595. getSubTimeStep(): number;
  137596. /**
  137597. * Release all resources
  137598. */
  137599. dispose(): void;
  137600. /**
  137601. * Gets the name of the current physics plugin
  137602. * @returns the name of the plugin
  137603. */
  137604. getPhysicsPluginName(): string;
  137605. /**
  137606. * Adding a new impostor for the impostor tracking.
  137607. * This will be done by the impostor itself.
  137608. * @param impostor the impostor to add
  137609. */
  137610. addImpostor(impostor: PhysicsImpostor): void;
  137611. /**
  137612. * Remove an impostor from the engine.
  137613. * This impostor and its mesh will not longer be updated by the physics engine.
  137614. * @param impostor the impostor to remove
  137615. */
  137616. removeImpostor(impostor: PhysicsImpostor): void;
  137617. /**
  137618. * Add a joint to the physics engine
  137619. * @param mainImpostor defines the main impostor to which the joint is added.
  137620. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  137621. * @param joint defines the joint that will connect both impostors.
  137622. */
  137623. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137624. /**
  137625. * Removes a joint from the simulation
  137626. * @param mainImpostor defines the impostor used with the joint
  137627. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  137628. * @param joint defines the joint to remove
  137629. */
  137630. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137631. /**
  137632. * Called by the scene. No need to call it.
  137633. * @param delta defines the timespam between frames
  137634. */
  137635. _step(delta: number): void;
  137636. /**
  137637. * Gets the current plugin used to run the simulation
  137638. * @returns current plugin
  137639. */
  137640. getPhysicsPlugin(): IPhysicsEnginePlugin;
  137641. /**
  137642. * Gets the list of physic impostors
  137643. * @returns an array of PhysicsImpostor
  137644. */
  137645. getImpostors(): Array<PhysicsImpostor>;
  137646. /**
  137647. * Gets the impostor for a physics enabled object
  137648. * @param object defines the object impersonated by the impostor
  137649. * @returns the PhysicsImpostor or null if not found
  137650. */
  137651. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  137652. /**
  137653. * Gets the impostor for a physics body object
  137654. * @param body defines physics body used by the impostor
  137655. * @returns the PhysicsImpostor or null if not found
  137656. */
  137657. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  137658. /**
  137659. * Does a raycast in the physics world
  137660. * @param from when should the ray start?
  137661. * @param to when should the ray end?
  137662. * @returns PhysicsRaycastResult
  137663. */
  137664. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137665. }
  137666. }
  137667. declare module BABYLON {
  137668. /** @hidden */
  137669. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  137670. private _useDeltaForWorldStep;
  137671. world: any;
  137672. name: string;
  137673. private _physicsMaterials;
  137674. private _fixedTimeStep;
  137675. private _cannonRaycastResult;
  137676. private _raycastResult;
  137677. private _physicsBodysToRemoveAfterStep;
  137678. private _firstFrame;
  137679. BJSCANNON: any;
  137680. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  137681. setGravity(gravity: Vector3): void;
  137682. setTimeStep(timeStep: number): void;
  137683. getTimeStep(): number;
  137684. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137685. private _removeMarkedPhysicsBodiesFromWorld;
  137686. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137687. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137688. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137689. private _processChildMeshes;
  137690. removePhysicsBody(impostor: PhysicsImpostor): void;
  137691. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137692. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137693. private _addMaterial;
  137694. private _checkWithEpsilon;
  137695. private _createShape;
  137696. private _createHeightmap;
  137697. private _minus90X;
  137698. private _plus90X;
  137699. private _tmpPosition;
  137700. private _tmpDeltaPosition;
  137701. private _tmpUnityRotation;
  137702. private _updatePhysicsBodyTransformation;
  137703. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137704. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137705. isSupported(): boolean;
  137706. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137707. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137708. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137709. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137710. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137711. getBodyMass(impostor: PhysicsImpostor): number;
  137712. getBodyFriction(impostor: PhysicsImpostor): number;
  137713. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137714. getBodyRestitution(impostor: PhysicsImpostor): number;
  137715. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137716. sleepBody(impostor: PhysicsImpostor): void;
  137717. wakeUpBody(impostor: PhysicsImpostor): void;
  137718. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  137719. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137720. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137721. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137722. getRadius(impostor: PhysicsImpostor): number;
  137723. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137724. dispose(): void;
  137725. private _extendNamespace;
  137726. /**
  137727. * Does a raycast in the physics world
  137728. * @param from when should the ray start?
  137729. * @param to when should the ray end?
  137730. * @returns PhysicsRaycastResult
  137731. */
  137732. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137733. }
  137734. }
  137735. declare module BABYLON {
  137736. /** @hidden */
  137737. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  137738. private _useDeltaForWorldStep;
  137739. world: any;
  137740. name: string;
  137741. BJSOIMO: any;
  137742. private _raycastResult;
  137743. private _fixedTimeStep;
  137744. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  137745. setGravity(gravity: Vector3): void;
  137746. setTimeStep(timeStep: number): void;
  137747. getTimeStep(): number;
  137748. private _tmpImpostorsArray;
  137749. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137750. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137751. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137752. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137753. private _tmpPositionVector;
  137754. removePhysicsBody(impostor: PhysicsImpostor): void;
  137755. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137756. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137757. isSupported(): boolean;
  137758. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137759. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137760. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137761. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137762. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137763. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137764. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137765. getBodyMass(impostor: PhysicsImpostor): number;
  137766. getBodyFriction(impostor: PhysicsImpostor): number;
  137767. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137768. getBodyRestitution(impostor: PhysicsImpostor): number;
  137769. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137770. sleepBody(impostor: PhysicsImpostor): void;
  137771. wakeUpBody(impostor: PhysicsImpostor): void;
  137772. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137773. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  137774. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  137775. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137776. getRadius(impostor: PhysicsImpostor): number;
  137777. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137778. dispose(): void;
  137779. /**
  137780. * Does a raycast in the physics world
  137781. * @param from when should the ray start?
  137782. * @param to when should the ray end?
  137783. * @returns PhysicsRaycastResult
  137784. */
  137785. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137786. }
  137787. }
  137788. declare module BABYLON {
  137789. /**
  137790. * Class containing static functions to help procedurally build meshes
  137791. */
  137792. export class RibbonBuilder {
  137793. /**
  137794. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137795. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  137796. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  137797. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  137798. * * 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
  137799. * * 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
  137800. * * 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
  137801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137802. * * 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
  137803. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137804. * * 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
  137805. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  137806. * * 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
  137807. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  137808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137809. * @param name defines the name of the mesh
  137810. * @param options defines the options used to create the mesh
  137811. * @param scene defines the hosting scene
  137812. * @returns the ribbon mesh
  137813. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  137814. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137815. */
  137816. static CreateRibbon(name: string, options: {
  137817. pathArray: Vector3[][];
  137818. closeArray?: boolean;
  137819. closePath?: boolean;
  137820. offset?: number;
  137821. updatable?: boolean;
  137822. sideOrientation?: number;
  137823. frontUVs?: Vector4;
  137824. backUVs?: Vector4;
  137825. instance?: Mesh;
  137826. invertUV?: boolean;
  137827. uvs?: Vector2[];
  137828. colors?: Color4[];
  137829. }, scene?: Nullable<Scene>): Mesh;
  137830. }
  137831. }
  137832. declare module BABYLON {
  137833. /**
  137834. * Class containing static functions to help procedurally build meshes
  137835. */
  137836. export class ShapeBuilder {
  137837. /**
  137838. * 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.
  137839. * * 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.
  137840. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137841. * * 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.
  137842. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  137843. * * 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
  137844. * * 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
  137845. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  137846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137847. * * 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
  137848. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  137849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137850. * @param name defines the name of the mesh
  137851. * @param options defines the options used to create the mesh
  137852. * @param scene defines the hosting scene
  137853. * @returns the extruded shape mesh
  137854. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137855. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137856. */
  137857. static ExtrudeShape(name: string, options: {
  137858. shape: Vector3[];
  137859. path: Vector3[];
  137860. scale?: number;
  137861. rotation?: number;
  137862. cap?: number;
  137863. updatable?: boolean;
  137864. sideOrientation?: number;
  137865. frontUVs?: Vector4;
  137866. backUVs?: Vector4;
  137867. instance?: Mesh;
  137868. invertUV?: boolean;
  137869. }, scene?: Nullable<Scene>): Mesh;
  137870. /**
  137871. * Creates an custom extruded shape mesh.
  137872. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  137873. * * 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.
  137874. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137875. * * 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
  137876. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  137877. * * 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
  137878. * * It must returns a float value that will be the scale value applied to the shape on each path point
  137879. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  137880. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  137881. * * 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
  137882. * * 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
  137883. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  137884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137885. * * 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
  137886. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137888. * @param name defines the name of the mesh
  137889. * @param options defines the options used to create the mesh
  137890. * @param scene defines the hosting scene
  137891. * @returns the custom extruded shape mesh
  137892. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  137893. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137894. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137895. */
  137896. static ExtrudeShapeCustom(name: string, options: {
  137897. shape: Vector3[];
  137898. path: Vector3[];
  137899. scaleFunction?: any;
  137900. rotationFunction?: any;
  137901. ribbonCloseArray?: boolean;
  137902. ribbonClosePath?: boolean;
  137903. cap?: number;
  137904. updatable?: boolean;
  137905. sideOrientation?: number;
  137906. frontUVs?: Vector4;
  137907. backUVs?: Vector4;
  137908. instance?: Mesh;
  137909. invertUV?: boolean;
  137910. }, scene?: Nullable<Scene>): Mesh;
  137911. private static _ExtrudeShapeGeneric;
  137912. }
  137913. }
  137914. declare module BABYLON {
  137915. /**
  137916. * AmmoJS Physics plugin
  137917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137918. * @see https://github.com/kripken/ammo.js/
  137919. */
  137920. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  137921. private _useDeltaForWorldStep;
  137922. /**
  137923. * Reference to the Ammo library
  137924. */
  137925. bjsAMMO: any;
  137926. /**
  137927. * Created ammoJS world which physics bodies are added to
  137928. */
  137929. world: any;
  137930. /**
  137931. * Name of the plugin
  137932. */
  137933. name: string;
  137934. private _timeStep;
  137935. private _fixedTimeStep;
  137936. private _maxSteps;
  137937. private _tmpQuaternion;
  137938. private _tmpAmmoTransform;
  137939. private _tmpAmmoQuaternion;
  137940. private _tmpAmmoConcreteContactResultCallback;
  137941. private _collisionConfiguration;
  137942. private _dispatcher;
  137943. private _overlappingPairCache;
  137944. private _solver;
  137945. private _softBodySolver;
  137946. private _tmpAmmoVectorA;
  137947. private _tmpAmmoVectorB;
  137948. private _tmpAmmoVectorC;
  137949. private _tmpAmmoVectorD;
  137950. private _tmpContactCallbackResult;
  137951. private _tmpAmmoVectorRCA;
  137952. private _tmpAmmoVectorRCB;
  137953. private _raycastResult;
  137954. private static readonly DISABLE_COLLISION_FLAG;
  137955. private static readonly KINEMATIC_FLAG;
  137956. private static readonly DISABLE_DEACTIVATION_FLAG;
  137957. /**
  137958. * Initializes the ammoJS plugin
  137959. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  137960. * @param ammoInjection can be used to inject your own ammo reference
  137961. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  137962. */
  137963. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  137964. /**
  137965. * Sets the gravity of the physics world (m/(s^2))
  137966. * @param gravity Gravity to set
  137967. */
  137968. setGravity(gravity: Vector3): void;
  137969. /**
  137970. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  137971. * @param timeStep timestep to use in seconds
  137972. */
  137973. setTimeStep(timeStep: number): void;
  137974. /**
  137975. * 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)
  137976. * @param fixedTimeStep fixedTimeStep to use in seconds
  137977. */
  137978. setFixedTimeStep(fixedTimeStep: number): void;
  137979. /**
  137980. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  137981. * @param maxSteps the maximum number of steps by the physics engine per frame
  137982. */
  137983. setMaxSteps(maxSteps: number): void;
  137984. /**
  137985. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  137986. * @returns the current timestep in seconds
  137987. */
  137988. getTimeStep(): number;
  137989. /**
  137990. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  137991. */
  137992. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  137993. private _isImpostorInContact;
  137994. private _isImpostorPairInContact;
  137995. private _stepSimulation;
  137996. /**
  137997. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  137998. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  137999. * After the step the babylon meshes are set to the position of the physics imposters
  138000. * @param delta amount of time to step forward
  138001. * @param impostors array of imposters to update before/after the step
  138002. */
  138003. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  138004. /**
  138005. * Update babylon mesh to match physics world object
  138006. * @param impostor imposter to match
  138007. */
  138008. private _afterSoftStep;
  138009. /**
  138010. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138011. * @param impostor imposter to match
  138012. */
  138013. private _ropeStep;
  138014. /**
  138015. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138016. * @param impostor imposter to match
  138017. */
  138018. private _softbodyOrClothStep;
  138019. private _tmpMatrix;
  138020. /**
  138021. * Applies an impulse on the imposter
  138022. * @param impostor imposter to apply impulse to
  138023. * @param force amount of force to be applied to the imposter
  138024. * @param contactPoint the location to apply the impulse on the imposter
  138025. */
  138026. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138027. /**
  138028. * Applies a force on the imposter
  138029. * @param impostor imposter to apply force
  138030. * @param force amount of force to be applied to the imposter
  138031. * @param contactPoint the location to apply the force on the imposter
  138032. */
  138033. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138034. /**
  138035. * Creates a physics body using the plugin
  138036. * @param impostor the imposter to create the physics body on
  138037. */
  138038. generatePhysicsBody(impostor: PhysicsImpostor): void;
  138039. /**
  138040. * Removes the physics body from the imposter and disposes of the body's memory
  138041. * @param impostor imposter to remove the physics body from
  138042. */
  138043. removePhysicsBody(impostor: PhysicsImpostor): void;
  138044. /**
  138045. * Generates a joint
  138046. * @param impostorJoint the imposter joint to create the joint with
  138047. */
  138048. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  138049. /**
  138050. * Removes a joint
  138051. * @param impostorJoint the imposter joint to remove the joint from
  138052. */
  138053. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  138054. private _addMeshVerts;
  138055. /**
  138056. * Initialise the soft body vertices to match its object's (mesh) vertices
  138057. * Softbody vertices (nodes) are in world space and to match this
  138058. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  138059. * @param impostor to create the softbody for
  138060. */
  138061. private _softVertexData;
  138062. /**
  138063. * Create an impostor's soft body
  138064. * @param impostor to create the softbody for
  138065. */
  138066. private _createSoftbody;
  138067. /**
  138068. * Create cloth for an impostor
  138069. * @param impostor to create the softbody for
  138070. */
  138071. private _createCloth;
  138072. /**
  138073. * Create rope for an impostor
  138074. * @param impostor to create the softbody for
  138075. */
  138076. private _createRope;
  138077. /**
  138078. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  138079. * @param impostor to create the custom physics shape for
  138080. */
  138081. private _createCustom;
  138082. private _addHullVerts;
  138083. private _createShape;
  138084. /**
  138085. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  138086. * @param impostor imposter containing the physics body and babylon object
  138087. */
  138088. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  138089. /**
  138090. * Sets the babylon object's position/rotation from the physics body's position/rotation
  138091. * @param impostor imposter containing the physics body and babylon object
  138092. * @param newPosition new position
  138093. * @param newRotation new rotation
  138094. */
  138095. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  138096. /**
  138097. * If this plugin is supported
  138098. * @returns true if its supported
  138099. */
  138100. isSupported(): boolean;
  138101. /**
  138102. * Sets the linear velocity of the physics body
  138103. * @param impostor imposter to set the velocity on
  138104. * @param velocity velocity to set
  138105. */
  138106. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138107. /**
  138108. * Sets the angular velocity of the physics body
  138109. * @param impostor imposter to set the velocity on
  138110. * @param velocity velocity to set
  138111. */
  138112. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138113. /**
  138114. * gets the linear velocity
  138115. * @param impostor imposter to get linear velocity from
  138116. * @returns linear velocity
  138117. */
  138118. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138119. /**
  138120. * gets the angular velocity
  138121. * @param impostor imposter to get angular velocity from
  138122. * @returns angular velocity
  138123. */
  138124. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138125. /**
  138126. * Sets the mass of physics body
  138127. * @param impostor imposter to set the mass on
  138128. * @param mass mass to set
  138129. */
  138130. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  138131. /**
  138132. * Gets the mass of the physics body
  138133. * @param impostor imposter to get the mass from
  138134. * @returns mass
  138135. */
  138136. getBodyMass(impostor: PhysicsImpostor): number;
  138137. /**
  138138. * Gets friction of the impostor
  138139. * @param impostor impostor to get friction from
  138140. * @returns friction value
  138141. */
  138142. getBodyFriction(impostor: PhysicsImpostor): number;
  138143. /**
  138144. * Sets friction of the impostor
  138145. * @param impostor impostor to set friction on
  138146. * @param friction friction value
  138147. */
  138148. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  138149. /**
  138150. * Gets restitution of the impostor
  138151. * @param impostor impostor to get restitution from
  138152. * @returns restitution value
  138153. */
  138154. getBodyRestitution(impostor: PhysicsImpostor): number;
  138155. /**
  138156. * Sets resitution of the impostor
  138157. * @param impostor impostor to set resitution on
  138158. * @param restitution resitution value
  138159. */
  138160. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  138161. /**
  138162. * Gets pressure inside the impostor
  138163. * @param impostor impostor to get pressure from
  138164. * @returns pressure value
  138165. */
  138166. getBodyPressure(impostor: PhysicsImpostor): number;
  138167. /**
  138168. * Sets pressure inside a soft body impostor
  138169. * Cloth and rope must remain 0 pressure
  138170. * @param impostor impostor to set pressure on
  138171. * @param pressure pressure value
  138172. */
  138173. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  138174. /**
  138175. * Gets stiffness of the impostor
  138176. * @param impostor impostor to get stiffness from
  138177. * @returns pressure value
  138178. */
  138179. getBodyStiffness(impostor: PhysicsImpostor): number;
  138180. /**
  138181. * Sets stiffness of the impostor
  138182. * @param impostor impostor to set stiffness on
  138183. * @param stiffness stiffness value from 0 to 1
  138184. */
  138185. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  138186. /**
  138187. * Gets velocityIterations of the impostor
  138188. * @param impostor impostor to get velocity iterations from
  138189. * @returns velocityIterations value
  138190. */
  138191. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  138192. /**
  138193. * Sets velocityIterations of the impostor
  138194. * @param impostor impostor to set velocity iterations on
  138195. * @param velocityIterations velocityIterations value
  138196. */
  138197. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  138198. /**
  138199. * Gets positionIterations of the impostor
  138200. * @param impostor impostor to get position iterations from
  138201. * @returns positionIterations value
  138202. */
  138203. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  138204. /**
  138205. * Sets positionIterations of the impostor
  138206. * @param impostor impostor to set position on
  138207. * @param positionIterations positionIterations value
  138208. */
  138209. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  138210. /**
  138211. * Append an anchor to a cloth object
  138212. * @param impostor is the cloth impostor to add anchor to
  138213. * @param otherImpostor is the rigid impostor to anchor to
  138214. * @param width ratio across width from 0 to 1
  138215. * @param height ratio up height from 0 to 1
  138216. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  138217. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138218. */
  138219. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138220. /**
  138221. * Append an hook to a rope object
  138222. * @param impostor is the rope impostor to add hook to
  138223. * @param otherImpostor is the rigid impostor to hook to
  138224. * @param length ratio along the rope from 0 to 1
  138225. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  138226. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138227. */
  138228. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138229. /**
  138230. * Sleeps the physics body and stops it from being active
  138231. * @param impostor impostor to sleep
  138232. */
  138233. sleepBody(impostor: PhysicsImpostor): void;
  138234. /**
  138235. * Activates the physics body
  138236. * @param impostor impostor to activate
  138237. */
  138238. wakeUpBody(impostor: PhysicsImpostor): void;
  138239. /**
  138240. * Updates the distance parameters of the joint
  138241. * @param joint joint to update
  138242. * @param maxDistance maximum distance of the joint
  138243. * @param minDistance minimum distance of the joint
  138244. */
  138245. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  138246. /**
  138247. * Sets a motor on the joint
  138248. * @param joint joint to set motor on
  138249. * @param speed speed of the motor
  138250. * @param maxForce maximum force of the motor
  138251. * @param motorIndex index of the motor
  138252. */
  138253. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  138254. /**
  138255. * Sets the motors limit
  138256. * @param joint joint to set limit on
  138257. * @param upperLimit upper limit
  138258. * @param lowerLimit lower limit
  138259. */
  138260. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  138261. /**
  138262. * Syncs the position and rotation of a mesh with the impostor
  138263. * @param mesh mesh to sync
  138264. * @param impostor impostor to update the mesh with
  138265. */
  138266. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  138267. /**
  138268. * Gets the radius of the impostor
  138269. * @param impostor impostor to get radius from
  138270. * @returns the radius
  138271. */
  138272. getRadius(impostor: PhysicsImpostor): number;
  138273. /**
  138274. * Gets the box size of the impostor
  138275. * @param impostor impostor to get box size from
  138276. * @param result the resulting box size
  138277. */
  138278. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  138279. /**
  138280. * Disposes of the impostor
  138281. */
  138282. dispose(): void;
  138283. /**
  138284. * Does a raycast in the physics world
  138285. * @param from when should the ray start?
  138286. * @param to when should the ray end?
  138287. * @returns PhysicsRaycastResult
  138288. */
  138289. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138290. }
  138291. }
  138292. declare module BABYLON {
  138293. interface AbstractScene {
  138294. /**
  138295. * The list of reflection probes added to the scene
  138296. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138297. */
  138298. reflectionProbes: Array<ReflectionProbe>;
  138299. /**
  138300. * Removes the given reflection probe from this scene.
  138301. * @param toRemove The reflection probe to remove
  138302. * @returns The index of the removed reflection probe
  138303. */
  138304. removeReflectionProbe(toRemove: ReflectionProbe): number;
  138305. /**
  138306. * Adds the given reflection probe to this scene.
  138307. * @param newReflectionProbe The reflection probe to add
  138308. */
  138309. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  138310. }
  138311. /**
  138312. * Class used to generate realtime reflection / refraction cube textures
  138313. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138314. */
  138315. export class ReflectionProbe {
  138316. /** defines the name of the probe */
  138317. name: string;
  138318. private _scene;
  138319. private _renderTargetTexture;
  138320. private _projectionMatrix;
  138321. private _viewMatrix;
  138322. private _target;
  138323. private _add;
  138324. private _attachedMesh;
  138325. private _invertYAxis;
  138326. /** Gets or sets probe position (center of the cube map) */
  138327. position: Vector3;
  138328. /**
  138329. * Creates a new reflection probe
  138330. * @param name defines the name of the probe
  138331. * @param size defines the texture resolution (for each face)
  138332. * @param scene defines the hosting scene
  138333. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  138334. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  138335. */
  138336. constructor(
  138337. /** defines the name of the probe */
  138338. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  138339. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  138340. get samples(): number;
  138341. set samples(value: number);
  138342. /** Gets or sets the refresh rate to use (on every frame by default) */
  138343. get refreshRate(): number;
  138344. set refreshRate(value: number);
  138345. /**
  138346. * Gets the hosting scene
  138347. * @returns a Scene
  138348. */
  138349. getScene(): Scene;
  138350. /** Gets the internal CubeTexture used to render to */
  138351. get cubeTexture(): RenderTargetTexture;
  138352. /** Gets the list of meshes to render */
  138353. get renderList(): Nullable<AbstractMesh[]>;
  138354. /**
  138355. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  138356. * @param mesh defines the mesh to attach to
  138357. */
  138358. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  138359. /**
  138360. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  138361. * @param renderingGroupId The rendering group id corresponding to its index
  138362. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  138363. */
  138364. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  138365. /**
  138366. * Clean all associated resources
  138367. */
  138368. dispose(): void;
  138369. /**
  138370. * Converts the reflection probe information to a readable string for debug purpose.
  138371. * @param fullDetails Supports for multiple levels of logging within scene loading
  138372. * @returns the human readable reflection probe info
  138373. */
  138374. toString(fullDetails?: boolean): string;
  138375. /**
  138376. * Get the class name of the relfection probe.
  138377. * @returns "ReflectionProbe"
  138378. */
  138379. getClassName(): string;
  138380. /**
  138381. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  138382. * @returns The JSON representation of the texture
  138383. */
  138384. serialize(): any;
  138385. /**
  138386. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  138387. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  138388. * @param scene Define the scene the parsed reflection probe should be instantiated in
  138389. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  138390. * @returns The parsed reflection probe if successful
  138391. */
  138392. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  138393. }
  138394. }
  138395. declare module BABYLON {
  138396. /** @hidden */
  138397. export var _BabylonLoaderRegistered: boolean;
  138398. /**
  138399. * Helps setting up some configuration for the babylon file loader.
  138400. */
  138401. export class BabylonFileLoaderConfiguration {
  138402. /**
  138403. * The loader does not allow injecting custom physix engine into the plugins.
  138404. * Unfortunately in ES6, we need to manually inject them into the plugin.
  138405. * So you could set this variable to your engine import to make it work.
  138406. */
  138407. static LoaderInjectedPhysicsEngine: any;
  138408. }
  138409. }
  138410. declare module BABYLON {
  138411. /**
  138412. * The Physically based simple base material of BJS.
  138413. *
  138414. * This enables better naming and convention enforcements on top of the pbrMaterial.
  138415. * It is used as the base class for both the specGloss and metalRough conventions.
  138416. */
  138417. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  138418. /**
  138419. * Number of Simultaneous lights allowed on the material.
  138420. */
  138421. maxSimultaneousLights: number;
  138422. /**
  138423. * If sets to true, disables all the lights affecting the material.
  138424. */
  138425. disableLighting: boolean;
  138426. /**
  138427. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  138428. */
  138429. environmentTexture: BaseTexture;
  138430. /**
  138431. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  138432. */
  138433. invertNormalMapX: boolean;
  138434. /**
  138435. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  138436. */
  138437. invertNormalMapY: boolean;
  138438. /**
  138439. * Normal map used in the model.
  138440. */
  138441. normalTexture: BaseTexture;
  138442. /**
  138443. * Emissivie color used to self-illuminate the model.
  138444. */
  138445. emissiveColor: Color3;
  138446. /**
  138447. * Emissivie texture used to self-illuminate the model.
  138448. */
  138449. emissiveTexture: BaseTexture;
  138450. /**
  138451. * Occlusion Channel Strenght.
  138452. */
  138453. occlusionStrength: number;
  138454. /**
  138455. * Occlusion Texture of the material (adding extra occlusion effects).
  138456. */
  138457. occlusionTexture: BaseTexture;
  138458. /**
  138459. * Defines the alpha limits in alpha test mode.
  138460. */
  138461. alphaCutOff: number;
  138462. /**
  138463. * Gets the current double sided mode.
  138464. */
  138465. get doubleSided(): boolean;
  138466. /**
  138467. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  138468. */
  138469. set doubleSided(value: boolean);
  138470. /**
  138471. * Stores the pre-calculated light information of a mesh in a texture.
  138472. */
  138473. lightmapTexture: BaseTexture;
  138474. /**
  138475. * If true, the light map contains occlusion information instead of lighting info.
  138476. */
  138477. useLightmapAsShadowmap: boolean;
  138478. /**
  138479. * Instantiates a new PBRMaterial instance.
  138480. *
  138481. * @param name The material name
  138482. * @param scene The scene the material will be use in.
  138483. */
  138484. constructor(name: string, scene: Scene);
  138485. getClassName(): string;
  138486. }
  138487. }
  138488. declare module BABYLON {
  138489. /**
  138490. * The PBR material of BJS following the metal roughness convention.
  138491. *
  138492. * This fits to the PBR convention in the GLTF definition:
  138493. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  138494. */
  138495. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  138496. /**
  138497. * The base color has two different interpretations depending on the value of metalness.
  138498. * When the material is a metal, the base color is the specific measured reflectance value
  138499. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  138500. * of the material.
  138501. */
  138502. baseColor: Color3;
  138503. /**
  138504. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  138505. * well as opacity information in the alpha channel.
  138506. */
  138507. baseTexture: BaseTexture;
  138508. /**
  138509. * Specifies the metallic scalar value of the material.
  138510. * Can also be used to scale the metalness values of the metallic texture.
  138511. */
  138512. metallic: number;
  138513. /**
  138514. * Specifies the roughness scalar value of the material.
  138515. * Can also be used to scale the roughness values of the metallic texture.
  138516. */
  138517. roughness: number;
  138518. /**
  138519. * Texture containing both the metallic value in the B channel and the
  138520. * roughness value in the G channel to keep better precision.
  138521. */
  138522. metallicRoughnessTexture: BaseTexture;
  138523. /**
  138524. * Instantiates a new PBRMetalRoughnessMaterial instance.
  138525. *
  138526. * @param name The material name
  138527. * @param scene The scene the material will be use in.
  138528. */
  138529. constructor(name: string, scene: Scene);
  138530. /**
  138531. * Return the currrent class name of the material.
  138532. */
  138533. getClassName(): string;
  138534. /**
  138535. * Makes a duplicate of the current material.
  138536. * @param name - name to use for the new material.
  138537. */
  138538. clone(name: string): PBRMetallicRoughnessMaterial;
  138539. /**
  138540. * Serialize the material to a parsable JSON object.
  138541. */
  138542. serialize(): any;
  138543. /**
  138544. * Parses a JSON object correponding to the serialize function.
  138545. */
  138546. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  138547. }
  138548. }
  138549. declare module BABYLON {
  138550. /**
  138551. * The PBR material of BJS following the specular glossiness convention.
  138552. *
  138553. * This fits to the PBR convention in the GLTF definition:
  138554. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  138555. */
  138556. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  138557. /**
  138558. * Specifies the diffuse color of the material.
  138559. */
  138560. diffuseColor: Color3;
  138561. /**
  138562. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  138563. * channel.
  138564. */
  138565. diffuseTexture: BaseTexture;
  138566. /**
  138567. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  138568. */
  138569. specularColor: Color3;
  138570. /**
  138571. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  138572. */
  138573. glossiness: number;
  138574. /**
  138575. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  138576. */
  138577. specularGlossinessTexture: BaseTexture;
  138578. /**
  138579. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  138580. *
  138581. * @param name The material name
  138582. * @param scene The scene the material will be use in.
  138583. */
  138584. constructor(name: string, scene: Scene);
  138585. /**
  138586. * Return the currrent class name of the material.
  138587. */
  138588. getClassName(): string;
  138589. /**
  138590. * Makes a duplicate of the current material.
  138591. * @param name - name to use for the new material.
  138592. */
  138593. clone(name: string): PBRSpecularGlossinessMaterial;
  138594. /**
  138595. * Serialize the material to a parsable JSON object.
  138596. */
  138597. serialize(): any;
  138598. /**
  138599. * Parses a JSON object correponding to the serialize function.
  138600. */
  138601. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  138602. }
  138603. }
  138604. declare module BABYLON {
  138605. /**
  138606. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  138607. * It can help converting any input color in a desired output one. This can then be used to create effects
  138608. * from sepia, black and white to sixties or futuristic rendering...
  138609. *
  138610. * The only supported format is currently 3dl.
  138611. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  138612. */
  138613. export class ColorGradingTexture extends BaseTexture {
  138614. /**
  138615. * The texture URL.
  138616. */
  138617. url: string;
  138618. /**
  138619. * Empty line regex stored for GC.
  138620. */
  138621. private static _noneEmptyLineRegex;
  138622. private _textureMatrix;
  138623. private _onLoad;
  138624. /**
  138625. * Instantiates a ColorGradingTexture from the following parameters.
  138626. *
  138627. * @param url The location of the color gradind data (currently only supporting 3dl)
  138628. * @param sceneOrEngine The scene or engine the texture will be used in
  138629. * @param onLoad defines a callback triggered when the texture has been loaded
  138630. */
  138631. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  138632. /**
  138633. * Fires the onload event from the constructor if requested.
  138634. */
  138635. private _triggerOnLoad;
  138636. /**
  138637. * Returns the texture matrix used in most of the material.
  138638. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  138639. */
  138640. getTextureMatrix(): Matrix;
  138641. /**
  138642. * Occurs when the file being loaded is a .3dl LUT file.
  138643. */
  138644. private load3dlTexture;
  138645. /**
  138646. * Starts the loading process of the texture.
  138647. */
  138648. private loadTexture;
  138649. /**
  138650. * Clones the color gradind texture.
  138651. */
  138652. clone(): ColorGradingTexture;
  138653. /**
  138654. * Called during delayed load for textures.
  138655. */
  138656. delayLoad(): void;
  138657. /**
  138658. * Parses a color grading texture serialized by Babylon.
  138659. * @param parsedTexture The texture information being parsedTexture
  138660. * @param scene The scene to load the texture in
  138661. * @param rootUrl The root url of the data assets to load
  138662. * @return A color gradind texture
  138663. */
  138664. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  138665. /**
  138666. * Serializes the LUT texture to json format.
  138667. */
  138668. serialize(): any;
  138669. }
  138670. }
  138671. declare module BABYLON {
  138672. /**
  138673. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  138674. */
  138675. export class EquiRectangularCubeTexture extends BaseTexture {
  138676. /** The six faces of the cube. */
  138677. private static _FacesMapping;
  138678. private _noMipmap;
  138679. private _onLoad;
  138680. private _onError;
  138681. /** The size of the cubemap. */
  138682. private _size;
  138683. /** The buffer of the image. */
  138684. private _buffer;
  138685. /** The width of the input image. */
  138686. private _width;
  138687. /** The height of the input image. */
  138688. private _height;
  138689. /** The URL to the image. */
  138690. url: string;
  138691. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  138692. coordinatesMode: number;
  138693. /**
  138694. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  138695. * @param url The location of the image
  138696. * @param scene The scene the texture will be used in
  138697. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  138698. * @param noMipmap Forces to not generate the mipmap if true
  138699. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  138700. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  138701. * @param onLoad — defines a callback called when texture is loaded
  138702. * @param onError — defines a callback called if there is an error
  138703. */
  138704. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  138705. /**
  138706. * Load the image data, by putting the image on a canvas and extracting its buffer.
  138707. */
  138708. private loadImage;
  138709. /**
  138710. * Convert the image buffer into a cubemap and create a CubeTexture.
  138711. */
  138712. private loadTexture;
  138713. /**
  138714. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  138715. * @param buffer The ArrayBuffer that should be converted.
  138716. * @returns The buffer as Float32Array.
  138717. */
  138718. private getFloat32ArrayFromArrayBuffer;
  138719. /**
  138720. * Get the current class name of the texture useful for serialization or dynamic coding.
  138721. * @returns "EquiRectangularCubeTexture"
  138722. */
  138723. getClassName(): string;
  138724. /**
  138725. * Create a clone of the current EquiRectangularCubeTexture and return it.
  138726. * @returns A clone of the current EquiRectangularCubeTexture.
  138727. */
  138728. clone(): EquiRectangularCubeTexture;
  138729. }
  138730. }
  138731. declare module BABYLON {
  138732. /**
  138733. * Defines the options related to the creation of an HtmlElementTexture
  138734. */
  138735. export interface IHtmlElementTextureOptions {
  138736. /**
  138737. * Defines wether mip maps should be created or not.
  138738. */
  138739. generateMipMaps?: boolean;
  138740. /**
  138741. * Defines the sampling mode of the texture.
  138742. */
  138743. samplingMode?: number;
  138744. /**
  138745. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  138746. */
  138747. engine: Nullable<ThinEngine>;
  138748. /**
  138749. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  138750. */
  138751. scene: Nullable<Scene>;
  138752. }
  138753. /**
  138754. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  138755. * To be as efficient as possible depending on your constraints nothing aside the first upload
  138756. * is automatically managed.
  138757. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  138758. * in your application.
  138759. *
  138760. * As the update is not automatic, you need to call them manually.
  138761. */
  138762. export class HtmlElementTexture extends BaseTexture {
  138763. /**
  138764. * The texture URL.
  138765. */
  138766. element: HTMLVideoElement | HTMLCanvasElement;
  138767. private static readonly DefaultOptions;
  138768. private _textureMatrix;
  138769. private _isVideo;
  138770. private _generateMipMaps;
  138771. private _samplingMode;
  138772. /**
  138773. * Instantiates a HtmlElementTexture from the following parameters.
  138774. *
  138775. * @param name Defines the name of the texture
  138776. * @param element Defines the video or canvas the texture is filled with
  138777. * @param options Defines the other none mandatory texture creation options
  138778. */
  138779. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  138780. private _createInternalTexture;
  138781. /**
  138782. * Returns the texture matrix used in most of the material.
  138783. */
  138784. getTextureMatrix(): Matrix;
  138785. /**
  138786. * Updates the content of the texture.
  138787. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  138788. */
  138789. update(invertY?: Nullable<boolean>): void;
  138790. }
  138791. }
  138792. declare module BABYLON {
  138793. /**
  138794. * Based on jsTGALoader - Javascript loader for TGA file
  138795. * By Vincent Thibault
  138796. * @see http://blog.robrowser.com/javascript-tga-loader.html
  138797. */
  138798. export class TGATools {
  138799. private static _TYPE_INDEXED;
  138800. private static _TYPE_RGB;
  138801. private static _TYPE_GREY;
  138802. private static _TYPE_RLE_INDEXED;
  138803. private static _TYPE_RLE_RGB;
  138804. private static _TYPE_RLE_GREY;
  138805. private static _ORIGIN_MASK;
  138806. private static _ORIGIN_SHIFT;
  138807. private static _ORIGIN_BL;
  138808. private static _ORIGIN_BR;
  138809. private static _ORIGIN_UL;
  138810. private static _ORIGIN_UR;
  138811. /**
  138812. * Gets the header of a TGA file
  138813. * @param data defines the TGA data
  138814. * @returns the header
  138815. */
  138816. static GetTGAHeader(data: Uint8Array): any;
  138817. /**
  138818. * Uploads TGA content to a Babylon Texture
  138819. * @hidden
  138820. */
  138821. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  138822. /** @hidden */
  138823. 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;
  138824. /** @hidden */
  138825. 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;
  138826. /** @hidden */
  138827. 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;
  138828. /** @hidden */
  138829. 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;
  138830. /** @hidden */
  138831. 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;
  138832. /** @hidden */
  138833. 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;
  138834. }
  138835. }
  138836. declare module BABYLON {
  138837. /**
  138838. * Implementation of the TGA Texture Loader.
  138839. * @hidden
  138840. */
  138841. export class _TGATextureLoader implements IInternalTextureLoader {
  138842. /**
  138843. * Defines wether the loader supports cascade loading the different faces.
  138844. */
  138845. readonly supportCascades: boolean;
  138846. /**
  138847. * This returns if the loader support the current file information.
  138848. * @param extension defines the file extension of the file being loaded
  138849. * @returns true if the loader can load the specified file
  138850. */
  138851. canLoad(extension: string): boolean;
  138852. /**
  138853. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138854. * @param data contains the texture data
  138855. * @param texture defines the BabylonJS internal texture
  138856. * @param createPolynomials will be true if polynomials have been requested
  138857. * @param onLoad defines the callback to trigger once the texture is ready
  138858. * @param onError defines the callback to trigger in case of error
  138859. */
  138860. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138861. /**
  138862. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138863. * @param data contains the texture data
  138864. * @param texture defines the BabylonJS internal texture
  138865. * @param callback defines the method to call once ready to upload
  138866. */
  138867. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138868. }
  138869. }
  138870. declare module BABYLON {
  138871. /**
  138872. * Info about the .basis files
  138873. */
  138874. class BasisFileInfo {
  138875. /**
  138876. * If the file has alpha
  138877. */
  138878. hasAlpha: boolean;
  138879. /**
  138880. * Info about each image of the basis file
  138881. */
  138882. images: Array<{
  138883. levels: Array<{
  138884. width: number;
  138885. height: number;
  138886. transcodedPixels: ArrayBufferView;
  138887. }>;
  138888. }>;
  138889. }
  138890. /**
  138891. * Result of transcoding a basis file
  138892. */
  138893. class TranscodeResult {
  138894. /**
  138895. * Info about the .basis file
  138896. */
  138897. fileInfo: BasisFileInfo;
  138898. /**
  138899. * Format to use when loading the file
  138900. */
  138901. format: number;
  138902. }
  138903. /**
  138904. * Configuration options for the Basis transcoder
  138905. */
  138906. export class BasisTranscodeConfiguration {
  138907. /**
  138908. * Supported compression formats used to determine the supported output format of the transcoder
  138909. */
  138910. supportedCompressionFormats?: {
  138911. /**
  138912. * etc1 compression format
  138913. */
  138914. etc1?: boolean;
  138915. /**
  138916. * s3tc compression format
  138917. */
  138918. s3tc?: boolean;
  138919. /**
  138920. * pvrtc compression format
  138921. */
  138922. pvrtc?: boolean;
  138923. /**
  138924. * etc2 compression format
  138925. */
  138926. etc2?: boolean;
  138927. };
  138928. /**
  138929. * If mipmap levels should be loaded for transcoded images (Default: true)
  138930. */
  138931. loadMipmapLevels?: boolean;
  138932. /**
  138933. * Index of a single image to load (Default: all images)
  138934. */
  138935. loadSingleImage?: number;
  138936. }
  138937. /**
  138938. * Used to load .Basis files
  138939. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  138940. */
  138941. export class BasisTools {
  138942. private static _IgnoreSupportedFormats;
  138943. /**
  138944. * URL to use when loading the basis transcoder
  138945. */
  138946. static JSModuleURL: string;
  138947. /**
  138948. * URL to use when loading the wasm module for the transcoder
  138949. */
  138950. static WasmModuleURL: string;
  138951. /**
  138952. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  138953. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  138954. * @returns internal format corresponding to the Basis format
  138955. */
  138956. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  138957. private static _WorkerPromise;
  138958. private static _Worker;
  138959. private static _actionId;
  138960. private static _CreateWorkerAsync;
  138961. /**
  138962. * Transcodes a loaded image file to compressed pixel data
  138963. * @param data image data to transcode
  138964. * @param config configuration options for the transcoding
  138965. * @returns a promise resulting in the transcoded image
  138966. */
  138967. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  138968. /**
  138969. * Loads a texture from the transcode result
  138970. * @param texture texture load to
  138971. * @param transcodeResult the result of transcoding the basis file to load from
  138972. */
  138973. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  138974. }
  138975. }
  138976. declare module BABYLON {
  138977. /**
  138978. * Loader for .basis file format
  138979. */
  138980. export class _BasisTextureLoader implements IInternalTextureLoader {
  138981. /**
  138982. * Defines whether the loader supports cascade loading the different faces.
  138983. */
  138984. readonly supportCascades: boolean;
  138985. /**
  138986. * This returns if the loader support the current file information.
  138987. * @param extension defines the file extension of the file being loaded
  138988. * @returns true if the loader can load the specified file
  138989. */
  138990. canLoad(extension: string): boolean;
  138991. /**
  138992. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138993. * @param data contains the texture data
  138994. * @param texture defines the BabylonJS internal texture
  138995. * @param createPolynomials will be true if polynomials have been requested
  138996. * @param onLoad defines the callback to trigger once the texture is ready
  138997. * @param onError defines the callback to trigger in case of error
  138998. */
  138999. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139000. /**
  139001. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139002. * @param data contains the texture data
  139003. * @param texture defines the BabylonJS internal texture
  139004. * @param callback defines the method to call once ready to upload
  139005. */
  139006. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139007. }
  139008. }
  139009. declare module BABYLON {
  139010. /**
  139011. * Defines the basic options interface of a TexturePacker Frame
  139012. */
  139013. export interface ITexturePackerFrame {
  139014. /**
  139015. * The frame ID
  139016. */
  139017. id: number;
  139018. /**
  139019. * The frames Scale
  139020. */
  139021. scale: Vector2;
  139022. /**
  139023. * The Frames offset
  139024. */
  139025. offset: Vector2;
  139026. }
  139027. /**
  139028. * This is a support class for frame Data on texture packer sets.
  139029. */
  139030. export class TexturePackerFrame implements ITexturePackerFrame {
  139031. /**
  139032. * The frame ID
  139033. */
  139034. id: number;
  139035. /**
  139036. * The frames Scale
  139037. */
  139038. scale: Vector2;
  139039. /**
  139040. * The Frames offset
  139041. */
  139042. offset: Vector2;
  139043. /**
  139044. * Initializes a texture package frame.
  139045. * @param id The numerical frame identifier
  139046. * @param scale Scalar Vector2 for UV frame
  139047. * @param offset Vector2 for the frame position in UV units.
  139048. * @returns TexturePackerFrame
  139049. */
  139050. constructor(id: number, scale: Vector2, offset: Vector2);
  139051. }
  139052. }
  139053. declare module BABYLON {
  139054. /**
  139055. * Defines the basic options interface of a TexturePacker
  139056. */
  139057. export interface ITexturePackerOptions {
  139058. /**
  139059. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  139060. */
  139061. map?: string[];
  139062. /**
  139063. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139064. */
  139065. uvsIn?: string;
  139066. /**
  139067. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139068. */
  139069. uvsOut?: string;
  139070. /**
  139071. * number representing the layout style. Defaults to LAYOUT_STRIP
  139072. */
  139073. layout?: number;
  139074. /**
  139075. * number of columns if using custom column count layout(2). This defaults to 4.
  139076. */
  139077. colnum?: number;
  139078. /**
  139079. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  139080. */
  139081. updateInputMeshes?: boolean;
  139082. /**
  139083. * boolean flag to dispose all the source textures. Defaults to true.
  139084. */
  139085. disposeSources?: boolean;
  139086. /**
  139087. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  139088. */
  139089. fillBlanks?: boolean;
  139090. /**
  139091. * string value representing the context fill style color. Defaults to 'black'.
  139092. */
  139093. customFillColor?: string;
  139094. /**
  139095. * Width and Height Value of each Frame in the TexturePacker Sets
  139096. */
  139097. frameSize?: number;
  139098. /**
  139099. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  139100. */
  139101. paddingRatio?: number;
  139102. /**
  139103. * Number that declares the fill method for the padding gutter.
  139104. */
  139105. paddingMode?: number;
  139106. /**
  139107. * If in SUBUV_COLOR padding mode what color to use.
  139108. */
  139109. paddingColor?: Color3 | Color4;
  139110. }
  139111. /**
  139112. * Defines the basic interface of a TexturePacker JSON File
  139113. */
  139114. export interface ITexturePackerJSON {
  139115. /**
  139116. * The frame ID
  139117. */
  139118. name: string;
  139119. /**
  139120. * The base64 channel data
  139121. */
  139122. sets: any;
  139123. /**
  139124. * The options of the Packer
  139125. */
  139126. options: ITexturePackerOptions;
  139127. /**
  139128. * The frame data of the Packer
  139129. */
  139130. frames: Array<number>;
  139131. }
  139132. /**
  139133. * This is a support class that generates a series of packed texture sets.
  139134. * @see https://doc.babylonjs.com/babylon101/materials
  139135. */
  139136. export class TexturePacker {
  139137. /** Packer Layout Constant 0 */
  139138. static readonly LAYOUT_STRIP: number;
  139139. /** Packer Layout Constant 1 */
  139140. static readonly LAYOUT_POWER2: number;
  139141. /** Packer Layout Constant 2 */
  139142. static readonly LAYOUT_COLNUM: number;
  139143. /** Packer Layout Constant 0 */
  139144. static readonly SUBUV_WRAP: number;
  139145. /** Packer Layout Constant 1 */
  139146. static readonly SUBUV_EXTEND: number;
  139147. /** Packer Layout Constant 2 */
  139148. static readonly SUBUV_COLOR: number;
  139149. /** The Name of the Texture Package */
  139150. name: string;
  139151. /** The scene scope of the TexturePacker */
  139152. scene: Scene;
  139153. /** The Meshes to target */
  139154. meshes: AbstractMesh[];
  139155. /** Arguments passed with the Constructor */
  139156. options: ITexturePackerOptions;
  139157. /** The promise that is started upon initialization */
  139158. promise: Nullable<Promise<TexturePacker | string>>;
  139159. /** The Container object for the channel sets that are generated */
  139160. sets: object;
  139161. /** The Container array for the frames that are generated */
  139162. frames: TexturePackerFrame[];
  139163. /** The expected number of textures the system is parsing. */
  139164. private _expecting;
  139165. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  139166. private _paddingValue;
  139167. /**
  139168. * Initializes a texture package series from an array of meshes or a single mesh.
  139169. * @param name The name of the package
  139170. * @param meshes The target meshes to compose the package from
  139171. * @param options The arguments that texture packer should follow while building.
  139172. * @param scene The scene which the textures are scoped to.
  139173. * @returns TexturePacker
  139174. */
  139175. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  139176. /**
  139177. * Starts the package process
  139178. * @param resolve The promises resolution function
  139179. * @returns TexturePacker
  139180. */
  139181. private _createFrames;
  139182. /**
  139183. * Calculates the Size of the Channel Sets
  139184. * @returns Vector2
  139185. */
  139186. private _calculateSize;
  139187. /**
  139188. * Calculates the UV data for the frames.
  139189. * @param baseSize the base frameSize
  139190. * @param padding the base frame padding
  139191. * @param dtSize size of the Dynamic Texture for that channel
  139192. * @param dtUnits is 1/dtSize
  139193. * @param update flag to update the input meshes
  139194. */
  139195. private _calculateMeshUVFrames;
  139196. /**
  139197. * Calculates the frames Offset.
  139198. * @param index of the frame
  139199. * @returns Vector2
  139200. */
  139201. private _getFrameOffset;
  139202. /**
  139203. * Updates a Mesh to the frame data
  139204. * @param mesh that is the target
  139205. * @param frameID or the frame index
  139206. */
  139207. private _updateMeshUV;
  139208. /**
  139209. * Updates a Meshes materials to use the texture packer channels
  139210. * @param m is the mesh to target
  139211. * @param force all channels on the packer to be set.
  139212. */
  139213. private _updateTextureReferences;
  139214. /**
  139215. * Public method to set a Mesh to a frame
  139216. * @param m that is the target
  139217. * @param frameID or the frame index
  139218. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  139219. */
  139220. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  139221. /**
  139222. * Starts the async promise to compile the texture packer.
  139223. * @returns Promise<void>
  139224. */
  139225. processAsync(): Promise<void>;
  139226. /**
  139227. * Disposes all textures associated with this packer
  139228. */
  139229. dispose(): void;
  139230. /**
  139231. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  139232. * @param imageType is the image type to use.
  139233. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  139234. */
  139235. download(imageType?: string, quality?: number): void;
  139236. /**
  139237. * Public method to load a texturePacker JSON file.
  139238. * @param data of the JSON file in string format.
  139239. */
  139240. updateFromJSON(data: string): void;
  139241. }
  139242. }
  139243. declare module BABYLON {
  139244. /**
  139245. * 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.
  139246. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  139247. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  139248. */
  139249. export class CustomProceduralTexture extends ProceduralTexture {
  139250. private _animate;
  139251. private _time;
  139252. private _config;
  139253. private _texturePath;
  139254. /**
  139255. * Instantiates a new Custom Procedural Texture.
  139256. * 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.
  139257. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  139258. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  139259. * @param name Define the name of the texture
  139260. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  139261. * @param size Define the size of the texture to create
  139262. * @param scene Define the scene the texture belongs to
  139263. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  139264. * @param generateMipMaps Define if the texture should creates mip maps or not
  139265. */
  139266. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  139267. private _loadJson;
  139268. /**
  139269. * Is the texture ready to be used ? (rendered at least once)
  139270. * @returns true if ready, otherwise, false.
  139271. */
  139272. isReady(): boolean;
  139273. /**
  139274. * Render the texture to its associated render target.
  139275. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  139276. */
  139277. render(useCameraPostProcess?: boolean): void;
  139278. /**
  139279. * Update the list of dependant textures samplers in the shader.
  139280. */
  139281. updateTextures(): void;
  139282. /**
  139283. * Update the uniform values of the procedural texture in the shader.
  139284. */
  139285. updateShaderUniforms(): void;
  139286. /**
  139287. * Define if the texture animates or not.
  139288. */
  139289. get animate(): boolean;
  139290. set animate(value: boolean);
  139291. }
  139292. }
  139293. declare module BABYLON {
  139294. /** @hidden */
  139295. export var noisePixelShader: {
  139296. name: string;
  139297. shader: string;
  139298. };
  139299. }
  139300. declare module BABYLON {
  139301. /**
  139302. * Class used to generate noise procedural textures
  139303. */
  139304. export class NoiseProceduralTexture extends ProceduralTexture {
  139305. private _time;
  139306. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  139307. brightness: number;
  139308. /** Defines the number of octaves to process */
  139309. octaves: number;
  139310. /** Defines the level of persistence (0.8 by default) */
  139311. persistence: number;
  139312. /** Gets or sets animation speed factor (default is 1) */
  139313. animationSpeedFactor: number;
  139314. /**
  139315. * Creates a new NoiseProceduralTexture
  139316. * @param name defines the name fo the texture
  139317. * @param size defines the size of the texture (default is 256)
  139318. * @param scene defines the hosting scene
  139319. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  139320. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  139321. */
  139322. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  139323. private _updateShaderUniforms;
  139324. protected _getDefines(): string;
  139325. /** Generate the current state of the procedural texture */
  139326. render(useCameraPostProcess?: boolean): void;
  139327. /**
  139328. * Serializes this noise procedural texture
  139329. * @returns a serialized noise procedural texture object
  139330. */
  139331. serialize(): any;
  139332. /**
  139333. * Clone the texture.
  139334. * @returns the cloned texture
  139335. */
  139336. clone(): NoiseProceduralTexture;
  139337. /**
  139338. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  139339. * @param parsedTexture defines parsed texture data
  139340. * @param scene defines the current scene
  139341. * @param rootUrl defines the root URL containing noise procedural texture information
  139342. * @returns a parsed NoiseProceduralTexture
  139343. */
  139344. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  139345. }
  139346. }
  139347. declare module BABYLON {
  139348. /**
  139349. * Raw cube texture where the raw buffers are passed in
  139350. */
  139351. export class RawCubeTexture extends CubeTexture {
  139352. /**
  139353. * Creates a cube texture where the raw buffers are passed in.
  139354. * @param scene defines the scene the texture is attached to
  139355. * @param data defines the array of data to use to create each face
  139356. * @param size defines the size of the textures
  139357. * @param format defines the format of the data
  139358. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  139359. * @param generateMipMaps defines if the engine should generate the mip levels
  139360. * @param invertY defines if data must be stored with Y axis inverted
  139361. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  139362. * @param compression defines the compression used (null by default)
  139363. */
  139364. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  139365. /**
  139366. * Updates the raw cube texture.
  139367. * @param data defines the data to store
  139368. * @param format defines the data format
  139369. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139370. * @param invertY defines if data must be stored with Y axis inverted
  139371. * @param compression defines the compression used (null by default)
  139372. * @param level defines which level of the texture to update
  139373. */
  139374. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  139375. /**
  139376. * Updates a raw cube texture with RGBD encoded data.
  139377. * @param data defines the array of data [mipmap][face] to use to create each face
  139378. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  139379. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  139380. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  139381. * @returns a promsie that resolves when the operation is complete
  139382. */
  139383. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  139384. /**
  139385. * Clones the raw cube texture.
  139386. * @return a new cube texture
  139387. */
  139388. clone(): CubeTexture;
  139389. /** @hidden */
  139390. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  139391. }
  139392. }
  139393. declare module BABYLON {
  139394. /**
  139395. * Class used to store 2D array textures containing user data
  139396. */
  139397. export class RawTexture2DArray extends Texture {
  139398. /** Gets or sets the texture format to use */
  139399. format: number;
  139400. /**
  139401. * Create a new RawTexture2DArray
  139402. * @param data defines the data of the texture
  139403. * @param width defines the width of the texture
  139404. * @param height defines the height of the texture
  139405. * @param depth defines the number of layers of the texture
  139406. * @param format defines the texture format to use
  139407. * @param scene defines the hosting scene
  139408. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  139409. * @param invertY defines if texture must be stored with Y axis inverted
  139410. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  139411. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  139412. */
  139413. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  139414. /** Gets or sets the texture format to use */
  139415. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  139416. /**
  139417. * Update the texture with new data
  139418. * @param data defines the data to store in the texture
  139419. */
  139420. update(data: ArrayBufferView): void;
  139421. }
  139422. }
  139423. declare module BABYLON {
  139424. /**
  139425. * Class used to store 3D textures containing user data
  139426. */
  139427. export class RawTexture3D extends Texture {
  139428. /** Gets or sets the texture format to use */
  139429. format: number;
  139430. /**
  139431. * Create a new RawTexture3D
  139432. * @param data defines the data of the texture
  139433. * @param width defines the width of the texture
  139434. * @param height defines the height of the texture
  139435. * @param depth defines the depth of the texture
  139436. * @param format defines the texture format to use
  139437. * @param scene defines the hosting scene
  139438. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  139439. * @param invertY defines if texture must be stored with Y axis inverted
  139440. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  139441. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  139442. */
  139443. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  139444. /** Gets or sets the texture format to use */
  139445. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  139446. /**
  139447. * Update the texture with new data
  139448. * @param data defines the data to store in the texture
  139449. */
  139450. update(data: ArrayBufferView): void;
  139451. }
  139452. }
  139453. declare module BABYLON {
  139454. /**
  139455. * Creates a refraction texture used by refraction channel of the standard material.
  139456. * It is like a mirror but to see through a material.
  139457. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139458. */
  139459. export class RefractionTexture extends RenderTargetTexture {
  139460. /**
  139461. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  139462. * 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.
  139463. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139464. */
  139465. refractionPlane: Plane;
  139466. /**
  139467. * Define how deep under the surface we should see.
  139468. */
  139469. depth: number;
  139470. /**
  139471. * Creates a refraction texture used by refraction channel of the standard material.
  139472. * It is like a mirror but to see through a material.
  139473. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139474. * @param name Define the texture name
  139475. * @param size Define the size of the underlying texture
  139476. * @param scene Define the scene the refraction belongs to
  139477. * @param generateMipMaps Define if we need to generate mips level for the refraction
  139478. */
  139479. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  139480. /**
  139481. * Clone the refraction texture.
  139482. * @returns the cloned texture
  139483. */
  139484. clone(): RefractionTexture;
  139485. /**
  139486. * Serialize the texture to a JSON representation you could use in Parse later on
  139487. * @returns the serialized JSON representation
  139488. */
  139489. serialize(): any;
  139490. }
  139491. }
  139492. declare module BABYLON {
  139493. /**
  139494. * Block used to add support for vertex skinning (bones)
  139495. */
  139496. export class BonesBlock extends NodeMaterialBlock {
  139497. /**
  139498. * Creates a new BonesBlock
  139499. * @param name defines the block name
  139500. */
  139501. constructor(name: string);
  139502. /**
  139503. * Initialize the block and prepare the context for build
  139504. * @param state defines the state that will be used for the build
  139505. */
  139506. initialize(state: NodeMaterialBuildState): void;
  139507. /**
  139508. * Gets the current class name
  139509. * @returns the class name
  139510. */
  139511. getClassName(): string;
  139512. /**
  139513. * Gets the matrix indices input component
  139514. */
  139515. get matricesIndices(): NodeMaterialConnectionPoint;
  139516. /**
  139517. * Gets the matrix weights input component
  139518. */
  139519. get matricesWeights(): NodeMaterialConnectionPoint;
  139520. /**
  139521. * Gets the extra matrix indices input component
  139522. */
  139523. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  139524. /**
  139525. * Gets the extra matrix weights input component
  139526. */
  139527. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  139528. /**
  139529. * Gets the world input component
  139530. */
  139531. get world(): NodeMaterialConnectionPoint;
  139532. /**
  139533. * Gets the output component
  139534. */
  139535. get output(): NodeMaterialConnectionPoint;
  139536. autoConfigure(material: NodeMaterial): void;
  139537. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  139538. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139539. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139540. protected _buildBlock(state: NodeMaterialBuildState): this;
  139541. }
  139542. }
  139543. declare module BABYLON {
  139544. /**
  139545. * Block used to add support for instances
  139546. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  139547. */
  139548. export class InstancesBlock extends NodeMaterialBlock {
  139549. /**
  139550. * Creates a new InstancesBlock
  139551. * @param name defines the block name
  139552. */
  139553. constructor(name: string);
  139554. /**
  139555. * Gets the current class name
  139556. * @returns the class name
  139557. */
  139558. getClassName(): string;
  139559. /**
  139560. * Gets the first world row input component
  139561. */
  139562. get world0(): NodeMaterialConnectionPoint;
  139563. /**
  139564. * Gets the second world row input component
  139565. */
  139566. get world1(): NodeMaterialConnectionPoint;
  139567. /**
  139568. * Gets the third world row input component
  139569. */
  139570. get world2(): NodeMaterialConnectionPoint;
  139571. /**
  139572. * Gets the forth world row input component
  139573. */
  139574. get world3(): NodeMaterialConnectionPoint;
  139575. /**
  139576. * Gets the world input component
  139577. */
  139578. get world(): NodeMaterialConnectionPoint;
  139579. /**
  139580. * Gets the output component
  139581. */
  139582. get output(): NodeMaterialConnectionPoint;
  139583. /**
  139584. * Gets the isntanceID component
  139585. */
  139586. get instanceID(): NodeMaterialConnectionPoint;
  139587. autoConfigure(material: NodeMaterial): void;
  139588. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  139589. protected _buildBlock(state: NodeMaterialBuildState): this;
  139590. }
  139591. }
  139592. declare module BABYLON {
  139593. /**
  139594. * Block used to add morph targets support to vertex shader
  139595. */
  139596. export class MorphTargetsBlock extends NodeMaterialBlock {
  139597. private _repeatableContentAnchor;
  139598. /**
  139599. * Create a new MorphTargetsBlock
  139600. * @param name defines the block name
  139601. */
  139602. constructor(name: string);
  139603. /**
  139604. * Gets the current class name
  139605. * @returns the class name
  139606. */
  139607. getClassName(): string;
  139608. /**
  139609. * Gets the position input component
  139610. */
  139611. get position(): NodeMaterialConnectionPoint;
  139612. /**
  139613. * Gets the normal input component
  139614. */
  139615. get normal(): NodeMaterialConnectionPoint;
  139616. /**
  139617. * Gets the tangent input component
  139618. */
  139619. get tangent(): NodeMaterialConnectionPoint;
  139620. /**
  139621. * Gets the tangent input component
  139622. */
  139623. get uv(): NodeMaterialConnectionPoint;
  139624. /**
  139625. * Gets the position output component
  139626. */
  139627. get positionOutput(): NodeMaterialConnectionPoint;
  139628. /**
  139629. * Gets the normal output component
  139630. */
  139631. get normalOutput(): NodeMaterialConnectionPoint;
  139632. /**
  139633. * Gets the tangent output component
  139634. */
  139635. get tangentOutput(): NodeMaterialConnectionPoint;
  139636. /**
  139637. * Gets the tangent output component
  139638. */
  139639. get uvOutput(): NodeMaterialConnectionPoint;
  139640. initialize(state: NodeMaterialBuildState): void;
  139641. autoConfigure(material: NodeMaterial): void;
  139642. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139643. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139644. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  139645. protected _buildBlock(state: NodeMaterialBuildState): this;
  139646. }
  139647. }
  139648. declare module BABYLON {
  139649. /**
  139650. * Block used to get data information from a light
  139651. */
  139652. export class LightInformationBlock extends NodeMaterialBlock {
  139653. private _lightDataUniformName;
  139654. private _lightColorUniformName;
  139655. private _lightTypeDefineName;
  139656. /**
  139657. * Gets or sets the light associated with this block
  139658. */
  139659. light: Nullable<Light>;
  139660. /**
  139661. * Creates a new LightInformationBlock
  139662. * @param name defines the block name
  139663. */
  139664. constructor(name: string);
  139665. /**
  139666. * Gets the current class name
  139667. * @returns the class name
  139668. */
  139669. getClassName(): string;
  139670. /**
  139671. * Gets the world position input component
  139672. */
  139673. get worldPosition(): NodeMaterialConnectionPoint;
  139674. /**
  139675. * Gets the direction output component
  139676. */
  139677. get direction(): NodeMaterialConnectionPoint;
  139678. /**
  139679. * Gets the direction output component
  139680. */
  139681. get color(): NodeMaterialConnectionPoint;
  139682. /**
  139683. * Gets the direction output component
  139684. */
  139685. get intensity(): NodeMaterialConnectionPoint;
  139686. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139687. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139688. protected _buildBlock(state: NodeMaterialBuildState): this;
  139689. serialize(): any;
  139690. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139691. }
  139692. }
  139693. declare module BABYLON {
  139694. /**
  139695. * Block used to add image processing support to fragment shader
  139696. */
  139697. export class ImageProcessingBlock extends NodeMaterialBlock {
  139698. /**
  139699. * Create a new ImageProcessingBlock
  139700. * @param name defines the block name
  139701. */
  139702. constructor(name: string);
  139703. /**
  139704. * Gets the current class name
  139705. * @returns the class name
  139706. */
  139707. getClassName(): string;
  139708. /**
  139709. * Gets the color input component
  139710. */
  139711. get color(): NodeMaterialConnectionPoint;
  139712. /**
  139713. * Gets the output component
  139714. */
  139715. get output(): NodeMaterialConnectionPoint;
  139716. /**
  139717. * Initialize the block and prepare the context for build
  139718. * @param state defines the state that will be used for the build
  139719. */
  139720. initialize(state: NodeMaterialBuildState): void;
  139721. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  139722. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139723. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139724. protected _buildBlock(state: NodeMaterialBuildState): this;
  139725. }
  139726. }
  139727. declare module BABYLON {
  139728. /**
  139729. * Block used to pertub normals based on a normal map
  139730. */
  139731. export class PerturbNormalBlock extends NodeMaterialBlock {
  139732. private _tangentSpaceParameterName;
  139733. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139734. invertX: boolean;
  139735. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  139736. invertY: boolean;
  139737. /**
  139738. * Create a new PerturbNormalBlock
  139739. * @param name defines the block name
  139740. */
  139741. constructor(name: string);
  139742. /**
  139743. * Gets the current class name
  139744. * @returns the class name
  139745. */
  139746. getClassName(): string;
  139747. /**
  139748. * Gets the world position input component
  139749. */
  139750. get worldPosition(): NodeMaterialConnectionPoint;
  139751. /**
  139752. * Gets the world normal input component
  139753. */
  139754. get worldNormal(): NodeMaterialConnectionPoint;
  139755. /**
  139756. * Gets the world tangent input component
  139757. */
  139758. get worldTangent(): NodeMaterialConnectionPoint;
  139759. /**
  139760. * Gets the uv input component
  139761. */
  139762. get uv(): NodeMaterialConnectionPoint;
  139763. /**
  139764. * Gets the normal map color input component
  139765. */
  139766. get normalMapColor(): NodeMaterialConnectionPoint;
  139767. /**
  139768. * Gets the strength input component
  139769. */
  139770. get strength(): NodeMaterialConnectionPoint;
  139771. /**
  139772. * Gets the output component
  139773. */
  139774. get output(): NodeMaterialConnectionPoint;
  139775. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139776. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139777. autoConfigure(material: NodeMaterial): void;
  139778. protected _buildBlock(state: NodeMaterialBuildState): this;
  139779. protected _dumpPropertiesCode(): string;
  139780. serialize(): any;
  139781. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139782. }
  139783. }
  139784. declare module BABYLON {
  139785. /**
  139786. * Block used to discard a pixel if a value is smaller than a cutoff
  139787. */
  139788. export class DiscardBlock extends NodeMaterialBlock {
  139789. /**
  139790. * Create a new DiscardBlock
  139791. * @param name defines the block name
  139792. */
  139793. constructor(name: string);
  139794. /**
  139795. * Gets the current class name
  139796. * @returns the class name
  139797. */
  139798. getClassName(): string;
  139799. /**
  139800. * Gets the color input component
  139801. */
  139802. get value(): NodeMaterialConnectionPoint;
  139803. /**
  139804. * Gets the cutoff input component
  139805. */
  139806. get cutoff(): NodeMaterialConnectionPoint;
  139807. protected _buildBlock(state: NodeMaterialBuildState): this;
  139808. }
  139809. }
  139810. declare module BABYLON {
  139811. /**
  139812. * Block used to test if the fragment shader is front facing
  139813. */
  139814. export class FrontFacingBlock extends NodeMaterialBlock {
  139815. /**
  139816. * Creates a new FrontFacingBlock
  139817. * @param name defines the block name
  139818. */
  139819. constructor(name: string);
  139820. /**
  139821. * Gets the current class name
  139822. * @returns the class name
  139823. */
  139824. getClassName(): string;
  139825. /**
  139826. * Gets the output component
  139827. */
  139828. get output(): NodeMaterialConnectionPoint;
  139829. protected _buildBlock(state: NodeMaterialBuildState): this;
  139830. }
  139831. }
  139832. declare module BABYLON {
  139833. /**
  139834. * Block used to get the derivative value on x and y of a given input
  139835. */
  139836. export class DerivativeBlock extends NodeMaterialBlock {
  139837. /**
  139838. * Create a new DerivativeBlock
  139839. * @param name defines the block name
  139840. */
  139841. constructor(name: string);
  139842. /**
  139843. * Gets the current class name
  139844. * @returns the class name
  139845. */
  139846. getClassName(): string;
  139847. /**
  139848. * Gets the input component
  139849. */
  139850. get input(): NodeMaterialConnectionPoint;
  139851. /**
  139852. * Gets the derivative output on x
  139853. */
  139854. get dx(): NodeMaterialConnectionPoint;
  139855. /**
  139856. * Gets the derivative output on y
  139857. */
  139858. get dy(): NodeMaterialConnectionPoint;
  139859. protected _buildBlock(state: NodeMaterialBuildState): this;
  139860. }
  139861. }
  139862. declare module BABYLON {
  139863. /**
  139864. * Block used to make gl_FragCoord available
  139865. */
  139866. export class FragCoordBlock extends NodeMaterialBlock {
  139867. /**
  139868. * Creates a new FragCoordBlock
  139869. * @param name defines the block name
  139870. */
  139871. constructor(name: string);
  139872. /**
  139873. * Gets the current class name
  139874. * @returns the class name
  139875. */
  139876. getClassName(): string;
  139877. /**
  139878. * Gets the xy component
  139879. */
  139880. get xy(): NodeMaterialConnectionPoint;
  139881. /**
  139882. * Gets the xyz component
  139883. */
  139884. get xyz(): NodeMaterialConnectionPoint;
  139885. /**
  139886. * Gets the xyzw component
  139887. */
  139888. get xyzw(): NodeMaterialConnectionPoint;
  139889. /**
  139890. * Gets the x component
  139891. */
  139892. get x(): NodeMaterialConnectionPoint;
  139893. /**
  139894. * Gets the y component
  139895. */
  139896. get y(): NodeMaterialConnectionPoint;
  139897. /**
  139898. * Gets the z component
  139899. */
  139900. get z(): NodeMaterialConnectionPoint;
  139901. /**
  139902. * Gets the w component
  139903. */
  139904. get output(): NodeMaterialConnectionPoint;
  139905. protected writeOutputs(state: NodeMaterialBuildState): string;
  139906. protected _buildBlock(state: NodeMaterialBuildState): this;
  139907. }
  139908. }
  139909. declare module BABYLON {
  139910. /**
  139911. * Block used to get the screen sizes
  139912. */
  139913. export class ScreenSizeBlock extends NodeMaterialBlock {
  139914. private _varName;
  139915. private _scene;
  139916. /**
  139917. * Creates a new ScreenSizeBlock
  139918. * @param name defines the block name
  139919. */
  139920. constructor(name: string);
  139921. /**
  139922. * Gets the current class name
  139923. * @returns the class name
  139924. */
  139925. getClassName(): string;
  139926. /**
  139927. * Gets the xy component
  139928. */
  139929. get xy(): NodeMaterialConnectionPoint;
  139930. /**
  139931. * Gets the x component
  139932. */
  139933. get x(): NodeMaterialConnectionPoint;
  139934. /**
  139935. * Gets the y component
  139936. */
  139937. get y(): NodeMaterialConnectionPoint;
  139938. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139939. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  139940. protected _buildBlock(state: NodeMaterialBuildState): this;
  139941. }
  139942. }
  139943. declare module BABYLON {
  139944. /**
  139945. * Block used to add support for scene fog
  139946. */
  139947. export class FogBlock extends NodeMaterialBlock {
  139948. private _fogDistanceName;
  139949. private _fogParameters;
  139950. /**
  139951. * Create a new FogBlock
  139952. * @param name defines the block name
  139953. */
  139954. constructor(name: string);
  139955. /**
  139956. * Gets the current class name
  139957. * @returns the class name
  139958. */
  139959. getClassName(): string;
  139960. /**
  139961. * Gets the world position input component
  139962. */
  139963. get worldPosition(): NodeMaterialConnectionPoint;
  139964. /**
  139965. * Gets the view input component
  139966. */
  139967. get view(): NodeMaterialConnectionPoint;
  139968. /**
  139969. * Gets the color input component
  139970. */
  139971. get input(): NodeMaterialConnectionPoint;
  139972. /**
  139973. * Gets the fog color input component
  139974. */
  139975. get fogColor(): NodeMaterialConnectionPoint;
  139976. /**
  139977. * Gets the output component
  139978. */
  139979. get output(): NodeMaterialConnectionPoint;
  139980. autoConfigure(material: NodeMaterial): void;
  139981. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139982. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139983. protected _buildBlock(state: NodeMaterialBuildState): this;
  139984. }
  139985. }
  139986. declare module BABYLON {
  139987. /**
  139988. * Block used to add light in the fragment shader
  139989. */
  139990. export class LightBlock extends NodeMaterialBlock {
  139991. private _lightId;
  139992. /**
  139993. * Gets or sets the light associated with this block
  139994. */
  139995. light: Nullable<Light>;
  139996. /**
  139997. * Create a new LightBlock
  139998. * @param name defines the block name
  139999. */
  140000. constructor(name: string);
  140001. /**
  140002. * Gets the current class name
  140003. * @returns the class name
  140004. */
  140005. getClassName(): string;
  140006. /**
  140007. * Gets the world position input component
  140008. */
  140009. get worldPosition(): NodeMaterialConnectionPoint;
  140010. /**
  140011. * Gets the world normal input component
  140012. */
  140013. get worldNormal(): NodeMaterialConnectionPoint;
  140014. /**
  140015. * Gets the camera (or eye) position component
  140016. */
  140017. get cameraPosition(): NodeMaterialConnectionPoint;
  140018. /**
  140019. * Gets the glossiness component
  140020. */
  140021. get glossiness(): NodeMaterialConnectionPoint;
  140022. /**
  140023. * Gets the glossinness power component
  140024. */
  140025. get glossPower(): NodeMaterialConnectionPoint;
  140026. /**
  140027. * Gets the diffuse color component
  140028. */
  140029. get diffuseColor(): NodeMaterialConnectionPoint;
  140030. /**
  140031. * Gets the specular color component
  140032. */
  140033. get specularColor(): NodeMaterialConnectionPoint;
  140034. /**
  140035. * Gets the diffuse output component
  140036. */
  140037. get diffuseOutput(): NodeMaterialConnectionPoint;
  140038. /**
  140039. * Gets the specular output component
  140040. */
  140041. get specularOutput(): NodeMaterialConnectionPoint;
  140042. /**
  140043. * Gets the shadow output component
  140044. */
  140045. get shadow(): NodeMaterialConnectionPoint;
  140046. autoConfigure(material: NodeMaterial): void;
  140047. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140048. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  140049. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140050. private _injectVertexCode;
  140051. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140052. serialize(): any;
  140053. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140054. }
  140055. }
  140056. declare module BABYLON {
  140057. /**
  140058. * Block used to read a reflection texture from a sampler
  140059. */
  140060. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  140061. /**
  140062. * Create a new ReflectionTextureBlock
  140063. * @param name defines the block name
  140064. */
  140065. constructor(name: string);
  140066. /**
  140067. * Gets the current class name
  140068. * @returns the class name
  140069. */
  140070. getClassName(): string;
  140071. /**
  140072. * Gets the world position input component
  140073. */
  140074. get position(): NodeMaterialConnectionPoint;
  140075. /**
  140076. * Gets the world position input component
  140077. */
  140078. get worldPosition(): NodeMaterialConnectionPoint;
  140079. /**
  140080. * Gets the world normal input component
  140081. */
  140082. get worldNormal(): NodeMaterialConnectionPoint;
  140083. /**
  140084. * Gets the world input component
  140085. */
  140086. get world(): NodeMaterialConnectionPoint;
  140087. /**
  140088. * Gets the camera (or eye) position component
  140089. */
  140090. get cameraPosition(): NodeMaterialConnectionPoint;
  140091. /**
  140092. * Gets the view input component
  140093. */
  140094. get view(): NodeMaterialConnectionPoint;
  140095. /**
  140096. * Gets the rgb output component
  140097. */
  140098. get rgb(): NodeMaterialConnectionPoint;
  140099. /**
  140100. * Gets the rgba output component
  140101. */
  140102. get rgba(): NodeMaterialConnectionPoint;
  140103. /**
  140104. * Gets the r output component
  140105. */
  140106. get r(): NodeMaterialConnectionPoint;
  140107. /**
  140108. * Gets the g output component
  140109. */
  140110. get g(): NodeMaterialConnectionPoint;
  140111. /**
  140112. * Gets the b output component
  140113. */
  140114. get b(): NodeMaterialConnectionPoint;
  140115. /**
  140116. * Gets the a output component
  140117. */
  140118. get a(): NodeMaterialConnectionPoint;
  140119. autoConfigure(material: NodeMaterial): void;
  140120. protected _buildBlock(state: NodeMaterialBuildState): this;
  140121. }
  140122. }
  140123. declare module BABYLON {
  140124. /**
  140125. * Block used to add 2 vectors
  140126. */
  140127. export class AddBlock extends NodeMaterialBlock {
  140128. /**
  140129. * Creates a new AddBlock
  140130. * @param name defines the block name
  140131. */
  140132. constructor(name: string);
  140133. /**
  140134. * Gets the current class name
  140135. * @returns the class name
  140136. */
  140137. getClassName(): string;
  140138. /**
  140139. * Gets the left operand input component
  140140. */
  140141. get left(): NodeMaterialConnectionPoint;
  140142. /**
  140143. * Gets the right operand input component
  140144. */
  140145. get right(): NodeMaterialConnectionPoint;
  140146. /**
  140147. * Gets the output component
  140148. */
  140149. get output(): NodeMaterialConnectionPoint;
  140150. protected _buildBlock(state: NodeMaterialBuildState): this;
  140151. }
  140152. }
  140153. declare module BABYLON {
  140154. /**
  140155. * Block used to scale a vector by a float
  140156. */
  140157. export class ScaleBlock extends NodeMaterialBlock {
  140158. /**
  140159. * Creates a new ScaleBlock
  140160. * @param name defines the block name
  140161. */
  140162. constructor(name: string);
  140163. /**
  140164. * Gets the current class name
  140165. * @returns the class name
  140166. */
  140167. getClassName(): string;
  140168. /**
  140169. * Gets the input component
  140170. */
  140171. get input(): NodeMaterialConnectionPoint;
  140172. /**
  140173. * Gets the factor input component
  140174. */
  140175. get factor(): NodeMaterialConnectionPoint;
  140176. /**
  140177. * Gets the output component
  140178. */
  140179. get output(): NodeMaterialConnectionPoint;
  140180. protected _buildBlock(state: NodeMaterialBuildState): this;
  140181. }
  140182. }
  140183. declare module BABYLON {
  140184. /**
  140185. * Block used to clamp a float
  140186. */
  140187. export class ClampBlock extends NodeMaterialBlock {
  140188. /** Gets or sets the minimum range */
  140189. minimum: number;
  140190. /** Gets or sets the maximum range */
  140191. maximum: number;
  140192. /**
  140193. * Creates a new ClampBlock
  140194. * @param name defines the block name
  140195. */
  140196. constructor(name: string);
  140197. /**
  140198. * Gets the current class name
  140199. * @returns the class name
  140200. */
  140201. getClassName(): string;
  140202. /**
  140203. * Gets the value input component
  140204. */
  140205. get value(): NodeMaterialConnectionPoint;
  140206. /**
  140207. * Gets the output component
  140208. */
  140209. get output(): NodeMaterialConnectionPoint;
  140210. protected _buildBlock(state: NodeMaterialBuildState): this;
  140211. protected _dumpPropertiesCode(): string;
  140212. serialize(): any;
  140213. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140214. }
  140215. }
  140216. declare module BABYLON {
  140217. /**
  140218. * Block used to apply a cross product between 2 vectors
  140219. */
  140220. export class CrossBlock extends NodeMaterialBlock {
  140221. /**
  140222. * Creates a new CrossBlock
  140223. * @param name defines the block name
  140224. */
  140225. constructor(name: string);
  140226. /**
  140227. * Gets the current class name
  140228. * @returns the class name
  140229. */
  140230. getClassName(): string;
  140231. /**
  140232. * Gets the left operand input component
  140233. */
  140234. get left(): NodeMaterialConnectionPoint;
  140235. /**
  140236. * Gets the right operand input component
  140237. */
  140238. get right(): NodeMaterialConnectionPoint;
  140239. /**
  140240. * Gets the output component
  140241. */
  140242. get output(): NodeMaterialConnectionPoint;
  140243. protected _buildBlock(state: NodeMaterialBuildState): this;
  140244. }
  140245. }
  140246. declare module BABYLON {
  140247. /**
  140248. * Block used to apply a dot product between 2 vectors
  140249. */
  140250. export class DotBlock extends NodeMaterialBlock {
  140251. /**
  140252. * Creates a new DotBlock
  140253. * @param name defines the block name
  140254. */
  140255. constructor(name: string);
  140256. /**
  140257. * Gets the current class name
  140258. * @returns the class name
  140259. */
  140260. getClassName(): string;
  140261. /**
  140262. * Gets the left operand input component
  140263. */
  140264. get left(): NodeMaterialConnectionPoint;
  140265. /**
  140266. * Gets the right operand input component
  140267. */
  140268. get right(): NodeMaterialConnectionPoint;
  140269. /**
  140270. * Gets the output component
  140271. */
  140272. get output(): NodeMaterialConnectionPoint;
  140273. protected _buildBlock(state: NodeMaterialBuildState): this;
  140274. }
  140275. }
  140276. declare module BABYLON {
  140277. /**
  140278. * Block used to normalize a vector
  140279. */
  140280. export class NormalizeBlock extends NodeMaterialBlock {
  140281. /**
  140282. * Creates a new NormalizeBlock
  140283. * @param name defines the block name
  140284. */
  140285. constructor(name: string);
  140286. /**
  140287. * Gets the current class name
  140288. * @returns the class name
  140289. */
  140290. getClassName(): string;
  140291. /**
  140292. * Gets the input component
  140293. */
  140294. get input(): NodeMaterialConnectionPoint;
  140295. /**
  140296. * Gets the output component
  140297. */
  140298. get output(): NodeMaterialConnectionPoint;
  140299. protected _buildBlock(state: NodeMaterialBuildState): this;
  140300. }
  140301. }
  140302. declare module BABYLON {
  140303. /**
  140304. * Operations supported by the Trigonometry block
  140305. */
  140306. export enum TrigonometryBlockOperations {
  140307. /** Cos */
  140308. Cos = 0,
  140309. /** Sin */
  140310. Sin = 1,
  140311. /** Abs */
  140312. Abs = 2,
  140313. /** Exp */
  140314. Exp = 3,
  140315. /** Exp2 */
  140316. Exp2 = 4,
  140317. /** Round */
  140318. Round = 5,
  140319. /** Floor */
  140320. Floor = 6,
  140321. /** Ceiling */
  140322. Ceiling = 7,
  140323. /** Square root */
  140324. Sqrt = 8,
  140325. /** Log */
  140326. Log = 9,
  140327. /** Tangent */
  140328. Tan = 10,
  140329. /** Arc tangent */
  140330. ArcTan = 11,
  140331. /** Arc cosinus */
  140332. ArcCos = 12,
  140333. /** Arc sinus */
  140334. ArcSin = 13,
  140335. /** Fraction */
  140336. Fract = 14,
  140337. /** Sign */
  140338. Sign = 15,
  140339. /** To radians (from degrees) */
  140340. Radians = 16,
  140341. /** To degrees (from radians) */
  140342. Degrees = 17
  140343. }
  140344. /**
  140345. * Block used to apply trigonometry operation to floats
  140346. */
  140347. export class TrigonometryBlock extends NodeMaterialBlock {
  140348. /**
  140349. * Gets or sets the operation applied by the block
  140350. */
  140351. operation: TrigonometryBlockOperations;
  140352. /**
  140353. * Creates a new TrigonometryBlock
  140354. * @param name defines the block name
  140355. */
  140356. constructor(name: string);
  140357. /**
  140358. * Gets the current class name
  140359. * @returns the class name
  140360. */
  140361. getClassName(): string;
  140362. /**
  140363. * Gets the input component
  140364. */
  140365. get input(): NodeMaterialConnectionPoint;
  140366. /**
  140367. * Gets the output component
  140368. */
  140369. get output(): NodeMaterialConnectionPoint;
  140370. protected _buildBlock(state: NodeMaterialBuildState): this;
  140371. serialize(): any;
  140372. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140373. protected _dumpPropertiesCode(): string;
  140374. }
  140375. }
  140376. declare module BABYLON {
  140377. /**
  140378. * Block used to create a Color3/4 out of individual inputs (one for each component)
  140379. */
  140380. export class ColorMergerBlock extends NodeMaterialBlock {
  140381. /**
  140382. * Create a new ColorMergerBlock
  140383. * @param name defines the block name
  140384. */
  140385. constructor(name: string);
  140386. /**
  140387. * Gets the current class name
  140388. * @returns the class name
  140389. */
  140390. getClassName(): string;
  140391. /**
  140392. * Gets the rgb component (input)
  140393. */
  140394. get rgbIn(): NodeMaterialConnectionPoint;
  140395. /**
  140396. * Gets the r component (input)
  140397. */
  140398. get r(): NodeMaterialConnectionPoint;
  140399. /**
  140400. * Gets the g component (input)
  140401. */
  140402. get g(): NodeMaterialConnectionPoint;
  140403. /**
  140404. * Gets the b component (input)
  140405. */
  140406. get b(): NodeMaterialConnectionPoint;
  140407. /**
  140408. * Gets the a component (input)
  140409. */
  140410. get a(): NodeMaterialConnectionPoint;
  140411. /**
  140412. * Gets the rgba component (output)
  140413. */
  140414. get rgba(): NodeMaterialConnectionPoint;
  140415. /**
  140416. * Gets the rgb component (output)
  140417. */
  140418. get rgbOut(): NodeMaterialConnectionPoint;
  140419. /**
  140420. * Gets the rgb component (output)
  140421. * @deprecated Please use rgbOut instead.
  140422. */
  140423. get rgb(): NodeMaterialConnectionPoint;
  140424. protected _buildBlock(state: NodeMaterialBuildState): this;
  140425. }
  140426. }
  140427. declare module BABYLON {
  140428. /**
  140429. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  140430. */
  140431. export class VectorSplitterBlock extends NodeMaterialBlock {
  140432. /**
  140433. * Create a new VectorSplitterBlock
  140434. * @param name defines the block name
  140435. */
  140436. constructor(name: string);
  140437. /**
  140438. * Gets the current class name
  140439. * @returns the class name
  140440. */
  140441. getClassName(): string;
  140442. /**
  140443. * Gets the xyzw component (input)
  140444. */
  140445. get xyzw(): NodeMaterialConnectionPoint;
  140446. /**
  140447. * Gets the xyz component (input)
  140448. */
  140449. get xyzIn(): NodeMaterialConnectionPoint;
  140450. /**
  140451. * Gets the xy component (input)
  140452. */
  140453. get xyIn(): NodeMaterialConnectionPoint;
  140454. /**
  140455. * Gets the xyz component (output)
  140456. */
  140457. get xyzOut(): NodeMaterialConnectionPoint;
  140458. /**
  140459. * Gets the xy component (output)
  140460. */
  140461. get xyOut(): NodeMaterialConnectionPoint;
  140462. /**
  140463. * Gets the x component (output)
  140464. */
  140465. get x(): NodeMaterialConnectionPoint;
  140466. /**
  140467. * Gets the y component (output)
  140468. */
  140469. get y(): NodeMaterialConnectionPoint;
  140470. /**
  140471. * Gets the z component (output)
  140472. */
  140473. get z(): NodeMaterialConnectionPoint;
  140474. /**
  140475. * Gets the w component (output)
  140476. */
  140477. get w(): NodeMaterialConnectionPoint;
  140478. protected _inputRename(name: string): string;
  140479. protected _outputRename(name: string): string;
  140480. protected _buildBlock(state: NodeMaterialBuildState): this;
  140481. }
  140482. }
  140483. declare module BABYLON {
  140484. /**
  140485. * Block used to lerp between 2 values
  140486. */
  140487. export class LerpBlock extends NodeMaterialBlock {
  140488. /**
  140489. * Creates a new LerpBlock
  140490. * @param name defines the block name
  140491. */
  140492. constructor(name: string);
  140493. /**
  140494. * Gets the current class name
  140495. * @returns the class name
  140496. */
  140497. getClassName(): string;
  140498. /**
  140499. * Gets the left operand input component
  140500. */
  140501. get left(): NodeMaterialConnectionPoint;
  140502. /**
  140503. * Gets the right operand input component
  140504. */
  140505. get right(): NodeMaterialConnectionPoint;
  140506. /**
  140507. * Gets the gradient operand input component
  140508. */
  140509. get gradient(): NodeMaterialConnectionPoint;
  140510. /**
  140511. * Gets the output component
  140512. */
  140513. get output(): NodeMaterialConnectionPoint;
  140514. protected _buildBlock(state: NodeMaterialBuildState): this;
  140515. }
  140516. }
  140517. declare module BABYLON {
  140518. /**
  140519. * Block used to divide 2 vectors
  140520. */
  140521. export class DivideBlock extends NodeMaterialBlock {
  140522. /**
  140523. * Creates a new DivideBlock
  140524. * @param name defines the block name
  140525. */
  140526. constructor(name: string);
  140527. /**
  140528. * Gets the current class name
  140529. * @returns the class name
  140530. */
  140531. getClassName(): string;
  140532. /**
  140533. * Gets the left operand input component
  140534. */
  140535. get left(): NodeMaterialConnectionPoint;
  140536. /**
  140537. * Gets the right operand input component
  140538. */
  140539. get right(): NodeMaterialConnectionPoint;
  140540. /**
  140541. * Gets the output component
  140542. */
  140543. get output(): NodeMaterialConnectionPoint;
  140544. protected _buildBlock(state: NodeMaterialBuildState): this;
  140545. }
  140546. }
  140547. declare module BABYLON {
  140548. /**
  140549. * Block used to subtract 2 vectors
  140550. */
  140551. export class SubtractBlock extends NodeMaterialBlock {
  140552. /**
  140553. * Creates a new SubtractBlock
  140554. * @param name defines the block name
  140555. */
  140556. constructor(name: string);
  140557. /**
  140558. * Gets the current class name
  140559. * @returns the class name
  140560. */
  140561. getClassName(): string;
  140562. /**
  140563. * Gets the left operand input component
  140564. */
  140565. get left(): NodeMaterialConnectionPoint;
  140566. /**
  140567. * Gets the right operand input component
  140568. */
  140569. get right(): NodeMaterialConnectionPoint;
  140570. /**
  140571. * Gets the output component
  140572. */
  140573. get output(): NodeMaterialConnectionPoint;
  140574. protected _buildBlock(state: NodeMaterialBuildState): this;
  140575. }
  140576. }
  140577. declare module BABYLON {
  140578. /**
  140579. * Block used to step a value
  140580. */
  140581. export class StepBlock extends NodeMaterialBlock {
  140582. /**
  140583. * Creates a new StepBlock
  140584. * @param name defines the block name
  140585. */
  140586. constructor(name: string);
  140587. /**
  140588. * Gets the current class name
  140589. * @returns the class name
  140590. */
  140591. getClassName(): string;
  140592. /**
  140593. * Gets the value operand input component
  140594. */
  140595. get value(): NodeMaterialConnectionPoint;
  140596. /**
  140597. * Gets the edge operand input component
  140598. */
  140599. get edge(): NodeMaterialConnectionPoint;
  140600. /**
  140601. * Gets the output component
  140602. */
  140603. get output(): NodeMaterialConnectionPoint;
  140604. protected _buildBlock(state: NodeMaterialBuildState): this;
  140605. }
  140606. }
  140607. declare module BABYLON {
  140608. /**
  140609. * Block used to get the opposite (1 - x) of a value
  140610. */
  140611. export class OneMinusBlock extends NodeMaterialBlock {
  140612. /**
  140613. * Creates a new OneMinusBlock
  140614. * @param name defines the block name
  140615. */
  140616. constructor(name: string);
  140617. /**
  140618. * Gets the current class name
  140619. * @returns the class name
  140620. */
  140621. getClassName(): string;
  140622. /**
  140623. * Gets the input component
  140624. */
  140625. get input(): NodeMaterialConnectionPoint;
  140626. /**
  140627. * Gets the output component
  140628. */
  140629. get output(): NodeMaterialConnectionPoint;
  140630. protected _buildBlock(state: NodeMaterialBuildState): this;
  140631. }
  140632. }
  140633. declare module BABYLON {
  140634. /**
  140635. * Block used to get the view direction
  140636. */
  140637. export class ViewDirectionBlock extends NodeMaterialBlock {
  140638. /**
  140639. * Creates a new ViewDirectionBlock
  140640. * @param name defines the block name
  140641. */
  140642. constructor(name: string);
  140643. /**
  140644. * Gets the current class name
  140645. * @returns the class name
  140646. */
  140647. getClassName(): string;
  140648. /**
  140649. * Gets the world position component
  140650. */
  140651. get worldPosition(): NodeMaterialConnectionPoint;
  140652. /**
  140653. * Gets the camera position component
  140654. */
  140655. get cameraPosition(): NodeMaterialConnectionPoint;
  140656. /**
  140657. * Gets the output component
  140658. */
  140659. get output(): NodeMaterialConnectionPoint;
  140660. autoConfigure(material: NodeMaterial): void;
  140661. protected _buildBlock(state: NodeMaterialBuildState): this;
  140662. }
  140663. }
  140664. declare module BABYLON {
  140665. /**
  140666. * Block used to compute fresnel value
  140667. */
  140668. export class FresnelBlock extends NodeMaterialBlock {
  140669. /**
  140670. * Create a new FresnelBlock
  140671. * @param name defines the block name
  140672. */
  140673. constructor(name: string);
  140674. /**
  140675. * Gets the current class name
  140676. * @returns the class name
  140677. */
  140678. getClassName(): string;
  140679. /**
  140680. * Gets the world normal input component
  140681. */
  140682. get worldNormal(): NodeMaterialConnectionPoint;
  140683. /**
  140684. * Gets the view direction input component
  140685. */
  140686. get viewDirection(): NodeMaterialConnectionPoint;
  140687. /**
  140688. * Gets the bias input component
  140689. */
  140690. get bias(): NodeMaterialConnectionPoint;
  140691. /**
  140692. * Gets the camera (or eye) position component
  140693. */
  140694. get power(): NodeMaterialConnectionPoint;
  140695. /**
  140696. * Gets the fresnel output component
  140697. */
  140698. get fresnel(): NodeMaterialConnectionPoint;
  140699. autoConfigure(material: NodeMaterial): void;
  140700. protected _buildBlock(state: NodeMaterialBuildState): this;
  140701. }
  140702. }
  140703. declare module BABYLON {
  140704. /**
  140705. * Block used to get the max of 2 values
  140706. */
  140707. export class MaxBlock extends NodeMaterialBlock {
  140708. /**
  140709. * Creates a new MaxBlock
  140710. * @param name defines the block name
  140711. */
  140712. constructor(name: string);
  140713. /**
  140714. * Gets the current class name
  140715. * @returns the class name
  140716. */
  140717. getClassName(): string;
  140718. /**
  140719. * Gets the left operand input component
  140720. */
  140721. get left(): NodeMaterialConnectionPoint;
  140722. /**
  140723. * Gets the right operand input component
  140724. */
  140725. get right(): NodeMaterialConnectionPoint;
  140726. /**
  140727. * Gets the output component
  140728. */
  140729. get output(): NodeMaterialConnectionPoint;
  140730. protected _buildBlock(state: NodeMaterialBuildState): this;
  140731. }
  140732. }
  140733. declare module BABYLON {
  140734. /**
  140735. * Block used to get the min of 2 values
  140736. */
  140737. export class MinBlock extends NodeMaterialBlock {
  140738. /**
  140739. * Creates a new MinBlock
  140740. * @param name defines the block name
  140741. */
  140742. constructor(name: string);
  140743. /**
  140744. * Gets the current class name
  140745. * @returns the class name
  140746. */
  140747. getClassName(): string;
  140748. /**
  140749. * Gets the left operand input component
  140750. */
  140751. get left(): NodeMaterialConnectionPoint;
  140752. /**
  140753. * Gets the right operand input component
  140754. */
  140755. get right(): NodeMaterialConnectionPoint;
  140756. /**
  140757. * Gets the output component
  140758. */
  140759. get output(): NodeMaterialConnectionPoint;
  140760. protected _buildBlock(state: NodeMaterialBuildState): this;
  140761. }
  140762. }
  140763. declare module BABYLON {
  140764. /**
  140765. * Block used to get the distance between 2 values
  140766. */
  140767. export class DistanceBlock extends NodeMaterialBlock {
  140768. /**
  140769. * Creates a new DistanceBlock
  140770. * @param name defines the block name
  140771. */
  140772. constructor(name: string);
  140773. /**
  140774. * Gets the current class name
  140775. * @returns the class name
  140776. */
  140777. getClassName(): string;
  140778. /**
  140779. * Gets the left operand input component
  140780. */
  140781. get left(): NodeMaterialConnectionPoint;
  140782. /**
  140783. * Gets the right operand input component
  140784. */
  140785. get right(): NodeMaterialConnectionPoint;
  140786. /**
  140787. * Gets the output component
  140788. */
  140789. get output(): NodeMaterialConnectionPoint;
  140790. protected _buildBlock(state: NodeMaterialBuildState): this;
  140791. }
  140792. }
  140793. declare module BABYLON {
  140794. /**
  140795. * Block used to get the length of a vector
  140796. */
  140797. export class LengthBlock extends NodeMaterialBlock {
  140798. /**
  140799. * Creates a new LengthBlock
  140800. * @param name defines the block name
  140801. */
  140802. constructor(name: string);
  140803. /**
  140804. * Gets the current class name
  140805. * @returns the class name
  140806. */
  140807. getClassName(): string;
  140808. /**
  140809. * Gets the value input component
  140810. */
  140811. get value(): NodeMaterialConnectionPoint;
  140812. /**
  140813. * Gets the output component
  140814. */
  140815. get output(): NodeMaterialConnectionPoint;
  140816. protected _buildBlock(state: NodeMaterialBuildState): this;
  140817. }
  140818. }
  140819. declare module BABYLON {
  140820. /**
  140821. * Block used to get negative version of a value (i.e. x * -1)
  140822. */
  140823. export class NegateBlock extends NodeMaterialBlock {
  140824. /**
  140825. * Creates a new NegateBlock
  140826. * @param name defines the block name
  140827. */
  140828. constructor(name: string);
  140829. /**
  140830. * Gets the current class name
  140831. * @returns the class name
  140832. */
  140833. getClassName(): string;
  140834. /**
  140835. * Gets the value input component
  140836. */
  140837. get value(): NodeMaterialConnectionPoint;
  140838. /**
  140839. * Gets the output component
  140840. */
  140841. get output(): NodeMaterialConnectionPoint;
  140842. protected _buildBlock(state: NodeMaterialBuildState): this;
  140843. }
  140844. }
  140845. declare module BABYLON {
  140846. /**
  140847. * Block used to get the value of the first parameter raised to the power of the second
  140848. */
  140849. export class PowBlock extends NodeMaterialBlock {
  140850. /**
  140851. * Creates a new PowBlock
  140852. * @param name defines the block name
  140853. */
  140854. constructor(name: string);
  140855. /**
  140856. * Gets the current class name
  140857. * @returns the class name
  140858. */
  140859. getClassName(): string;
  140860. /**
  140861. * Gets the value operand input component
  140862. */
  140863. get value(): NodeMaterialConnectionPoint;
  140864. /**
  140865. * Gets the power operand input component
  140866. */
  140867. get power(): NodeMaterialConnectionPoint;
  140868. /**
  140869. * Gets the output component
  140870. */
  140871. get output(): NodeMaterialConnectionPoint;
  140872. protected _buildBlock(state: NodeMaterialBuildState): this;
  140873. }
  140874. }
  140875. declare module BABYLON {
  140876. /**
  140877. * Block used to get a random number
  140878. */
  140879. export class RandomNumberBlock extends NodeMaterialBlock {
  140880. /**
  140881. * Creates a new RandomNumberBlock
  140882. * @param name defines the block name
  140883. */
  140884. constructor(name: string);
  140885. /**
  140886. * Gets the current class name
  140887. * @returns the class name
  140888. */
  140889. getClassName(): string;
  140890. /**
  140891. * Gets the seed input component
  140892. */
  140893. get seed(): NodeMaterialConnectionPoint;
  140894. /**
  140895. * Gets the output component
  140896. */
  140897. get output(): NodeMaterialConnectionPoint;
  140898. protected _buildBlock(state: NodeMaterialBuildState): this;
  140899. }
  140900. }
  140901. declare module BABYLON {
  140902. /**
  140903. * Block used to compute arc tangent of 2 values
  140904. */
  140905. export class ArcTan2Block extends NodeMaterialBlock {
  140906. /**
  140907. * Creates a new ArcTan2Block
  140908. * @param name defines the block name
  140909. */
  140910. constructor(name: string);
  140911. /**
  140912. * Gets the current class name
  140913. * @returns the class name
  140914. */
  140915. getClassName(): string;
  140916. /**
  140917. * Gets the x operand input component
  140918. */
  140919. get x(): NodeMaterialConnectionPoint;
  140920. /**
  140921. * Gets the y operand input component
  140922. */
  140923. get y(): NodeMaterialConnectionPoint;
  140924. /**
  140925. * Gets the output component
  140926. */
  140927. get output(): NodeMaterialConnectionPoint;
  140928. protected _buildBlock(state: NodeMaterialBuildState): this;
  140929. }
  140930. }
  140931. declare module BABYLON {
  140932. /**
  140933. * Block used to smooth step a value
  140934. */
  140935. export class SmoothStepBlock extends NodeMaterialBlock {
  140936. /**
  140937. * Creates a new SmoothStepBlock
  140938. * @param name defines the block name
  140939. */
  140940. constructor(name: string);
  140941. /**
  140942. * Gets the current class name
  140943. * @returns the class name
  140944. */
  140945. getClassName(): string;
  140946. /**
  140947. * Gets the value operand input component
  140948. */
  140949. get value(): NodeMaterialConnectionPoint;
  140950. /**
  140951. * Gets the first edge operand input component
  140952. */
  140953. get edge0(): NodeMaterialConnectionPoint;
  140954. /**
  140955. * Gets the second edge operand input component
  140956. */
  140957. get edge1(): NodeMaterialConnectionPoint;
  140958. /**
  140959. * Gets the output component
  140960. */
  140961. get output(): NodeMaterialConnectionPoint;
  140962. protected _buildBlock(state: NodeMaterialBuildState): this;
  140963. }
  140964. }
  140965. declare module BABYLON {
  140966. /**
  140967. * Block used to get the reciprocal (1 / x) of a value
  140968. */
  140969. export class ReciprocalBlock extends NodeMaterialBlock {
  140970. /**
  140971. * Creates a new ReciprocalBlock
  140972. * @param name defines the block name
  140973. */
  140974. constructor(name: string);
  140975. /**
  140976. * Gets the current class name
  140977. * @returns the class name
  140978. */
  140979. getClassName(): string;
  140980. /**
  140981. * Gets the input component
  140982. */
  140983. get input(): NodeMaterialConnectionPoint;
  140984. /**
  140985. * Gets the output component
  140986. */
  140987. get output(): NodeMaterialConnectionPoint;
  140988. protected _buildBlock(state: NodeMaterialBuildState): this;
  140989. }
  140990. }
  140991. declare module BABYLON {
  140992. /**
  140993. * Block used to replace a color by another one
  140994. */
  140995. export class ReplaceColorBlock extends NodeMaterialBlock {
  140996. /**
  140997. * Creates a new ReplaceColorBlock
  140998. * @param name defines the block name
  140999. */
  141000. constructor(name: string);
  141001. /**
  141002. * Gets the current class name
  141003. * @returns the class name
  141004. */
  141005. getClassName(): string;
  141006. /**
  141007. * Gets the value input component
  141008. */
  141009. get value(): NodeMaterialConnectionPoint;
  141010. /**
  141011. * Gets the reference input component
  141012. */
  141013. get reference(): NodeMaterialConnectionPoint;
  141014. /**
  141015. * Gets the distance input component
  141016. */
  141017. get distance(): NodeMaterialConnectionPoint;
  141018. /**
  141019. * Gets the replacement input component
  141020. */
  141021. get replacement(): NodeMaterialConnectionPoint;
  141022. /**
  141023. * Gets the output component
  141024. */
  141025. get output(): NodeMaterialConnectionPoint;
  141026. protected _buildBlock(state: NodeMaterialBuildState): this;
  141027. }
  141028. }
  141029. declare module BABYLON {
  141030. /**
  141031. * Block used to posterize a value
  141032. * @see https://en.wikipedia.org/wiki/Posterization
  141033. */
  141034. export class PosterizeBlock extends NodeMaterialBlock {
  141035. /**
  141036. * Creates a new PosterizeBlock
  141037. * @param name defines the block name
  141038. */
  141039. constructor(name: string);
  141040. /**
  141041. * Gets the current class name
  141042. * @returns the class name
  141043. */
  141044. getClassName(): string;
  141045. /**
  141046. * Gets the value input component
  141047. */
  141048. get value(): NodeMaterialConnectionPoint;
  141049. /**
  141050. * Gets the steps input component
  141051. */
  141052. get steps(): NodeMaterialConnectionPoint;
  141053. /**
  141054. * Gets the output component
  141055. */
  141056. get output(): NodeMaterialConnectionPoint;
  141057. protected _buildBlock(state: NodeMaterialBuildState): this;
  141058. }
  141059. }
  141060. declare module BABYLON {
  141061. /**
  141062. * Operations supported by the Wave block
  141063. */
  141064. export enum WaveBlockKind {
  141065. /** SawTooth */
  141066. SawTooth = 0,
  141067. /** Square */
  141068. Square = 1,
  141069. /** Triangle */
  141070. Triangle = 2
  141071. }
  141072. /**
  141073. * Block used to apply wave operation to floats
  141074. */
  141075. export class WaveBlock extends NodeMaterialBlock {
  141076. /**
  141077. * Gets or sets the kibnd of wave to be applied by the block
  141078. */
  141079. kind: WaveBlockKind;
  141080. /**
  141081. * Creates a new WaveBlock
  141082. * @param name defines the block name
  141083. */
  141084. constructor(name: string);
  141085. /**
  141086. * Gets the current class name
  141087. * @returns the class name
  141088. */
  141089. getClassName(): string;
  141090. /**
  141091. * Gets the input component
  141092. */
  141093. get input(): NodeMaterialConnectionPoint;
  141094. /**
  141095. * Gets the output component
  141096. */
  141097. get output(): NodeMaterialConnectionPoint;
  141098. protected _buildBlock(state: NodeMaterialBuildState): this;
  141099. serialize(): any;
  141100. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141101. }
  141102. }
  141103. declare module BABYLON {
  141104. /**
  141105. * Class used to store a color step for the GradientBlock
  141106. */
  141107. export class GradientBlockColorStep {
  141108. /**
  141109. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141110. */
  141111. step: number;
  141112. /**
  141113. * Gets or sets the color associated with this step
  141114. */
  141115. color: Color3;
  141116. /**
  141117. * Creates a new GradientBlockColorStep
  141118. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  141119. * @param color defines the color associated with this step
  141120. */
  141121. constructor(
  141122. /**
  141123. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141124. */
  141125. step: number,
  141126. /**
  141127. * Gets or sets the color associated with this step
  141128. */
  141129. color: Color3);
  141130. }
  141131. /**
  141132. * Block used to return a color from a gradient based on an input value between 0 and 1
  141133. */
  141134. export class GradientBlock extends NodeMaterialBlock {
  141135. /**
  141136. * Gets or sets the list of color steps
  141137. */
  141138. colorSteps: GradientBlockColorStep[];
  141139. /**
  141140. * Creates a new GradientBlock
  141141. * @param name defines the block name
  141142. */
  141143. constructor(name: string);
  141144. /**
  141145. * Gets the current class name
  141146. * @returns the class name
  141147. */
  141148. getClassName(): string;
  141149. /**
  141150. * Gets the gradient input component
  141151. */
  141152. get gradient(): NodeMaterialConnectionPoint;
  141153. /**
  141154. * Gets the output component
  141155. */
  141156. get output(): NodeMaterialConnectionPoint;
  141157. private _writeColorConstant;
  141158. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141159. serialize(): any;
  141160. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141161. protected _dumpPropertiesCode(): string;
  141162. }
  141163. }
  141164. declare module BABYLON {
  141165. /**
  141166. * Block used to normalize lerp between 2 values
  141167. */
  141168. export class NLerpBlock extends NodeMaterialBlock {
  141169. /**
  141170. * Creates a new NLerpBlock
  141171. * @param name defines the block name
  141172. */
  141173. constructor(name: string);
  141174. /**
  141175. * Gets the current class name
  141176. * @returns the class name
  141177. */
  141178. getClassName(): string;
  141179. /**
  141180. * Gets the left operand input component
  141181. */
  141182. get left(): NodeMaterialConnectionPoint;
  141183. /**
  141184. * Gets the right operand input component
  141185. */
  141186. get right(): NodeMaterialConnectionPoint;
  141187. /**
  141188. * Gets the gradient operand input component
  141189. */
  141190. get gradient(): NodeMaterialConnectionPoint;
  141191. /**
  141192. * Gets the output component
  141193. */
  141194. get output(): NodeMaterialConnectionPoint;
  141195. protected _buildBlock(state: NodeMaterialBuildState): this;
  141196. }
  141197. }
  141198. declare module BABYLON {
  141199. /**
  141200. * block used to Generate a Worley Noise 3D Noise Pattern
  141201. */
  141202. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  141203. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  141204. manhattanDistance: boolean;
  141205. /**
  141206. * Creates a new WorleyNoise3DBlock
  141207. * @param name defines the block name
  141208. */
  141209. constructor(name: string);
  141210. /**
  141211. * Gets the current class name
  141212. * @returns the class name
  141213. */
  141214. getClassName(): string;
  141215. /**
  141216. * Gets the seed input component
  141217. */
  141218. get seed(): NodeMaterialConnectionPoint;
  141219. /**
  141220. * Gets the jitter input component
  141221. */
  141222. get jitter(): NodeMaterialConnectionPoint;
  141223. /**
  141224. * Gets the output component
  141225. */
  141226. get output(): NodeMaterialConnectionPoint;
  141227. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141228. /**
  141229. * Exposes the properties to the UI?
  141230. */
  141231. protected _dumpPropertiesCode(): string;
  141232. /**
  141233. * Exposes the properties to the Seralize?
  141234. */
  141235. serialize(): any;
  141236. /**
  141237. * Exposes the properties to the deseralize?
  141238. */
  141239. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141240. }
  141241. }
  141242. declare module BABYLON {
  141243. /**
  141244. * block used to Generate a Simplex Perlin 3d Noise Pattern
  141245. */
  141246. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  141247. /**
  141248. * Creates a new SimplexPerlin3DBlock
  141249. * @param name defines the block name
  141250. */
  141251. constructor(name: string);
  141252. /**
  141253. * Gets the current class name
  141254. * @returns the class name
  141255. */
  141256. getClassName(): string;
  141257. /**
  141258. * Gets the seed operand input component
  141259. */
  141260. get seed(): NodeMaterialConnectionPoint;
  141261. /**
  141262. * Gets the output component
  141263. */
  141264. get output(): NodeMaterialConnectionPoint;
  141265. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141266. }
  141267. }
  141268. declare module BABYLON {
  141269. /**
  141270. * Block used to blend normals
  141271. */
  141272. export class NormalBlendBlock extends NodeMaterialBlock {
  141273. /**
  141274. * Creates a new NormalBlendBlock
  141275. * @param name defines the block name
  141276. */
  141277. constructor(name: string);
  141278. /**
  141279. * Gets the current class name
  141280. * @returns the class name
  141281. */
  141282. getClassName(): string;
  141283. /**
  141284. * Gets the first input component
  141285. */
  141286. get normalMap0(): NodeMaterialConnectionPoint;
  141287. /**
  141288. * Gets the second input component
  141289. */
  141290. get normalMap1(): NodeMaterialConnectionPoint;
  141291. /**
  141292. * Gets the output component
  141293. */
  141294. get output(): NodeMaterialConnectionPoint;
  141295. protected _buildBlock(state: NodeMaterialBuildState): this;
  141296. }
  141297. }
  141298. declare module BABYLON {
  141299. /**
  141300. * Block used to rotate a 2d vector by a given angle
  141301. */
  141302. export class Rotate2dBlock extends NodeMaterialBlock {
  141303. /**
  141304. * Creates a new Rotate2dBlock
  141305. * @param name defines the block name
  141306. */
  141307. constructor(name: string);
  141308. /**
  141309. * Gets the current class name
  141310. * @returns the class name
  141311. */
  141312. getClassName(): string;
  141313. /**
  141314. * Gets the input vector
  141315. */
  141316. get input(): NodeMaterialConnectionPoint;
  141317. /**
  141318. * Gets the input angle
  141319. */
  141320. get angle(): NodeMaterialConnectionPoint;
  141321. /**
  141322. * Gets the output component
  141323. */
  141324. get output(): NodeMaterialConnectionPoint;
  141325. autoConfigure(material: NodeMaterial): void;
  141326. protected _buildBlock(state: NodeMaterialBuildState): this;
  141327. }
  141328. }
  141329. declare module BABYLON {
  141330. /**
  141331. * Block used to get the reflected vector from a direction and a normal
  141332. */
  141333. export class ReflectBlock extends NodeMaterialBlock {
  141334. /**
  141335. * Creates a new ReflectBlock
  141336. * @param name defines the block name
  141337. */
  141338. constructor(name: string);
  141339. /**
  141340. * Gets the current class name
  141341. * @returns the class name
  141342. */
  141343. getClassName(): string;
  141344. /**
  141345. * Gets the incident component
  141346. */
  141347. get incident(): NodeMaterialConnectionPoint;
  141348. /**
  141349. * Gets the normal component
  141350. */
  141351. get normal(): NodeMaterialConnectionPoint;
  141352. /**
  141353. * Gets the output component
  141354. */
  141355. get output(): NodeMaterialConnectionPoint;
  141356. protected _buildBlock(state: NodeMaterialBuildState): this;
  141357. }
  141358. }
  141359. declare module BABYLON {
  141360. /**
  141361. * Block used to get the refracted vector from a direction and a normal
  141362. */
  141363. export class RefractBlock extends NodeMaterialBlock {
  141364. /**
  141365. * Creates a new RefractBlock
  141366. * @param name defines the block name
  141367. */
  141368. constructor(name: string);
  141369. /**
  141370. * Gets the current class name
  141371. * @returns the class name
  141372. */
  141373. getClassName(): string;
  141374. /**
  141375. * Gets the incident component
  141376. */
  141377. get incident(): NodeMaterialConnectionPoint;
  141378. /**
  141379. * Gets the normal component
  141380. */
  141381. get normal(): NodeMaterialConnectionPoint;
  141382. /**
  141383. * Gets the index of refraction component
  141384. */
  141385. get ior(): NodeMaterialConnectionPoint;
  141386. /**
  141387. * Gets the output component
  141388. */
  141389. get output(): NodeMaterialConnectionPoint;
  141390. protected _buildBlock(state: NodeMaterialBuildState): this;
  141391. }
  141392. }
  141393. declare module BABYLON {
  141394. /**
  141395. * Block used to desaturate a color
  141396. */
  141397. export class DesaturateBlock extends NodeMaterialBlock {
  141398. /**
  141399. * Creates a new DesaturateBlock
  141400. * @param name defines the block name
  141401. */
  141402. constructor(name: string);
  141403. /**
  141404. * Gets the current class name
  141405. * @returns the class name
  141406. */
  141407. getClassName(): string;
  141408. /**
  141409. * Gets the color operand input component
  141410. */
  141411. get color(): NodeMaterialConnectionPoint;
  141412. /**
  141413. * Gets the level operand input component
  141414. */
  141415. get level(): NodeMaterialConnectionPoint;
  141416. /**
  141417. * Gets the output component
  141418. */
  141419. get output(): NodeMaterialConnectionPoint;
  141420. protected _buildBlock(state: NodeMaterialBuildState): this;
  141421. }
  141422. }
  141423. declare module BABYLON {
  141424. /**
  141425. * Block used to implement the ambient occlusion module of the PBR material
  141426. */
  141427. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  141428. /**
  141429. * Create a new AmbientOcclusionBlock
  141430. * @param name defines the block name
  141431. */
  141432. constructor(name: string);
  141433. /**
  141434. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  141435. */
  141436. useAmbientInGrayScale: boolean;
  141437. /**
  141438. * Initialize the block and prepare the context for build
  141439. * @param state defines the state that will be used for the build
  141440. */
  141441. initialize(state: NodeMaterialBuildState): void;
  141442. /**
  141443. * Gets the current class name
  141444. * @returns the class name
  141445. */
  141446. getClassName(): string;
  141447. /**
  141448. * Gets the texture input component
  141449. */
  141450. get texture(): NodeMaterialConnectionPoint;
  141451. /**
  141452. * Gets the texture intensity component
  141453. */
  141454. get intensity(): NodeMaterialConnectionPoint;
  141455. /**
  141456. * Gets the direct light intensity input component
  141457. */
  141458. get directLightIntensity(): NodeMaterialConnectionPoint;
  141459. /**
  141460. * Gets the ambient occlusion object output component
  141461. */
  141462. get ambientOcclusion(): NodeMaterialConnectionPoint;
  141463. /**
  141464. * Gets the main code of the block (fragment side)
  141465. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  141466. * @returns the shader code
  141467. */
  141468. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  141469. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141470. protected _buildBlock(state: NodeMaterialBuildState): this;
  141471. protected _dumpPropertiesCode(): string;
  141472. serialize(): any;
  141473. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141474. }
  141475. }
  141476. declare module BABYLON {
  141477. /**
  141478. * Block used to implement the reflection module of the PBR material
  141479. */
  141480. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  141481. /** @hidden */
  141482. _defineLODReflectionAlpha: string;
  141483. /** @hidden */
  141484. _defineLinearSpecularReflection: string;
  141485. private _vEnvironmentIrradianceName;
  141486. /** @hidden */
  141487. _vReflectionMicrosurfaceInfosName: string;
  141488. /** @hidden */
  141489. _vReflectionInfosName: string;
  141490. /** @hidden */
  141491. _vReflectionFilteringInfoName: string;
  141492. private _scene;
  141493. /**
  141494. * The three properties below are set by the main PBR block prior to calling methods of this class.
  141495. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141496. * It's less burden on the user side in the editor part.
  141497. */
  141498. /** @hidden */
  141499. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141500. /** @hidden */
  141501. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141502. /** @hidden */
  141503. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  141504. /**
  141505. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  141506. * diffuse part of the IBL.
  141507. */
  141508. useSphericalHarmonics: boolean;
  141509. /**
  141510. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  141511. */
  141512. forceIrradianceInFragment: boolean;
  141513. /**
  141514. * Create a new ReflectionBlock
  141515. * @param name defines the block name
  141516. */
  141517. constructor(name: string);
  141518. /**
  141519. * Gets the current class name
  141520. * @returns the class name
  141521. */
  141522. getClassName(): string;
  141523. /**
  141524. * Gets the position input component
  141525. */
  141526. get position(): NodeMaterialConnectionPoint;
  141527. /**
  141528. * Gets the world position input component
  141529. */
  141530. get worldPosition(): NodeMaterialConnectionPoint;
  141531. /**
  141532. * Gets the world normal input component
  141533. */
  141534. get worldNormal(): NodeMaterialConnectionPoint;
  141535. /**
  141536. * Gets the world input component
  141537. */
  141538. get world(): NodeMaterialConnectionPoint;
  141539. /**
  141540. * Gets the camera (or eye) position component
  141541. */
  141542. get cameraPosition(): NodeMaterialConnectionPoint;
  141543. /**
  141544. * Gets the view input component
  141545. */
  141546. get view(): NodeMaterialConnectionPoint;
  141547. /**
  141548. * Gets the color input component
  141549. */
  141550. get color(): NodeMaterialConnectionPoint;
  141551. /**
  141552. * Gets the reflection object output component
  141553. */
  141554. get reflection(): NodeMaterialConnectionPoint;
  141555. /**
  141556. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  141557. */
  141558. get hasTexture(): boolean;
  141559. /**
  141560. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  141561. */
  141562. get reflectionColor(): string;
  141563. protected _getTexture(): Nullable<BaseTexture>;
  141564. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141565. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141566. /**
  141567. * Gets the code to inject in the vertex shader
  141568. * @param state current state of the node material building
  141569. * @returns the shader code
  141570. */
  141571. handleVertexSide(state: NodeMaterialBuildState): string;
  141572. /**
  141573. * Gets the main code of the block (fragment side)
  141574. * @param state current state of the node material building
  141575. * @param normalVarName name of the existing variable corresponding to the normal
  141576. * @returns the shader code
  141577. */
  141578. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  141579. protected _buildBlock(state: NodeMaterialBuildState): this;
  141580. protected _dumpPropertiesCode(): string;
  141581. serialize(): any;
  141582. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141583. }
  141584. }
  141585. declare module BABYLON {
  141586. /**
  141587. * Block used to implement the sheen module of the PBR material
  141588. */
  141589. export class SheenBlock extends NodeMaterialBlock {
  141590. /**
  141591. * Create a new SheenBlock
  141592. * @param name defines the block name
  141593. */
  141594. constructor(name: string);
  141595. /**
  141596. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  141597. * It allows the strength of the sheen effect to not depend on the base color of the material,
  141598. * making it easier to setup and tweak the effect
  141599. */
  141600. albedoScaling: boolean;
  141601. /**
  141602. * Defines if the sheen is linked to the sheen color.
  141603. */
  141604. linkSheenWithAlbedo: boolean;
  141605. /**
  141606. * Initialize the block and prepare the context for build
  141607. * @param state defines the state that will be used for the build
  141608. */
  141609. initialize(state: NodeMaterialBuildState): void;
  141610. /**
  141611. * Gets the current class name
  141612. * @returns the class name
  141613. */
  141614. getClassName(): string;
  141615. /**
  141616. * Gets the intensity input component
  141617. */
  141618. get intensity(): NodeMaterialConnectionPoint;
  141619. /**
  141620. * Gets the color input component
  141621. */
  141622. get color(): NodeMaterialConnectionPoint;
  141623. /**
  141624. * Gets the roughness input component
  141625. */
  141626. get roughness(): NodeMaterialConnectionPoint;
  141627. /**
  141628. * Gets the sheen object output component
  141629. */
  141630. get sheen(): NodeMaterialConnectionPoint;
  141631. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141632. /**
  141633. * Gets the main code of the block (fragment side)
  141634. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141635. * @returns the shader code
  141636. */
  141637. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  141638. protected _buildBlock(state: NodeMaterialBuildState): this;
  141639. protected _dumpPropertiesCode(): string;
  141640. serialize(): any;
  141641. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141642. }
  141643. }
  141644. declare module BABYLON {
  141645. /**
  141646. * Block used to implement the reflectivity module of the PBR material
  141647. */
  141648. export class ReflectivityBlock extends NodeMaterialBlock {
  141649. private _metallicReflectanceColor;
  141650. private _metallicF0Factor;
  141651. /** @hidden */
  141652. _vMetallicReflectanceFactorsName: string;
  141653. /**
  141654. * The property below is set by the main PBR block prior to calling methods of this class.
  141655. */
  141656. /** @hidden */
  141657. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  141658. /**
  141659. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  141660. */
  141661. useAmbientOcclusionFromMetallicTextureRed: boolean;
  141662. /**
  141663. * Specifies if the metallic texture contains the metallness information in its blue channel.
  141664. */
  141665. useMetallnessFromMetallicTextureBlue: boolean;
  141666. /**
  141667. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  141668. */
  141669. useRoughnessFromMetallicTextureAlpha: boolean;
  141670. /**
  141671. * Specifies if the metallic texture contains the roughness information in its green channel.
  141672. */
  141673. useRoughnessFromMetallicTextureGreen: boolean;
  141674. /**
  141675. * Create a new ReflectivityBlock
  141676. * @param name defines the block name
  141677. */
  141678. constructor(name: string);
  141679. /**
  141680. * Initialize the block and prepare the context for build
  141681. * @param state defines the state that will be used for the build
  141682. */
  141683. initialize(state: NodeMaterialBuildState): void;
  141684. /**
  141685. * Gets the current class name
  141686. * @returns the class name
  141687. */
  141688. getClassName(): string;
  141689. /**
  141690. * Gets the metallic input component
  141691. */
  141692. get metallic(): NodeMaterialConnectionPoint;
  141693. /**
  141694. * Gets the roughness input component
  141695. */
  141696. get roughness(): NodeMaterialConnectionPoint;
  141697. /**
  141698. * Gets the texture input component
  141699. */
  141700. get texture(): NodeMaterialConnectionPoint;
  141701. /**
  141702. * Gets the reflectivity object output component
  141703. */
  141704. get reflectivity(): NodeMaterialConnectionPoint;
  141705. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141706. /**
  141707. * Gets the main code of the block (fragment side)
  141708. * @param state current state of the node material building
  141709. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  141710. * @returns the shader code
  141711. */
  141712. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  141713. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141714. protected _buildBlock(state: NodeMaterialBuildState): this;
  141715. protected _dumpPropertiesCode(): string;
  141716. serialize(): any;
  141717. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141718. }
  141719. }
  141720. declare module BABYLON {
  141721. /**
  141722. * Block used to implement the anisotropy module of the PBR material
  141723. */
  141724. export class AnisotropyBlock extends NodeMaterialBlock {
  141725. /**
  141726. * The two properties below are set by the main PBR block prior to calling methods of this class.
  141727. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141728. * It's less burden on the user side in the editor part.
  141729. */
  141730. /** @hidden */
  141731. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141732. /** @hidden */
  141733. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141734. /**
  141735. * Create a new AnisotropyBlock
  141736. * @param name defines the block name
  141737. */
  141738. constructor(name: string);
  141739. /**
  141740. * Initialize the block and prepare the context for build
  141741. * @param state defines the state that will be used for the build
  141742. */
  141743. initialize(state: NodeMaterialBuildState): void;
  141744. /**
  141745. * Gets the current class name
  141746. * @returns the class name
  141747. */
  141748. getClassName(): string;
  141749. /**
  141750. * Gets the intensity input component
  141751. */
  141752. get intensity(): NodeMaterialConnectionPoint;
  141753. /**
  141754. * Gets the direction input component
  141755. */
  141756. get direction(): NodeMaterialConnectionPoint;
  141757. /**
  141758. * Gets the texture input component
  141759. */
  141760. get texture(): NodeMaterialConnectionPoint;
  141761. /**
  141762. * Gets the uv input component
  141763. */
  141764. get uv(): NodeMaterialConnectionPoint;
  141765. /**
  141766. * Gets the worldTangent input component
  141767. */
  141768. get worldTangent(): NodeMaterialConnectionPoint;
  141769. /**
  141770. * Gets the anisotropy object output component
  141771. */
  141772. get anisotropy(): NodeMaterialConnectionPoint;
  141773. private _generateTBNSpace;
  141774. /**
  141775. * Gets the main code of the block (fragment side)
  141776. * @param state current state of the node material building
  141777. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141778. * @returns the shader code
  141779. */
  141780. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  141781. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141782. protected _buildBlock(state: NodeMaterialBuildState): this;
  141783. }
  141784. }
  141785. declare module BABYLON {
  141786. /**
  141787. * Block used to implement the clear coat module of the PBR material
  141788. */
  141789. export class ClearCoatBlock extends NodeMaterialBlock {
  141790. private _scene;
  141791. /**
  141792. * Create a new ClearCoatBlock
  141793. * @param name defines the block name
  141794. */
  141795. constructor(name: string);
  141796. /**
  141797. * Initialize the block and prepare the context for build
  141798. * @param state defines the state that will be used for the build
  141799. */
  141800. initialize(state: NodeMaterialBuildState): void;
  141801. /**
  141802. * Gets the current class name
  141803. * @returns the class name
  141804. */
  141805. getClassName(): string;
  141806. /**
  141807. * Gets the intensity input component
  141808. */
  141809. get intensity(): NodeMaterialConnectionPoint;
  141810. /**
  141811. * Gets the roughness input component
  141812. */
  141813. get roughness(): NodeMaterialConnectionPoint;
  141814. /**
  141815. * Gets the ior input component
  141816. */
  141817. get ior(): NodeMaterialConnectionPoint;
  141818. /**
  141819. * Gets the texture input component
  141820. */
  141821. get texture(): NodeMaterialConnectionPoint;
  141822. /**
  141823. * Gets the bump texture input component
  141824. */
  141825. get bumpTexture(): NodeMaterialConnectionPoint;
  141826. /**
  141827. * Gets the uv input component
  141828. */
  141829. get uv(): NodeMaterialConnectionPoint;
  141830. /**
  141831. * Gets the tint color input component
  141832. */
  141833. get tintColor(): NodeMaterialConnectionPoint;
  141834. /**
  141835. * Gets the tint "at distance" input component
  141836. */
  141837. get tintAtDistance(): NodeMaterialConnectionPoint;
  141838. /**
  141839. * Gets the tint thickness input component
  141840. */
  141841. get tintThickness(): NodeMaterialConnectionPoint;
  141842. /**
  141843. * Gets the world tangent input component
  141844. */
  141845. get worldTangent(): NodeMaterialConnectionPoint;
  141846. /**
  141847. * Gets the clear coat object output component
  141848. */
  141849. get clearcoat(): NodeMaterialConnectionPoint;
  141850. autoConfigure(material: NodeMaterial): void;
  141851. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141852. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141853. private _generateTBNSpace;
  141854. /**
  141855. * Gets the main code of the block (fragment side)
  141856. * @param state current state of the node material building
  141857. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  141858. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141859. * @param worldPosVarName name of the variable holding the world position
  141860. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141861. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  141862. * @param worldNormalVarName name of the variable holding the world normal
  141863. * @returns the shader code
  141864. */
  141865. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  141866. protected _buildBlock(state: NodeMaterialBuildState): this;
  141867. }
  141868. }
  141869. declare module BABYLON {
  141870. /**
  141871. * Block used to implement the sub surface module of the PBR material
  141872. */
  141873. export class SubSurfaceBlock extends NodeMaterialBlock {
  141874. /**
  141875. * Create a new SubSurfaceBlock
  141876. * @param name defines the block name
  141877. */
  141878. constructor(name: string);
  141879. /**
  141880. * Stores the intensity of the different subsurface effects in the thickness texture.
  141881. * * the green channel is the translucency intensity.
  141882. * * the blue channel is the scattering intensity.
  141883. * * the alpha channel is the refraction intensity.
  141884. */
  141885. useMaskFromThicknessTexture: boolean;
  141886. /**
  141887. * Initialize the block and prepare the context for build
  141888. * @param state defines the state that will be used for the build
  141889. */
  141890. initialize(state: NodeMaterialBuildState): void;
  141891. /**
  141892. * Gets the current class name
  141893. * @returns the class name
  141894. */
  141895. getClassName(): string;
  141896. /**
  141897. * Gets the min thickness input component
  141898. */
  141899. get minThickness(): NodeMaterialConnectionPoint;
  141900. /**
  141901. * Gets the max thickness input component
  141902. */
  141903. get maxThickness(): NodeMaterialConnectionPoint;
  141904. /**
  141905. * Gets the thickness texture component
  141906. */
  141907. get thicknessTexture(): NodeMaterialConnectionPoint;
  141908. /**
  141909. * Gets the tint color input component
  141910. */
  141911. get tintColor(): NodeMaterialConnectionPoint;
  141912. /**
  141913. * Gets the translucency intensity input component
  141914. */
  141915. get translucencyIntensity(): NodeMaterialConnectionPoint;
  141916. /**
  141917. * Gets the translucency diffusion distance input component
  141918. */
  141919. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  141920. /**
  141921. * Gets the refraction object parameters
  141922. */
  141923. get refraction(): NodeMaterialConnectionPoint;
  141924. /**
  141925. * Gets the sub surface object output component
  141926. */
  141927. get subsurface(): NodeMaterialConnectionPoint;
  141928. autoConfigure(material: NodeMaterial): void;
  141929. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141930. /**
  141931. * Gets the main code of the block (fragment side)
  141932. * @param state current state of the node material building
  141933. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  141934. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141935. * @param worldPosVarName name of the variable holding the world position
  141936. * @returns the shader code
  141937. */
  141938. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  141939. protected _buildBlock(state: NodeMaterialBuildState): this;
  141940. }
  141941. }
  141942. declare module BABYLON {
  141943. /**
  141944. * Block used to implement the PBR metallic/roughness model
  141945. */
  141946. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  141947. /**
  141948. * Gets or sets the light associated with this block
  141949. */
  141950. light: Nullable<Light>;
  141951. private _lightId;
  141952. private _scene;
  141953. private _environmentBRDFTexture;
  141954. private _environmentBrdfSamplerName;
  141955. private _vNormalWName;
  141956. private _invertNormalName;
  141957. /**
  141958. * Create a new ReflectionBlock
  141959. * @param name defines the block name
  141960. */
  141961. constructor(name: string);
  141962. /**
  141963. * Intensity of the direct lights e.g. the four lights available in your scene.
  141964. * This impacts both the direct diffuse and specular highlights.
  141965. */
  141966. directIntensity: number;
  141967. /**
  141968. * Intensity of the environment e.g. how much the environment will light the object
  141969. * either through harmonics for rough material or through the refelction for shiny ones.
  141970. */
  141971. environmentIntensity: number;
  141972. /**
  141973. * This is a special control allowing the reduction of the specular highlights coming from the
  141974. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  141975. */
  141976. specularIntensity: number;
  141977. /**
  141978. * Defines the falloff type used in this material.
  141979. * It by default is Physical.
  141980. */
  141981. lightFalloff: number;
  141982. /**
  141983. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  141984. */
  141985. useAlphaFromAlbedoTexture: boolean;
  141986. /**
  141987. * Specifies that alpha test should be used
  141988. */
  141989. useAlphaTest: boolean;
  141990. /**
  141991. * Defines the alpha limits in alpha test mode.
  141992. */
  141993. alphaTestCutoff: number;
  141994. /**
  141995. * Specifies that alpha blending should be used
  141996. */
  141997. useAlphaBlending: boolean;
  141998. /**
  141999. * Defines if the alpha value should be determined via the rgb values.
  142000. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  142001. */
  142002. opacityRGB: boolean;
  142003. /**
  142004. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  142005. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  142006. */
  142007. useRadianceOverAlpha: boolean;
  142008. /**
  142009. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  142010. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  142011. */
  142012. useSpecularOverAlpha: boolean;
  142013. /**
  142014. * Enables specular anti aliasing in the PBR shader.
  142015. * It will both interacts on the Geometry for analytical and IBL lighting.
  142016. * It also prefilter the roughness map based on the bump values.
  142017. */
  142018. enableSpecularAntiAliasing: boolean;
  142019. /**
  142020. * Enables realtime filtering on the texture.
  142021. */
  142022. realTimeFiltering: boolean;
  142023. /**
  142024. * Quality switch for realtime filtering
  142025. */
  142026. realTimeFilteringQuality: number;
  142027. /**
  142028. * Defines if the material uses energy conservation.
  142029. */
  142030. useEnergyConservation: boolean;
  142031. /**
  142032. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  142033. * too much the area relying on ambient texture to define their ambient occlusion.
  142034. */
  142035. useRadianceOcclusion: boolean;
  142036. /**
  142037. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  142038. * makes the reflect vector face the model (under horizon).
  142039. */
  142040. useHorizonOcclusion: boolean;
  142041. /**
  142042. * If set to true, no lighting calculations will be applied.
  142043. */
  142044. unlit: boolean;
  142045. /**
  142046. * Force normal to face away from face.
  142047. */
  142048. forceNormalForward: boolean;
  142049. /**
  142050. * Defines the material debug mode.
  142051. * It helps seeing only some components of the material while troubleshooting.
  142052. */
  142053. debugMode: number;
  142054. /**
  142055. * Specify from where on screen the debug mode should start.
  142056. * The value goes from -1 (full screen) to 1 (not visible)
  142057. * It helps with side by side comparison against the final render
  142058. * This defaults to 0
  142059. */
  142060. debugLimit: number;
  142061. /**
  142062. * As the default viewing range might not be enough (if the ambient is really small for instance)
  142063. * You can use the factor to better multiply the final value.
  142064. */
  142065. debugFactor: number;
  142066. /**
  142067. * Initialize the block and prepare the context for build
  142068. * @param state defines the state that will be used for the build
  142069. */
  142070. initialize(state: NodeMaterialBuildState): void;
  142071. /**
  142072. * Gets the current class name
  142073. * @returns the class name
  142074. */
  142075. getClassName(): string;
  142076. /**
  142077. * Gets the world position input component
  142078. */
  142079. get worldPosition(): NodeMaterialConnectionPoint;
  142080. /**
  142081. * Gets the world normal input component
  142082. */
  142083. get worldNormal(): NodeMaterialConnectionPoint;
  142084. /**
  142085. * Gets the perturbed normal input component
  142086. */
  142087. get perturbedNormal(): NodeMaterialConnectionPoint;
  142088. /**
  142089. * Gets the camera position input component
  142090. */
  142091. get cameraPosition(): NodeMaterialConnectionPoint;
  142092. /**
  142093. * Gets the base color input component
  142094. */
  142095. get baseColor(): NodeMaterialConnectionPoint;
  142096. /**
  142097. * Gets the opacity texture input component
  142098. */
  142099. get opacityTexture(): NodeMaterialConnectionPoint;
  142100. /**
  142101. * Gets the ambient color input component
  142102. */
  142103. get ambientColor(): NodeMaterialConnectionPoint;
  142104. /**
  142105. * Gets the reflectivity object parameters
  142106. */
  142107. get reflectivity(): NodeMaterialConnectionPoint;
  142108. /**
  142109. * Gets the ambient occlusion object parameters
  142110. */
  142111. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142112. /**
  142113. * Gets the reflection object parameters
  142114. */
  142115. get reflection(): NodeMaterialConnectionPoint;
  142116. /**
  142117. * Gets the sheen object parameters
  142118. */
  142119. get sheen(): NodeMaterialConnectionPoint;
  142120. /**
  142121. * Gets the clear coat object parameters
  142122. */
  142123. get clearcoat(): NodeMaterialConnectionPoint;
  142124. /**
  142125. * Gets the sub surface object parameters
  142126. */
  142127. get subsurface(): NodeMaterialConnectionPoint;
  142128. /**
  142129. * Gets the anisotropy object parameters
  142130. */
  142131. get anisotropy(): NodeMaterialConnectionPoint;
  142132. /**
  142133. * Gets the ambient output component
  142134. */
  142135. get ambient(): NodeMaterialConnectionPoint;
  142136. /**
  142137. * Gets the diffuse output component
  142138. */
  142139. get diffuse(): NodeMaterialConnectionPoint;
  142140. /**
  142141. * Gets the specular output component
  142142. */
  142143. get specular(): NodeMaterialConnectionPoint;
  142144. /**
  142145. * Gets the sheen output component
  142146. */
  142147. get sheenDir(): NodeMaterialConnectionPoint;
  142148. /**
  142149. * Gets the clear coat output component
  142150. */
  142151. get clearcoatDir(): NodeMaterialConnectionPoint;
  142152. /**
  142153. * Gets the indirect diffuse output component
  142154. */
  142155. get diffuseIndirect(): NodeMaterialConnectionPoint;
  142156. /**
  142157. * Gets the indirect specular output component
  142158. */
  142159. get specularIndirect(): NodeMaterialConnectionPoint;
  142160. /**
  142161. * Gets the indirect sheen output component
  142162. */
  142163. get sheenIndirect(): NodeMaterialConnectionPoint;
  142164. /**
  142165. * Gets the indirect clear coat output component
  142166. */
  142167. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  142168. /**
  142169. * Gets the refraction output component
  142170. */
  142171. get refraction(): NodeMaterialConnectionPoint;
  142172. /**
  142173. * Gets the global lighting output component
  142174. */
  142175. get lighting(): NodeMaterialConnectionPoint;
  142176. /**
  142177. * Gets the shadow output component
  142178. */
  142179. get shadow(): NodeMaterialConnectionPoint;
  142180. /**
  142181. * Gets the alpha output component
  142182. */
  142183. get alpha(): NodeMaterialConnectionPoint;
  142184. autoConfigure(material: NodeMaterial): void;
  142185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142186. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142187. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142188. private _injectVertexCode;
  142189. /**
  142190. * Gets the code corresponding to the albedo/opacity module
  142191. * @returns the shader code
  142192. */
  142193. getAlbedoOpacityCode(): string;
  142194. protected _buildBlock(state: NodeMaterialBuildState): this;
  142195. protected _dumpPropertiesCode(): string;
  142196. serialize(): any;
  142197. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142198. }
  142199. }
  142200. declare module BABYLON {
  142201. /**
  142202. * Block used to compute value of one parameter modulo another
  142203. */
  142204. export class ModBlock extends NodeMaterialBlock {
  142205. /**
  142206. * Creates a new ModBlock
  142207. * @param name defines the block name
  142208. */
  142209. constructor(name: string);
  142210. /**
  142211. * Gets the current class name
  142212. * @returns the class name
  142213. */
  142214. getClassName(): string;
  142215. /**
  142216. * Gets the left operand input component
  142217. */
  142218. get left(): NodeMaterialConnectionPoint;
  142219. /**
  142220. * Gets the right operand input component
  142221. */
  142222. get right(): NodeMaterialConnectionPoint;
  142223. /**
  142224. * Gets the output component
  142225. */
  142226. get output(): NodeMaterialConnectionPoint;
  142227. protected _buildBlock(state: NodeMaterialBuildState): this;
  142228. }
  142229. }
  142230. declare module BABYLON {
  142231. /**
  142232. * Helper class to push actions to a pool of workers.
  142233. */
  142234. export class WorkerPool implements IDisposable {
  142235. private _workerInfos;
  142236. private _pendingActions;
  142237. /**
  142238. * Constructor
  142239. * @param workers Array of workers to use for actions
  142240. */
  142241. constructor(workers: Array<Worker>);
  142242. /**
  142243. * Terminates all workers and clears any pending actions.
  142244. */
  142245. dispose(): void;
  142246. /**
  142247. * Pushes an action to the worker pool. If all the workers are active, the action will be
  142248. * pended until a worker has completed its action.
  142249. * @param action The action to perform. Call onComplete when the action is complete.
  142250. */
  142251. push(action: (worker: Worker, onComplete: () => void) => void): void;
  142252. private _execute;
  142253. }
  142254. }
  142255. declare module BABYLON {
  142256. /**
  142257. * Configuration for Draco compression
  142258. */
  142259. export interface IDracoCompressionConfiguration {
  142260. /**
  142261. * Configuration for the decoder.
  142262. */
  142263. decoder: {
  142264. /**
  142265. * The url to the WebAssembly module.
  142266. */
  142267. wasmUrl?: string;
  142268. /**
  142269. * The url to the WebAssembly binary.
  142270. */
  142271. wasmBinaryUrl?: string;
  142272. /**
  142273. * The url to the fallback JavaScript module.
  142274. */
  142275. fallbackUrl?: string;
  142276. };
  142277. }
  142278. /**
  142279. * Draco compression (https://google.github.io/draco/)
  142280. *
  142281. * This class wraps the Draco module.
  142282. *
  142283. * **Encoder**
  142284. *
  142285. * The encoder is not currently implemented.
  142286. *
  142287. * **Decoder**
  142288. *
  142289. * 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.
  142290. *
  142291. * To update the configuration, use the following code:
  142292. * ```javascript
  142293. * DracoCompression.Configuration = {
  142294. * decoder: {
  142295. * wasmUrl: "<url to the WebAssembly library>",
  142296. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  142297. * fallbackUrl: "<url to the fallback JavaScript library>",
  142298. * }
  142299. * };
  142300. * ```
  142301. *
  142302. * 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.
  142303. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  142304. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  142305. *
  142306. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  142307. * ```javascript
  142308. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  142309. * ```
  142310. *
  142311. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  142312. */
  142313. export class DracoCompression implements IDisposable {
  142314. private _workerPoolPromise?;
  142315. private _decoderModulePromise?;
  142316. /**
  142317. * The configuration. Defaults to the following urls:
  142318. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  142319. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  142320. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  142321. */
  142322. static Configuration: IDracoCompressionConfiguration;
  142323. /**
  142324. * Returns true if the decoder configuration is available.
  142325. */
  142326. static get DecoderAvailable(): boolean;
  142327. /**
  142328. * Default number of workers to create when creating the draco compression object.
  142329. */
  142330. static DefaultNumWorkers: number;
  142331. private static GetDefaultNumWorkers;
  142332. private static _Default;
  142333. /**
  142334. * Default instance for the draco compression object.
  142335. */
  142336. static get Default(): DracoCompression;
  142337. /**
  142338. * Constructor
  142339. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  142340. */
  142341. constructor(numWorkers?: number);
  142342. /**
  142343. * Stop all async operations and release resources.
  142344. */
  142345. dispose(): void;
  142346. /**
  142347. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  142348. * @returns a promise that resolves when ready
  142349. */
  142350. whenReadyAsync(): Promise<void>;
  142351. /**
  142352. * Decode Draco compressed mesh data to vertex data.
  142353. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  142354. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  142355. * @returns A promise that resolves with the decoded vertex data
  142356. */
  142357. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  142358. [kind: string]: number;
  142359. }): Promise<VertexData>;
  142360. }
  142361. }
  142362. declare module BABYLON {
  142363. /**
  142364. * Class for building Constructive Solid Geometry
  142365. */
  142366. export class CSG {
  142367. private polygons;
  142368. /**
  142369. * The world matrix
  142370. */
  142371. matrix: Matrix;
  142372. /**
  142373. * Stores the position
  142374. */
  142375. position: Vector3;
  142376. /**
  142377. * Stores the rotation
  142378. */
  142379. rotation: Vector3;
  142380. /**
  142381. * Stores the rotation quaternion
  142382. */
  142383. rotationQuaternion: Nullable<Quaternion>;
  142384. /**
  142385. * Stores the scaling vector
  142386. */
  142387. scaling: Vector3;
  142388. /**
  142389. * Convert the Mesh to CSG
  142390. * @param mesh The Mesh to convert to CSG
  142391. * @returns A new CSG from the Mesh
  142392. */
  142393. static FromMesh(mesh: Mesh): CSG;
  142394. /**
  142395. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  142396. * @param polygons Polygons used to construct a CSG solid
  142397. */
  142398. private static FromPolygons;
  142399. /**
  142400. * Clones, or makes a deep copy, of the CSG
  142401. * @returns A new CSG
  142402. */
  142403. clone(): CSG;
  142404. /**
  142405. * Unions this CSG with another CSG
  142406. * @param csg The CSG to union against this CSG
  142407. * @returns The unioned CSG
  142408. */
  142409. union(csg: CSG): CSG;
  142410. /**
  142411. * Unions this CSG with another CSG in place
  142412. * @param csg The CSG to union against this CSG
  142413. */
  142414. unionInPlace(csg: CSG): void;
  142415. /**
  142416. * Subtracts this CSG with another CSG
  142417. * @param csg The CSG to subtract against this CSG
  142418. * @returns A new CSG
  142419. */
  142420. subtract(csg: CSG): CSG;
  142421. /**
  142422. * Subtracts this CSG with another CSG in place
  142423. * @param csg The CSG to subtact against this CSG
  142424. */
  142425. subtractInPlace(csg: CSG): void;
  142426. /**
  142427. * Intersect this CSG with another CSG
  142428. * @param csg The CSG to intersect against this CSG
  142429. * @returns A new CSG
  142430. */
  142431. intersect(csg: CSG): CSG;
  142432. /**
  142433. * Intersects this CSG with another CSG in place
  142434. * @param csg The CSG to intersect against this CSG
  142435. */
  142436. intersectInPlace(csg: CSG): void;
  142437. /**
  142438. * Return a new CSG solid with solid and empty space switched. This solid is
  142439. * not modified.
  142440. * @returns A new CSG solid with solid and empty space switched
  142441. */
  142442. inverse(): CSG;
  142443. /**
  142444. * Inverses the CSG in place
  142445. */
  142446. inverseInPlace(): void;
  142447. /**
  142448. * This is used to keep meshes transformations so they can be restored
  142449. * when we build back a Babylon Mesh
  142450. * NB : All CSG operations are performed in world coordinates
  142451. * @param csg The CSG to copy the transform attributes from
  142452. * @returns This CSG
  142453. */
  142454. copyTransformAttributes(csg: CSG): CSG;
  142455. /**
  142456. * Build Raw mesh from CSG
  142457. * Coordinates here are in world space
  142458. * @param name The name of the mesh geometry
  142459. * @param scene The Scene
  142460. * @param keepSubMeshes Specifies if the submeshes should be kept
  142461. * @returns A new Mesh
  142462. */
  142463. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142464. /**
  142465. * Build Mesh from CSG taking material and transforms into account
  142466. * @param name The name of the Mesh
  142467. * @param material The material of the Mesh
  142468. * @param scene The Scene
  142469. * @param keepSubMeshes Specifies if submeshes should be kept
  142470. * @returns The new Mesh
  142471. */
  142472. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142473. }
  142474. }
  142475. declare module BABYLON {
  142476. /**
  142477. * Class used to create a trail following a mesh
  142478. */
  142479. export class TrailMesh extends Mesh {
  142480. private _generator;
  142481. private _autoStart;
  142482. private _running;
  142483. private _diameter;
  142484. private _length;
  142485. private _sectionPolygonPointsCount;
  142486. private _sectionVectors;
  142487. private _sectionNormalVectors;
  142488. private _beforeRenderObserver;
  142489. /**
  142490. * @constructor
  142491. * @param name The value used by scene.getMeshByName() to do a lookup.
  142492. * @param generator The mesh or transform node to generate a trail.
  142493. * @param scene The scene to add this mesh to.
  142494. * @param diameter Diameter of trailing mesh. Default is 1.
  142495. * @param length Length of trailing mesh. Default is 60.
  142496. * @param autoStart Automatically start trailing mesh. Default true.
  142497. */
  142498. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  142499. /**
  142500. * "TrailMesh"
  142501. * @returns "TrailMesh"
  142502. */
  142503. getClassName(): string;
  142504. private _createMesh;
  142505. /**
  142506. * Start trailing mesh.
  142507. */
  142508. start(): void;
  142509. /**
  142510. * Stop trailing mesh.
  142511. */
  142512. stop(): void;
  142513. /**
  142514. * Update trailing mesh geometry.
  142515. */
  142516. update(): void;
  142517. /**
  142518. * Returns a new TrailMesh object.
  142519. * @param name is a string, the name given to the new mesh
  142520. * @param newGenerator use new generator object for cloned trail mesh
  142521. * @returns a new mesh
  142522. */
  142523. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  142524. /**
  142525. * Serializes this trail mesh
  142526. * @param serializationObject object to write serialization to
  142527. */
  142528. serialize(serializationObject: any): void;
  142529. /**
  142530. * Parses a serialized trail mesh
  142531. * @param parsedMesh the serialized mesh
  142532. * @param scene the scene to create the trail mesh in
  142533. * @returns the created trail mesh
  142534. */
  142535. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  142536. }
  142537. }
  142538. declare module BABYLON {
  142539. /**
  142540. * Class containing static functions to help procedurally build meshes
  142541. */
  142542. export class TiledBoxBuilder {
  142543. /**
  142544. * Creates a box mesh
  142545. * 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)
  142546. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142548. * * 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
  142549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142550. * @param name defines the name of the mesh
  142551. * @param options defines the options used to create the mesh
  142552. * @param scene defines the hosting scene
  142553. * @returns the box mesh
  142554. */
  142555. static CreateTiledBox(name: string, options: {
  142556. pattern?: number;
  142557. width?: number;
  142558. height?: number;
  142559. depth?: number;
  142560. tileSize?: number;
  142561. tileWidth?: number;
  142562. tileHeight?: number;
  142563. alignHorizontal?: number;
  142564. alignVertical?: number;
  142565. faceUV?: Vector4[];
  142566. faceColors?: Color4[];
  142567. sideOrientation?: number;
  142568. updatable?: boolean;
  142569. }, scene?: Nullable<Scene>): Mesh;
  142570. }
  142571. }
  142572. declare module BABYLON {
  142573. /**
  142574. * Class containing static functions to help procedurally build meshes
  142575. */
  142576. export class TorusKnotBuilder {
  142577. /**
  142578. * Creates a torus knot mesh
  142579. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  142580. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  142581. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  142582. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  142583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142584. * * 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
  142585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142586. * @param name defines the name of the mesh
  142587. * @param options defines the options used to create the mesh
  142588. * @param scene defines the hosting scene
  142589. * @returns the torus knot mesh
  142590. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  142591. */
  142592. static CreateTorusKnot(name: string, options: {
  142593. radius?: number;
  142594. tube?: number;
  142595. radialSegments?: number;
  142596. tubularSegments?: number;
  142597. p?: number;
  142598. q?: number;
  142599. updatable?: boolean;
  142600. sideOrientation?: number;
  142601. frontUVs?: Vector4;
  142602. backUVs?: Vector4;
  142603. }, scene: any): Mesh;
  142604. }
  142605. }
  142606. declare module BABYLON {
  142607. /**
  142608. * Polygon
  142609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  142610. */
  142611. export class Polygon {
  142612. /**
  142613. * Creates a rectangle
  142614. * @param xmin bottom X coord
  142615. * @param ymin bottom Y coord
  142616. * @param xmax top X coord
  142617. * @param ymax top Y coord
  142618. * @returns points that make the resulting rectation
  142619. */
  142620. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  142621. /**
  142622. * Creates a circle
  142623. * @param radius radius of circle
  142624. * @param cx scale in x
  142625. * @param cy scale in y
  142626. * @param numberOfSides number of sides that make up the circle
  142627. * @returns points that make the resulting circle
  142628. */
  142629. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  142630. /**
  142631. * Creates a polygon from input string
  142632. * @param input Input polygon data
  142633. * @returns the parsed points
  142634. */
  142635. static Parse(input: string): Vector2[];
  142636. /**
  142637. * Starts building a polygon from x and y coordinates
  142638. * @param x x coordinate
  142639. * @param y y coordinate
  142640. * @returns the started path2
  142641. */
  142642. static StartingAt(x: number, y: number): Path2;
  142643. }
  142644. /**
  142645. * Builds a polygon
  142646. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  142647. */
  142648. export class PolygonMeshBuilder {
  142649. private _points;
  142650. private _outlinepoints;
  142651. private _holes;
  142652. private _name;
  142653. private _scene;
  142654. private _epoints;
  142655. private _eholes;
  142656. private _addToepoint;
  142657. /**
  142658. * Babylon reference to the earcut plugin.
  142659. */
  142660. bjsEarcut: any;
  142661. /**
  142662. * Creates a PolygonMeshBuilder
  142663. * @param name name of the builder
  142664. * @param contours Path of the polygon
  142665. * @param scene scene to add to when creating the mesh
  142666. * @param earcutInjection can be used to inject your own earcut reference
  142667. */
  142668. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  142669. /**
  142670. * Adds a whole within the polygon
  142671. * @param hole Array of points defining the hole
  142672. * @returns this
  142673. */
  142674. addHole(hole: Vector2[]): PolygonMeshBuilder;
  142675. /**
  142676. * Creates the polygon
  142677. * @param updatable If the mesh should be updatable
  142678. * @param depth The depth of the mesh created
  142679. * @returns the created mesh
  142680. */
  142681. build(updatable?: boolean, depth?: number): Mesh;
  142682. /**
  142683. * Creates the polygon
  142684. * @param depth The depth of the mesh created
  142685. * @returns the created VertexData
  142686. */
  142687. buildVertexData(depth?: number): VertexData;
  142688. /**
  142689. * Adds a side to the polygon
  142690. * @param positions points that make the polygon
  142691. * @param normals normals of the polygon
  142692. * @param uvs uvs of the polygon
  142693. * @param indices indices of the polygon
  142694. * @param bounds bounds of the polygon
  142695. * @param points points of the polygon
  142696. * @param depth depth of the polygon
  142697. * @param flip flip of the polygon
  142698. */
  142699. private addSide;
  142700. }
  142701. }
  142702. declare module BABYLON {
  142703. /**
  142704. * Class containing static functions to help procedurally build meshes
  142705. */
  142706. export class PolygonBuilder {
  142707. /**
  142708. * Creates a polygon mesh
  142709. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  142710. * * 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
  142711. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142713. * * 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)
  142714. * * Remember you can only change the shape positions, not their number when updating a polygon
  142715. * @param name defines the name of the mesh
  142716. * @param options defines the options used to create the mesh
  142717. * @param scene defines the hosting scene
  142718. * @param earcutInjection can be used to inject your own earcut reference
  142719. * @returns the polygon mesh
  142720. */
  142721. static CreatePolygon(name: string, options: {
  142722. shape: Vector3[];
  142723. holes?: Vector3[][];
  142724. depth?: number;
  142725. faceUV?: Vector4[];
  142726. faceColors?: Color4[];
  142727. updatable?: boolean;
  142728. sideOrientation?: number;
  142729. frontUVs?: Vector4;
  142730. backUVs?: Vector4;
  142731. wrap?: boolean;
  142732. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142733. /**
  142734. * Creates an extruded polygon mesh, with depth in the Y direction.
  142735. * * 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)
  142736. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142737. * @param name defines the name of the mesh
  142738. * @param options defines the options used to create the mesh
  142739. * @param scene defines the hosting scene
  142740. * @param earcutInjection can be used to inject your own earcut reference
  142741. * @returns the polygon mesh
  142742. */
  142743. static ExtrudePolygon(name: string, options: {
  142744. shape: Vector3[];
  142745. holes?: Vector3[][];
  142746. depth?: number;
  142747. faceUV?: Vector4[];
  142748. faceColors?: Color4[];
  142749. updatable?: boolean;
  142750. sideOrientation?: number;
  142751. frontUVs?: Vector4;
  142752. backUVs?: Vector4;
  142753. wrap?: boolean;
  142754. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142755. }
  142756. }
  142757. declare module BABYLON {
  142758. /**
  142759. * Class containing static functions to help procedurally build meshes
  142760. */
  142761. export class LatheBuilder {
  142762. /**
  142763. * Creates lathe mesh.
  142764. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142765. * * 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
  142766. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142767. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142768. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142769. * * 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
  142770. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142771. * * 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
  142772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142773. * * 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
  142774. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142776. * @param name defines the name of the mesh
  142777. * @param options defines the options used to create the mesh
  142778. * @param scene defines the hosting scene
  142779. * @returns the lathe mesh
  142780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142781. */
  142782. static CreateLathe(name: string, options: {
  142783. shape: Vector3[];
  142784. radius?: number;
  142785. tessellation?: number;
  142786. clip?: number;
  142787. arc?: number;
  142788. closed?: boolean;
  142789. updatable?: boolean;
  142790. sideOrientation?: number;
  142791. frontUVs?: Vector4;
  142792. backUVs?: Vector4;
  142793. cap?: number;
  142794. invertUV?: boolean;
  142795. }, scene?: Nullable<Scene>): Mesh;
  142796. }
  142797. }
  142798. declare module BABYLON {
  142799. /**
  142800. * Class containing static functions to help procedurally build meshes
  142801. */
  142802. export class TiledPlaneBuilder {
  142803. /**
  142804. * Creates a tiled plane mesh
  142805. * * The parameter `pattern` will, depending on value, do nothing or
  142806. * * * flip (reflect about central vertical) alternate tiles across and up
  142807. * * * flip every tile on alternate rows
  142808. * * * rotate (180 degs) alternate tiles across and up
  142809. * * * rotate every tile on alternate rows
  142810. * * * flip and rotate alternate tiles across and up
  142811. * * * flip and rotate every tile on alternate rows
  142812. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  142813. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  142814. * * 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
  142815. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142816. * * 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)
  142817. * * 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)
  142818. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142819. * @param name defines the name of the mesh
  142820. * @param options defines the options used to create the mesh
  142821. * @param scene defines the hosting scene
  142822. * @returns the box mesh
  142823. */
  142824. static CreateTiledPlane(name: string, options: {
  142825. pattern?: number;
  142826. tileSize?: number;
  142827. tileWidth?: number;
  142828. tileHeight?: number;
  142829. size?: number;
  142830. width?: number;
  142831. height?: number;
  142832. alignHorizontal?: number;
  142833. alignVertical?: number;
  142834. sideOrientation?: number;
  142835. frontUVs?: Vector4;
  142836. backUVs?: Vector4;
  142837. updatable?: boolean;
  142838. }, scene?: Nullable<Scene>): Mesh;
  142839. }
  142840. }
  142841. declare module BABYLON {
  142842. /**
  142843. * Class containing static functions to help procedurally build meshes
  142844. */
  142845. export class TubeBuilder {
  142846. /**
  142847. * Creates a tube mesh.
  142848. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142849. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142850. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142851. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142852. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142853. * * 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)
  142854. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142855. * * 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
  142856. * * 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
  142857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142858. * * 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
  142859. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142861. * @param name defines the name of the mesh
  142862. * @param options defines the options used to create the mesh
  142863. * @param scene defines the hosting scene
  142864. * @returns the tube mesh
  142865. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142866. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142867. */
  142868. static CreateTube(name: string, options: {
  142869. path: Vector3[];
  142870. radius?: number;
  142871. tessellation?: number;
  142872. radiusFunction?: {
  142873. (i: number, distance: number): number;
  142874. };
  142875. cap?: number;
  142876. arc?: number;
  142877. updatable?: boolean;
  142878. sideOrientation?: number;
  142879. frontUVs?: Vector4;
  142880. backUVs?: Vector4;
  142881. instance?: Mesh;
  142882. invertUV?: boolean;
  142883. }, scene?: Nullable<Scene>): Mesh;
  142884. }
  142885. }
  142886. declare module BABYLON {
  142887. /**
  142888. * Class containing static functions to help procedurally build meshes
  142889. */
  142890. export class IcoSphereBuilder {
  142891. /**
  142892. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142893. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142894. * * 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`)
  142895. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142896. * * 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
  142897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142898. * * 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
  142899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142900. * @param name defines the name of the mesh
  142901. * @param options defines the options used to create the mesh
  142902. * @param scene defines the hosting scene
  142903. * @returns the icosahedron mesh
  142904. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142905. */
  142906. static CreateIcoSphere(name: string, options: {
  142907. radius?: number;
  142908. radiusX?: number;
  142909. radiusY?: number;
  142910. radiusZ?: number;
  142911. flat?: boolean;
  142912. subdivisions?: number;
  142913. sideOrientation?: number;
  142914. frontUVs?: Vector4;
  142915. backUVs?: Vector4;
  142916. updatable?: boolean;
  142917. }, scene?: Nullable<Scene>): Mesh;
  142918. }
  142919. }
  142920. declare module BABYLON {
  142921. /**
  142922. * Class containing static functions to help procedurally build meshes
  142923. */
  142924. export class DecalBuilder {
  142925. /**
  142926. * Creates a decal mesh.
  142927. * 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
  142928. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142929. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142930. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142931. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142932. * @param name defines the name of the mesh
  142933. * @param sourceMesh defines the mesh where the decal must be applied
  142934. * @param options defines the options used to create the mesh
  142935. * @param scene defines the hosting scene
  142936. * @returns the decal mesh
  142937. * @see https://doc.babylonjs.com/how_to/decals
  142938. */
  142939. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142940. position?: Vector3;
  142941. normal?: Vector3;
  142942. size?: Vector3;
  142943. angle?: number;
  142944. }): Mesh;
  142945. }
  142946. }
  142947. declare module BABYLON {
  142948. /**
  142949. * Class containing static functions to help procedurally build meshes
  142950. */
  142951. export class MeshBuilder {
  142952. /**
  142953. * Creates a box mesh
  142954. * * The parameter `size` sets the size (float) of each box side (default 1)
  142955. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  142956. * * 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)
  142957. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142959. * * 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
  142960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142961. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142962. * @param name defines the name of the mesh
  142963. * @param options defines the options used to create the mesh
  142964. * @param scene defines the hosting scene
  142965. * @returns the box mesh
  142966. */
  142967. static CreateBox(name: string, options: {
  142968. size?: number;
  142969. width?: number;
  142970. height?: number;
  142971. depth?: number;
  142972. faceUV?: Vector4[];
  142973. faceColors?: Color4[];
  142974. sideOrientation?: number;
  142975. frontUVs?: Vector4;
  142976. backUVs?: Vector4;
  142977. wrap?: boolean;
  142978. topBaseAt?: number;
  142979. bottomBaseAt?: number;
  142980. updatable?: boolean;
  142981. }, scene?: Nullable<Scene>): Mesh;
  142982. /**
  142983. * Creates a tiled box mesh
  142984. * * faceTiles sets the pattern, tile size and number of tiles for a face
  142985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142986. * @param name defines the name of the mesh
  142987. * @param options defines the options used to create the mesh
  142988. * @param scene defines the hosting scene
  142989. * @returns the tiled box mesh
  142990. */
  142991. static CreateTiledBox(name: string, options: {
  142992. pattern?: number;
  142993. size?: number;
  142994. width?: number;
  142995. height?: number;
  142996. depth: number;
  142997. tileSize?: number;
  142998. tileWidth?: number;
  142999. tileHeight?: number;
  143000. faceUV?: Vector4[];
  143001. faceColors?: Color4[];
  143002. alignHorizontal?: number;
  143003. alignVertical?: number;
  143004. sideOrientation?: number;
  143005. updatable?: boolean;
  143006. }, scene?: Nullable<Scene>): Mesh;
  143007. /**
  143008. * Creates a sphere mesh
  143009. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  143010. * * 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`)
  143011. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  143012. * * 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
  143013. * * 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)
  143014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143015. * * 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
  143016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143017. * @param name defines the name of the mesh
  143018. * @param options defines the options used to create the mesh
  143019. * @param scene defines the hosting scene
  143020. * @returns the sphere mesh
  143021. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  143022. */
  143023. static CreateSphere(name: string, options: {
  143024. segments?: number;
  143025. diameter?: number;
  143026. diameterX?: number;
  143027. diameterY?: number;
  143028. diameterZ?: number;
  143029. arc?: number;
  143030. slice?: number;
  143031. sideOrientation?: number;
  143032. frontUVs?: Vector4;
  143033. backUVs?: Vector4;
  143034. updatable?: boolean;
  143035. }, scene?: Nullable<Scene>): Mesh;
  143036. /**
  143037. * Creates a plane polygonal mesh. By default, this is a disc
  143038. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  143039. * * 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
  143040. * * 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
  143041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143042. * * 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
  143043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143044. * @param name defines the name of the mesh
  143045. * @param options defines the options used to create the mesh
  143046. * @param scene defines the hosting scene
  143047. * @returns the plane polygonal mesh
  143048. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  143049. */
  143050. static CreateDisc(name: string, options: {
  143051. radius?: number;
  143052. tessellation?: number;
  143053. arc?: number;
  143054. updatable?: boolean;
  143055. sideOrientation?: number;
  143056. frontUVs?: Vector4;
  143057. backUVs?: Vector4;
  143058. }, scene?: Nullable<Scene>): Mesh;
  143059. /**
  143060. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  143061. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  143062. * * 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`)
  143063. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  143064. * * 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
  143065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143066. * * 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
  143067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143068. * @param name defines the name of the mesh
  143069. * @param options defines the options used to create the mesh
  143070. * @param scene defines the hosting scene
  143071. * @returns the icosahedron mesh
  143072. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  143073. */
  143074. static CreateIcoSphere(name: string, options: {
  143075. radius?: number;
  143076. radiusX?: number;
  143077. radiusY?: number;
  143078. radiusZ?: number;
  143079. flat?: boolean;
  143080. subdivisions?: number;
  143081. sideOrientation?: number;
  143082. frontUVs?: Vector4;
  143083. backUVs?: Vector4;
  143084. updatable?: boolean;
  143085. }, scene?: Nullable<Scene>): Mesh;
  143086. /**
  143087. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143088. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  143089. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  143090. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  143091. * * 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
  143092. * * 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
  143093. * * 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
  143094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143095. * * 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
  143096. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143097. * * 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
  143098. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  143099. * * 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
  143100. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  143101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143102. * @param name defines the name of the mesh
  143103. * @param options defines the options used to create the mesh
  143104. * @param scene defines the hosting scene
  143105. * @returns the ribbon mesh
  143106. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  143107. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143108. */
  143109. static CreateRibbon(name: string, options: {
  143110. pathArray: Vector3[][];
  143111. closeArray?: boolean;
  143112. closePath?: boolean;
  143113. offset?: number;
  143114. updatable?: boolean;
  143115. sideOrientation?: number;
  143116. frontUVs?: Vector4;
  143117. backUVs?: Vector4;
  143118. instance?: Mesh;
  143119. invertUV?: boolean;
  143120. uvs?: Vector2[];
  143121. colors?: Color4[];
  143122. }, scene?: Nullable<Scene>): Mesh;
  143123. /**
  143124. * Creates a cylinder or a cone mesh
  143125. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  143126. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  143127. * * 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.
  143128. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  143129. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  143130. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  143131. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  143132. * * 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).
  143133. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  143134. * * 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).
  143135. * * 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
  143136. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  143137. * * 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
  143138. * * 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.
  143139. * * If `enclose` is false, a ring surface is one element.
  143140. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  143141. * * 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
  143142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143143. * * 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
  143144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143145. * @param name defines the name of the mesh
  143146. * @param options defines the options used to create the mesh
  143147. * @param scene defines the hosting scene
  143148. * @returns the cylinder mesh
  143149. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  143150. */
  143151. static CreateCylinder(name: string, options: {
  143152. height?: number;
  143153. diameterTop?: number;
  143154. diameterBottom?: number;
  143155. diameter?: number;
  143156. tessellation?: number;
  143157. subdivisions?: number;
  143158. arc?: number;
  143159. faceColors?: Color4[];
  143160. faceUV?: Vector4[];
  143161. updatable?: boolean;
  143162. hasRings?: boolean;
  143163. enclose?: boolean;
  143164. cap?: number;
  143165. sideOrientation?: number;
  143166. frontUVs?: Vector4;
  143167. backUVs?: Vector4;
  143168. }, scene?: Nullable<Scene>): Mesh;
  143169. /**
  143170. * Creates a torus mesh
  143171. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  143172. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  143173. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  143174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143175. * * 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
  143176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143177. * @param name defines the name of the mesh
  143178. * @param options defines the options used to create the mesh
  143179. * @param scene defines the hosting scene
  143180. * @returns the torus mesh
  143181. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  143182. */
  143183. static CreateTorus(name: string, options: {
  143184. diameter?: number;
  143185. thickness?: number;
  143186. tessellation?: number;
  143187. updatable?: boolean;
  143188. sideOrientation?: number;
  143189. frontUVs?: Vector4;
  143190. backUVs?: Vector4;
  143191. }, scene?: Nullable<Scene>): Mesh;
  143192. /**
  143193. * Creates a torus knot mesh
  143194. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  143195. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  143196. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  143197. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  143198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143199. * * 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
  143200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143201. * @param name defines the name of the mesh
  143202. * @param options defines the options used to create the mesh
  143203. * @param scene defines the hosting scene
  143204. * @returns the torus knot mesh
  143205. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  143206. */
  143207. static CreateTorusKnot(name: string, options: {
  143208. radius?: number;
  143209. tube?: number;
  143210. radialSegments?: number;
  143211. tubularSegments?: number;
  143212. p?: number;
  143213. q?: number;
  143214. updatable?: boolean;
  143215. sideOrientation?: number;
  143216. frontUVs?: Vector4;
  143217. backUVs?: Vector4;
  143218. }, scene?: Nullable<Scene>): Mesh;
  143219. /**
  143220. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  143221. * * 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
  143222. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  143223. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  143224. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  143225. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  143226. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  143227. * * 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
  143228. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  143229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  143231. * @param name defines the name of the new line system
  143232. * @param options defines the options used to create the line system
  143233. * @param scene defines the hosting scene
  143234. * @returns a new line system mesh
  143235. */
  143236. static CreateLineSystem(name: string, options: {
  143237. lines: Vector3[][];
  143238. updatable?: boolean;
  143239. instance?: Nullable<LinesMesh>;
  143240. colors?: Nullable<Color4[][]>;
  143241. useVertexAlpha?: boolean;
  143242. }, scene: Nullable<Scene>): LinesMesh;
  143243. /**
  143244. * Creates a line mesh
  143245. * 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
  143246. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  143247. * * The parameter `points` is an array successive Vector3
  143248. * * 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
  143249. * * The optional parameter `colors` is an array of successive Color4, one per line point
  143250. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  143251. * * When updating an instance, remember that only point positions can change, not the number of points
  143252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  143254. * @param name defines the name of the new line system
  143255. * @param options defines the options used to create the line system
  143256. * @param scene defines the hosting scene
  143257. * @returns a new line mesh
  143258. */
  143259. static CreateLines(name: string, options: {
  143260. points: Vector3[];
  143261. updatable?: boolean;
  143262. instance?: Nullable<LinesMesh>;
  143263. colors?: Color4[];
  143264. useVertexAlpha?: boolean;
  143265. }, scene?: Nullable<Scene>): LinesMesh;
  143266. /**
  143267. * Creates a dashed line mesh
  143268. * * 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
  143269. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  143270. * * The parameter `points` is an array successive Vector3
  143271. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  143272. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  143273. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  143274. * * 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
  143275. * * When updating an instance, remember that only point positions can change, not the number of points
  143276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143277. * @param name defines the name of the mesh
  143278. * @param options defines the options used to create the mesh
  143279. * @param scene defines the hosting scene
  143280. * @returns the dashed line mesh
  143281. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  143282. */
  143283. static CreateDashedLines(name: string, options: {
  143284. points: Vector3[];
  143285. dashSize?: number;
  143286. gapSize?: number;
  143287. dashNb?: number;
  143288. updatable?: boolean;
  143289. instance?: LinesMesh;
  143290. }, scene?: Nullable<Scene>): LinesMesh;
  143291. /**
  143292. * 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.
  143293. * * 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.
  143294. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143295. * * 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.
  143296. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  143297. * * 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
  143298. * * 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
  143299. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  143300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143301. * * 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
  143302. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  143303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143304. * @param name defines the name of the mesh
  143305. * @param options defines the options used to create the mesh
  143306. * @param scene defines the hosting scene
  143307. * @returns the extruded shape mesh
  143308. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143310. */
  143311. static ExtrudeShape(name: string, options: {
  143312. shape: Vector3[];
  143313. path: Vector3[];
  143314. scale?: number;
  143315. rotation?: number;
  143316. cap?: number;
  143317. updatable?: boolean;
  143318. sideOrientation?: number;
  143319. frontUVs?: Vector4;
  143320. backUVs?: Vector4;
  143321. instance?: Mesh;
  143322. invertUV?: boolean;
  143323. }, scene?: Nullable<Scene>): Mesh;
  143324. /**
  143325. * Creates an custom extruded shape mesh.
  143326. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  143327. * * 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.
  143328. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143329. * * 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
  143330. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  143331. * * 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
  143332. * * It must returns a float value that will be the scale value applied to the shape on each path point
  143333. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  143334. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  143335. * * 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
  143336. * * 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
  143337. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  143338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143339. * * 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
  143340. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143342. * @param name defines the name of the mesh
  143343. * @param options defines the options used to create the mesh
  143344. * @param scene defines the hosting scene
  143345. * @returns the custom extruded shape mesh
  143346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  143347. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143348. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143349. */
  143350. static ExtrudeShapeCustom(name: string, options: {
  143351. shape: Vector3[];
  143352. path: Vector3[];
  143353. scaleFunction?: any;
  143354. rotationFunction?: any;
  143355. ribbonCloseArray?: boolean;
  143356. ribbonClosePath?: boolean;
  143357. cap?: number;
  143358. updatable?: boolean;
  143359. sideOrientation?: number;
  143360. frontUVs?: Vector4;
  143361. backUVs?: Vector4;
  143362. instance?: Mesh;
  143363. invertUV?: boolean;
  143364. }, scene?: Nullable<Scene>): Mesh;
  143365. /**
  143366. * Creates lathe mesh.
  143367. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  143368. * * 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
  143369. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  143370. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  143371. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  143372. * * 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
  143373. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  143374. * * 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
  143375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143376. * * 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
  143377. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143379. * @param name defines the name of the mesh
  143380. * @param options defines the options used to create the mesh
  143381. * @param scene defines the hosting scene
  143382. * @returns the lathe mesh
  143383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  143384. */
  143385. static CreateLathe(name: string, options: {
  143386. shape: Vector3[];
  143387. radius?: number;
  143388. tessellation?: number;
  143389. clip?: number;
  143390. arc?: number;
  143391. closed?: boolean;
  143392. updatable?: boolean;
  143393. sideOrientation?: number;
  143394. frontUVs?: Vector4;
  143395. backUVs?: Vector4;
  143396. cap?: number;
  143397. invertUV?: boolean;
  143398. }, scene?: Nullable<Scene>): Mesh;
  143399. /**
  143400. * Creates a tiled plane mesh
  143401. * * You can set a limited pattern arrangement with the tiles
  143402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143403. * * 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
  143404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143405. * @param name defines the name of the mesh
  143406. * @param options defines the options used to create the mesh
  143407. * @param scene defines the hosting scene
  143408. * @returns the plane mesh
  143409. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  143410. */
  143411. static CreateTiledPlane(name: string, options: {
  143412. pattern?: number;
  143413. tileSize?: number;
  143414. tileWidth?: number;
  143415. tileHeight?: number;
  143416. size?: number;
  143417. width?: number;
  143418. height?: number;
  143419. alignHorizontal?: number;
  143420. alignVertical?: number;
  143421. sideOrientation?: number;
  143422. frontUVs?: Vector4;
  143423. backUVs?: Vector4;
  143424. updatable?: boolean;
  143425. }, scene?: Nullable<Scene>): Mesh;
  143426. /**
  143427. * Creates a plane mesh
  143428. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  143429. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  143430. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  143431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143432. * * 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
  143433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143434. * @param name defines the name of the mesh
  143435. * @param options defines the options used to create the mesh
  143436. * @param scene defines the hosting scene
  143437. * @returns the plane mesh
  143438. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  143439. */
  143440. static CreatePlane(name: string, options: {
  143441. size?: number;
  143442. width?: number;
  143443. height?: number;
  143444. sideOrientation?: number;
  143445. frontUVs?: Vector4;
  143446. backUVs?: Vector4;
  143447. updatable?: boolean;
  143448. sourcePlane?: Plane;
  143449. }, scene?: Nullable<Scene>): Mesh;
  143450. /**
  143451. * Creates a ground mesh
  143452. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  143453. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  143454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143455. * @param name defines the name of the mesh
  143456. * @param options defines the options used to create the mesh
  143457. * @param scene defines the hosting scene
  143458. * @returns the ground mesh
  143459. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  143460. */
  143461. static CreateGround(name: string, options: {
  143462. width?: number;
  143463. height?: number;
  143464. subdivisions?: number;
  143465. subdivisionsX?: number;
  143466. subdivisionsY?: number;
  143467. updatable?: boolean;
  143468. }, scene?: Nullable<Scene>): Mesh;
  143469. /**
  143470. * Creates a tiled ground mesh
  143471. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  143472. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  143473. * * 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
  143474. * * 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
  143475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143476. * @param name defines the name of the mesh
  143477. * @param options defines the options used to create the mesh
  143478. * @param scene defines the hosting scene
  143479. * @returns the tiled ground mesh
  143480. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  143481. */
  143482. static CreateTiledGround(name: string, options: {
  143483. xmin: number;
  143484. zmin: number;
  143485. xmax: number;
  143486. zmax: number;
  143487. subdivisions?: {
  143488. w: number;
  143489. h: number;
  143490. };
  143491. precision?: {
  143492. w: number;
  143493. h: number;
  143494. };
  143495. updatable?: boolean;
  143496. }, scene?: Nullable<Scene>): Mesh;
  143497. /**
  143498. * Creates a ground mesh from a height map
  143499. * * The parameter `url` sets the URL of the height map image resource.
  143500. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  143501. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  143502. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  143503. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  143504. * * 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.
  143505. * * 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).
  143506. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  143507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143508. * @param name defines the name of the mesh
  143509. * @param url defines the url to the height map
  143510. * @param options defines the options used to create the mesh
  143511. * @param scene defines the hosting scene
  143512. * @returns the ground mesh
  143513. * @see https://doc.babylonjs.com/babylon101/height_map
  143514. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  143515. */
  143516. static CreateGroundFromHeightMap(name: string, url: string, options: {
  143517. width?: number;
  143518. height?: number;
  143519. subdivisions?: number;
  143520. minHeight?: number;
  143521. maxHeight?: number;
  143522. colorFilter?: Color3;
  143523. alphaFilter?: number;
  143524. updatable?: boolean;
  143525. onReady?: (mesh: GroundMesh) => void;
  143526. }, scene?: Nullable<Scene>): GroundMesh;
  143527. /**
  143528. * Creates a polygon mesh
  143529. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  143530. * * 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
  143531. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143533. * * 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)
  143534. * * Remember you can only change the shape positions, not their number when updating a polygon
  143535. * @param name defines the name of the mesh
  143536. * @param options defines the options used to create the mesh
  143537. * @param scene defines the hosting scene
  143538. * @param earcutInjection can be used to inject your own earcut reference
  143539. * @returns the polygon mesh
  143540. */
  143541. static CreatePolygon(name: string, options: {
  143542. shape: Vector3[];
  143543. holes?: Vector3[][];
  143544. depth?: number;
  143545. faceUV?: Vector4[];
  143546. faceColors?: Color4[];
  143547. updatable?: boolean;
  143548. sideOrientation?: number;
  143549. frontUVs?: Vector4;
  143550. backUVs?: Vector4;
  143551. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143552. /**
  143553. * Creates an extruded polygon mesh, with depth in the Y direction.
  143554. * * 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)
  143555. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143556. * @param name defines the name of the mesh
  143557. * @param options defines the options used to create the mesh
  143558. * @param scene defines the hosting scene
  143559. * @param earcutInjection can be used to inject your own earcut reference
  143560. * @returns the polygon mesh
  143561. */
  143562. static ExtrudePolygon(name: string, options: {
  143563. shape: Vector3[];
  143564. holes?: Vector3[][];
  143565. depth?: number;
  143566. faceUV?: Vector4[];
  143567. faceColors?: Color4[];
  143568. updatable?: boolean;
  143569. sideOrientation?: number;
  143570. frontUVs?: Vector4;
  143571. backUVs?: Vector4;
  143572. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143573. /**
  143574. * Creates a tube mesh.
  143575. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143576. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  143577. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  143578. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  143579. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  143580. * * 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)
  143581. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  143582. * * 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
  143583. * * 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
  143584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143585. * * 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
  143586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143588. * @param name defines the name of the mesh
  143589. * @param options defines the options used to create the mesh
  143590. * @param scene defines the hosting scene
  143591. * @returns the tube mesh
  143592. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143593. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  143594. */
  143595. static CreateTube(name: string, options: {
  143596. path: Vector3[];
  143597. radius?: number;
  143598. tessellation?: number;
  143599. radiusFunction?: {
  143600. (i: number, distance: number): number;
  143601. };
  143602. cap?: number;
  143603. arc?: number;
  143604. updatable?: boolean;
  143605. sideOrientation?: number;
  143606. frontUVs?: Vector4;
  143607. backUVs?: Vector4;
  143608. instance?: Mesh;
  143609. invertUV?: boolean;
  143610. }, scene?: Nullable<Scene>): Mesh;
  143611. /**
  143612. * Creates a polyhedron mesh
  143613. * * 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
  143614. * * The parameter `size` (positive float, default 1) sets the polygon size
  143615. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  143616. * * 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`
  143617. * * 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
  143618. * * 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)`)
  143619. * * 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
  143620. * * 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
  143621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143622. * * 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
  143623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143624. * @param name defines the name of the mesh
  143625. * @param options defines the options used to create the mesh
  143626. * @param scene defines the hosting scene
  143627. * @returns the polyhedron mesh
  143628. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  143629. */
  143630. static CreatePolyhedron(name: string, options: {
  143631. type?: number;
  143632. size?: number;
  143633. sizeX?: number;
  143634. sizeY?: number;
  143635. sizeZ?: number;
  143636. custom?: any;
  143637. faceUV?: Vector4[];
  143638. faceColors?: Color4[];
  143639. flat?: boolean;
  143640. updatable?: boolean;
  143641. sideOrientation?: number;
  143642. frontUVs?: Vector4;
  143643. backUVs?: Vector4;
  143644. }, scene?: Nullable<Scene>): Mesh;
  143645. /**
  143646. * Creates a decal mesh.
  143647. * 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
  143648. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  143649. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  143650. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  143651. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  143652. * @param name defines the name of the mesh
  143653. * @param sourceMesh defines the mesh where the decal must be applied
  143654. * @param options defines the options used to create the mesh
  143655. * @param scene defines the hosting scene
  143656. * @returns the decal mesh
  143657. * @see https://doc.babylonjs.com/how_to/decals
  143658. */
  143659. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  143660. position?: Vector3;
  143661. normal?: Vector3;
  143662. size?: Vector3;
  143663. angle?: number;
  143664. }): Mesh;
  143665. }
  143666. }
  143667. declare module BABYLON {
  143668. /**
  143669. * A simplifier interface for future simplification implementations
  143670. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143671. */
  143672. export interface ISimplifier {
  143673. /**
  143674. * Simplification of a given mesh according to the given settings.
  143675. * Since this requires computation, it is assumed that the function runs async.
  143676. * @param settings The settings of the simplification, including quality and distance
  143677. * @param successCallback A callback that will be called after the mesh was simplified.
  143678. * @param errorCallback in case of an error, this callback will be called. optional.
  143679. */
  143680. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  143681. }
  143682. /**
  143683. * Expected simplification settings.
  143684. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  143685. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143686. */
  143687. export interface ISimplificationSettings {
  143688. /**
  143689. * Gets or sets the expected quality
  143690. */
  143691. quality: number;
  143692. /**
  143693. * Gets or sets the distance when this optimized version should be used
  143694. */
  143695. distance: number;
  143696. /**
  143697. * Gets an already optimized mesh
  143698. */
  143699. optimizeMesh?: boolean;
  143700. }
  143701. /**
  143702. * Class used to specify simplification options
  143703. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143704. */
  143705. export class SimplificationSettings implements ISimplificationSettings {
  143706. /** expected quality */
  143707. quality: number;
  143708. /** distance when this optimized version should be used */
  143709. distance: number;
  143710. /** already optimized mesh */
  143711. optimizeMesh?: boolean | undefined;
  143712. /**
  143713. * Creates a SimplificationSettings
  143714. * @param quality expected quality
  143715. * @param distance distance when this optimized version should be used
  143716. * @param optimizeMesh already optimized mesh
  143717. */
  143718. constructor(
  143719. /** expected quality */
  143720. quality: number,
  143721. /** distance when this optimized version should be used */
  143722. distance: number,
  143723. /** already optimized mesh */
  143724. optimizeMesh?: boolean | undefined);
  143725. }
  143726. /**
  143727. * Interface used to define a simplification task
  143728. */
  143729. export interface ISimplificationTask {
  143730. /**
  143731. * Array of settings
  143732. */
  143733. settings: Array<ISimplificationSettings>;
  143734. /**
  143735. * Simplification type
  143736. */
  143737. simplificationType: SimplificationType;
  143738. /**
  143739. * Mesh to simplify
  143740. */
  143741. mesh: Mesh;
  143742. /**
  143743. * Callback called on success
  143744. */
  143745. successCallback?: () => void;
  143746. /**
  143747. * Defines if parallel processing can be used
  143748. */
  143749. parallelProcessing: boolean;
  143750. }
  143751. /**
  143752. * Queue used to order the simplification tasks
  143753. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143754. */
  143755. export class SimplificationQueue {
  143756. private _simplificationArray;
  143757. /**
  143758. * Gets a boolean indicating that the process is still running
  143759. */
  143760. running: boolean;
  143761. /**
  143762. * Creates a new queue
  143763. */
  143764. constructor();
  143765. /**
  143766. * Adds a new simplification task
  143767. * @param task defines a task to add
  143768. */
  143769. addTask(task: ISimplificationTask): void;
  143770. /**
  143771. * Execute next task
  143772. */
  143773. executeNext(): void;
  143774. /**
  143775. * Execute a simplification task
  143776. * @param task defines the task to run
  143777. */
  143778. runSimplification(task: ISimplificationTask): void;
  143779. private getSimplifier;
  143780. }
  143781. /**
  143782. * The implemented types of simplification
  143783. * At the moment only Quadratic Error Decimation is implemented
  143784. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143785. */
  143786. export enum SimplificationType {
  143787. /** Quadratic error decimation */
  143788. QUADRATIC = 0
  143789. }
  143790. /**
  143791. * An implementation of the Quadratic Error simplification algorithm.
  143792. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  143793. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  143794. * @author RaananW
  143795. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143796. */
  143797. export class QuadraticErrorSimplification implements ISimplifier {
  143798. private _mesh;
  143799. private triangles;
  143800. private vertices;
  143801. private references;
  143802. private _reconstructedMesh;
  143803. /** Gets or sets the number pf sync interations */
  143804. syncIterations: number;
  143805. /** Gets or sets the aggressiveness of the simplifier */
  143806. aggressiveness: number;
  143807. /** Gets or sets the number of allowed iterations for decimation */
  143808. decimationIterations: number;
  143809. /** Gets or sets the espilon to use for bounding box computation */
  143810. boundingBoxEpsilon: number;
  143811. /**
  143812. * Creates a new QuadraticErrorSimplification
  143813. * @param _mesh defines the target mesh
  143814. */
  143815. constructor(_mesh: Mesh);
  143816. /**
  143817. * Simplification of a given mesh according to the given settings.
  143818. * Since this requires computation, it is assumed that the function runs async.
  143819. * @param settings The settings of the simplification, including quality and distance
  143820. * @param successCallback A callback that will be called after the mesh was simplified.
  143821. */
  143822. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  143823. private runDecimation;
  143824. private initWithMesh;
  143825. private init;
  143826. private reconstructMesh;
  143827. private initDecimatedMesh;
  143828. private isFlipped;
  143829. private updateTriangles;
  143830. private identifyBorder;
  143831. private updateMesh;
  143832. private vertexError;
  143833. private calculateError;
  143834. }
  143835. }
  143836. declare module BABYLON {
  143837. interface Scene {
  143838. /** @hidden (Backing field) */
  143839. _simplificationQueue: SimplificationQueue;
  143840. /**
  143841. * Gets or sets the simplification queue attached to the scene
  143842. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143843. */
  143844. simplificationQueue: SimplificationQueue;
  143845. }
  143846. interface Mesh {
  143847. /**
  143848. * Simplify the mesh according to the given array of settings.
  143849. * Function will return immediately and will simplify async
  143850. * @param settings a collection of simplification settings
  143851. * @param parallelProcessing should all levels calculate parallel or one after the other
  143852. * @param simplificationType the type of simplification to run
  143853. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  143854. * @returns the current mesh
  143855. */
  143856. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  143857. }
  143858. /**
  143859. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  143860. * created in a scene
  143861. */
  143862. export class SimplicationQueueSceneComponent implements ISceneComponent {
  143863. /**
  143864. * The component name helpfull to identify the component in the list of scene components.
  143865. */
  143866. readonly name: string;
  143867. /**
  143868. * The scene the component belongs to.
  143869. */
  143870. scene: Scene;
  143871. /**
  143872. * Creates a new instance of the component for the given scene
  143873. * @param scene Defines the scene to register the component in
  143874. */
  143875. constructor(scene: Scene);
  143876. /**
  143877. * Registers the component in a given scene
  143878. */
  143879. register(): void;
  143880. /**
  143881. * Rebuilds the elements related to this component in case of
  143882. * context lost for instance.
  143883. */
  143884. rebuild(): void;
  143885. /**
  143886. * Disposes the component and the associated ressources
  143887. */
  143888. dispose(): void;
  143889. private _beforeCameraUpdate;
  143890. }
  143891. }
  143892. declare module BABYLON {
  143893. interface Mesh {
  143894. /**
  143895. * Creates a new thin instance
  143896. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  143897. * @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
  143898. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  143899. */
  143900. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  143901. /**
  143902. * Adds the transformation (matrix) of the current mesh as a thin instance
  143903. * @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
  143904. * @returns the thin instance index number
  143905. */
  143906. thinInstanceAddSelf(refresh: boolean): number;
  143907. /**
  143908. * Registers a custom attribute to be used with thin instances
  143909. * @param kind name of the attribute
  143910. * @param stride size in floats of the attribute
  143911. */
  143912. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  143913. /**
  143914. * Sets the matrix of a thin instance
  143915. * @param index index of the thin instance
  143916. * @param matrix matrix to set
  143917. * @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
  143918. */
  143919. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  143920. /**
  143921. * Sets the value of a custom attribute for a thin instance
  143922. * @param kind name of the attribute
  143923. * @param index index of the thin instance
  143924. * @param value value to set
  143925. * @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
  143926. */
  143927. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  143928. /**
  143929. * 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.
  143930. */
  143931. thinInstanceCount: number;
  143932. /**
  143933. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  143934. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  143935. * @param buffer buffer to set
  143936. * @param stride size in floats of each value of the buffer
  143937. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  143938. */
  143939. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  143940. /**
  143941. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  143942. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  143943. */
  143944. thinInstanceBufferUpdated(kind: string): void;
  143945. /**
  143946. * Refreshes the bounding info, taking into account all the thin instances defined
  143947. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  143948. */
  143949. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  143950. /** @hidden */
  143951. _thinInstanceInitializeUserStorage(): void;
  143952. /** @hidden */
  143953. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  143954. /** @hidden */
  143955. _userThinInstanceBuffersStorage: {
  143956. data: {
  143957. [key: string]: Float32Array;
  143958. };
  143959. sizes: {
  143960. [key: string]: number;
  143961. };
  143962. vertexBuffers: {
  143963. [key: string]: Nullable<VertexBuffer>;
  143964. };
  143965. strides: {
  143966. [key: string]: number;
  143967. };
  143968. };
  143969. }
  143970. }
  143971. declare module BABYLON {
  143972. /**
  143973. * Navigation plugin interface to add navigation constrained by a navigation mesh
  143974. */
  143975. export interface INavigationEnginePlugin {
  143976. /**
  143977. * plugin name
  143978. */
  143979. name: string;
  143980. /**
  143981. * Creates a navigation mesh
  143982. * @param meshes array of all the geometry used to compute the navigatio mesh
  143983. * @param parameters bunch of parameters used to filter geometry
  143984. */
  143985. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143986. /**
  143987. * Create a navigation mesh debug mesh
  143988. * @param scene is where the mesh will be added
  143989. * @returns debug display mesh
  143990. */
  143991. createDebugNavMesh(scene: Scene): Mesh;
  143992. /**
  143993. * Get a navigation mesh constrained position, closest to the parameter position
  143994. * @param position world position
  143995. * @returns the closest point to position constrained by the navigation mesh
  143996. */
  143997. getClosestPoint(position: Vector3): Vector3;
  143998. /**
  143999. * Get a navigation mesh constrained position, closest to the parameter position
  144000. * @param position world position
  144001. * @param result output the closest point to position constrained by the navigation mesh
  144002. */
  144003. getClosestPointToRef(position: Vector3, result: Vector3): void;
  144004. /**
  144005. * Get a navigation mesh constrained position, within a particular radius
  144006. * @param position world position
  144007. * @param maxRadius the maximum distance to the constrained world position
  144008. * @returns the closest point to position constrained by the navigation mesh
  144009. */
  144010. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144011. /**
  144012. * Get a navigation mesh constrained position, within a particular radius
  144013. * @param position world position
  144014. * @param maxRadius the maximum distance to the constrained world position
  144015. * @param result output the closest point to position constrained by the navigation mesh
  144016. */
  144017. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144018. /**
  144019. * Compute the final position from a segment made of destination-position
  144020. * @param position world position
  144021. * @param destination world position
  144022. * @returns the resulting point along the navmesh
  144023. */
  144024. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144025. /**
  144026. * Compute the final position from a segment made of destination-position
  144027. * @param position world position
  144028. * @param destination world position
  144029. * @param result output the resulting point along the navmesh
  144030. */
  144031. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144032. /**
  144033. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144034. * @param start world position
  144035. * @param end world position
  144036. * @returns array containing world position composing the path
  144037. */
  144038. computePath(start: Vector3, end: Vector3): Vector3[];
  144039. /**
  144040. * If this plugin is supported
  144041. * @returns true if plugin is supported
  144042. */
  144043. isSupported(): boolean;
  144044. /**
  144045. * Create a new Crowd so you can add agents
  144046. * @param maxAgents the maximum agent count in the crowd
  144047. * @param maxAgentRadius the maximum radius an agent can have
  144048. * @param scene to attach the crowd to
  144049. * @returns the crowd you can add agents to
  144050. */
  144051. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144052. /**
  144053. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144054. * The queries will try to find a solution within those bounds
  144055. * default is (1,1,1)
  144056. * @param extent x,y,z value that define the extent around the queries point of reference
  144057. */
  144058. setDefaultQueryExtent(extent: Vector3): void;
  144059. /**
  144060. * Get the Bounding box extent specified by setDefaultQueryExtent
  144061. * @returns the box extent values
  144062. */
  144063. getDefaultQueryExtent(): Vector3;
  144064. /**
  144065. * build the navmesh from a previously saved state using getNavmeshData
  144066. * @param data the Uint8Array returned by getNavmeshData
  144067. */
  144068. buildFromNavmeshData(data: Uint8Array): void;
  144069. /**
  144070. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144071. * @returns data the Uint8Array that can be saved and reused
  144072. */
  144073. getNavmeshData(): Uint8Array;
  144074. /**
  144075. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144076. * @param result output the box extent values
  144077. */
  144078. getDefaultQueryExtentToRef(result: Vector3): void;
  144079. /**
  144080. * Release all resources
  144081. */
  144082. dispose(): void;
  144083. }
  144084. /**
  144085. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  144086. */
  144087. export interface ICrowd {
  144088. /**
  144089. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144090. * You can attach anything to that node. The node position is updated in the scene update tick.
  144091. * @param pos world position that will be constrained by the navigation mesh
  144092. * @param parameters agent parameters
  144093. * @param transform hooked to the agent that will be update by the scene
  144094. * @returns agent index
  144095. */
  144096. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144097. /**
  144098. * Returns the agent position in world space
  144099. * @param index agent index returned by addAgent
  144100. * @returns world space position
  144101. */
  144102. getAgentPosition(index: number): Vector3;
  144103. /**
  144104. * Gets the agent position result in world space
  144105. * @param index agent index returned by addAgent
  144106. * @param result output world space position
  144107. */
  144108. getAgentPositionToRef(index: number, result: Vector3): void;
  144109. /**
  144110. * Gets the agent velocity in world space
  144111. * @param index agent index returned by addAgent
  144112. * @returns world space velocity
  144113. */
  144114. getAgentVelocity(index: number): Vector3;
  144115. /**
  144116. * Gets the agent velocity result in world space
  144117. * @param index agent index returned by addAgent
  144118. * @param result output world space velocity
  144119. */
  144120. getAgentVelocityToRef(index: number, result: Vector3): void;
  144121. /**
  144122. * remove a particular agent previously created
  144123. * @param index agent index returned by addAgent
  144124. */
  144125. removeAgent(index: number): void;
  144126. /**
  144127. * get the list of all agents attached to this crowd
  144128. * @returns list of agent indices
  144129. */
  144130. getAgents(): number[];
  144131. /**
  144132. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144133. * @param deltaTime in seconds
  144134. */
  144135. update(deltaTime: number): void;
  144136. /**
  144137. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144138. * @param index agent index returned by addAgent
  144139. * @param destination targeted world position
  144140. */
  144141. agentGoto(index: number, destination: Vector3): void;
  144142. /**
  144143. * Teleport the agent to a new position
  144144. * @param index agent index returned by addAgent
  144145. * @param destination targeted world position
  144146. */
  144147. agentTeleport(index: number, destination: Vector3): void;
  144148. /**
  144149. * Update agent parameters
  144150. * @param index agent index returned by addAgent
  144151. * @param parameters agent parameters
  144152. */
  144153. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144154. /**
  144155. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144156. * The queries will try to find a solution within those bounds
  144157. * default is (1,1,1)
  144158. * @param extent x,y,z value that define the extent around the queries point of reference
  144159. */
  144160. setDefaultQueryExtent(extent: Vector3): void;
  144161. /**
  144162. * Get the Bounding box extent specified by setDefaultQueryExtent
  144163. * @returns the box extent values
  144164. */
  144165. getDefaultQueryExtent(): Vector3;
  144166. /**
  144167. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144168. * @param result output the box extent values
  144169. */
  144170. getDefaultQueryExtentToRef(result: Vector3): void;
  144171. /**
  144172. * Release all resources
  144173. */
  144174. dispose(): void;
  144175. }
  144176. /**
  144177. * Configures an agent
  144178. */
  144179. export interface IAgentParameters {
  144180. /**
  144181. * Agent radius. [Limit: >= 0]
  144182. */
  144183. radius: number;
  144184. /**
  144185. * Agent height. [Limit: > 0]
  144186. */
  144187. height: number;
  144188. /**
  144189. * Maximum allowed acceleration. [Limit: >= 0]
  144190. */
  144191. maxAcceleration: number;
  144192. /**
  144193. * Maximum allowed speed. [Limit: >= 0]
  144194. */
  144195. maxSpeed: number;
  144196. /**
  144197. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  144198. */
  144199. collisionQueryRange: number;
  144200. /**
  144201. * The path visibility optimization range. [Limit: > 0]
  144202. */
  144203. pathOptimizationRange: number;
  144204. /**
  144205. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  144206. */
  144207. separationWeight: number;
  144208. }
  144209. /**
  144210. * Configures the navigation mesh creation
  144211. */
  144212. export interface INavMeshParameters {
  144213. /**
  144214. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  144215. */
  144216. cs: number;
  144217. /**
  144218. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  144219. */
  144220. ch: number;
  144221. /**
  144222. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  144223. */
  144224. walkableSlopeAngle: number;
  144225. /**
  144226. * Minimum floor to 'ceiling' height that will still allow the floor area to
  144227. * be considered walkable. [Limit: >= 3] [Units: vx]
  144228. */
  144229. walkableHeight: number;
  144230. /**
  144231. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  144232. */
  144233. walkableClimb: number;
  144234. /**
  144235. * The distance to erode/shrink the walkable area of the heightfield away from
  144236. * obstructions. [Limit: >=0] [Units: vx]
  144237. */
  144238. walkableRadius: number;
  144239. /**
  144240. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  144241. */
  144242. maxEdgeLen: number;
  144243. /**
  144244. * The maximum distance a simplfied contour's border edges should deviate
  144245. * the original raw contour. [Limit: >=0] [Units: vx]
  144246. */
  144247. maxSimplificationError: number;
  144248. /**
  144249. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  144250. */
  144251. minRegionArea: number;
  144252. /**
  144253. * Any regions with a span count smaller than this value will, if possible,
  144254. * be merged with larger regions. [Limit: >=0] [Units: vx]
  144255. */
  144256. mergeRegionArea: number;
  144257. /**
  144258. * The maximum number of vertices allowed for polygons generated during the
  144259. * contour to polygon conversion process. [Limit: >= 3]
  144260. */
  144261. maxVertsPerPoly: number;
  144262. /**
  144263. * Sets the sampling distance to use when generating the detail mesh.
  144264. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  144265. */
  144266. detailSampleDist: number;
  144267. /**
  144268. * The maximum distance the detail mesh surface should deviate from heightfield
  144269. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  144270. */
  144271. detailSampleMaxError: number;
  144272. }
  144273. }
  144274. declare module BABYLON {
  144275. /**
  144276. * RecastJS navigation plugin
  144277. */
  144278. export class RecastJSPlugin implements INavigationEnginePlugin {
  144279. /**
  144280. * Reference to the Recast library
  144281. */
  144282. bjsRECAST: any;
  144283. /**
  144284. * plugin name
  144285. */
  144286. name: string;
  144287. /**
  144288. * the first navmesh created. We might extend this to support multiple navmeshes
  144289. */
  144290. navMesh: any;
  144291. /**
  144292. * Initializes the recastJS plugin
  144293. * @param recastInjection can be used to inject your own recast reference
  144294. */
  144295. constructor(recastInjection?: any);
  144296. /**
  144297. * Creates a navigation mesh
  144298. * @param meshes array of all the geometry used to compute the navigatio mesh
  144299. * @param parameters bunch of parameters used to filter geometry
  144300. */
  144301. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  144302. /**
  144303. * Create a navigation mesh debug mesh
  144304. * @param scene is where the mesh will be added
  144305. * @returns debug display mesh
  144306. */
  144307. createDebugNavMesh(scene: Scene): Mesh;
  144308. /**
  144309. * Get a navigation mesh constrained position, closest to the parameter position
  144310. * @param position world position
  144311. * @returns the closest point to position constrained by the navigation mesh
  144312. */
  144313. getClosestPoint(position: Vector3): Vector3;
  144314. /**
  144315. * Get a navigation mesh constrained position, closest to the parameter position
  144316. * @param position world position
  144317. * @param result output the closest point to position constrained by the navigation mesh
  144318. */
  144319. getClosestPointToRef(position: Vector3, result: Vector3): void;
  144320. /**
  144321. * Get a navigation mesh constrained position, within a particular radius
  144322. * @param position world position
  144323. * @param maxRadius the maximum distance to the constrained world position
  144324. * @returns the closest point to position constrained by the navigation mesh
  144325. */
  144326. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144327. /**
  144328. * Get a navigation mesh constrained position, within a particular radius
  144329. * @param position world position
  144330. * @param maxRadius the maximum distance to the constrained world position
  144331. * @param result output the closest point to position constrained by the navigation mesh
  144332. */
  144333. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144334. /**
  144335. * Compute the final position from a segment made of destination-position
  144336. * @param position world position
  144337. * @param destination world position
  144338. * @returns the resulting point along the navmesh
  144339. */
  144340. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144341. /**
  144342. * Compute the final position from a segment made of destination-position
  144343. * @param position world position
  144344. * @param destination world position
  144345. * @param result output the resulting point along the navmesh
  144346. */
  144347. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144348. /**
  144349. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144350. * @param start world position
  144351. * @param end world position
  144352. * @returns array containing world position composing the path
  144353. */
  144354. computePath(start: Vector3, end: Vector3): Vector3[];
  144355. /**
  144356. * Create a new Crowd so you can add agents
  144357. * @param maxAgents the maximum agent count in the crowd
  144358. * @param maxAgentRadius the maximum radius an agent can have
  144359. * @param scene to attach the crowd to
  144360. * @returns the crowd you can add agents to
  144361. */
  144362. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144363. /**
  144364. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144365. * The queries will try to find a solution within those bounds
  144366. * default is (1,1,1)
  144367. * @param extent x,y,z value that define the extent around the queries point of reference
  144368. */
  144369. setDefaultQueryExtent(extent: Vector3): void;
  144370. /**
  144371. * Get the Bounding box extent specified by setDefaultQueryExtent
  144372. * @returns the box extent values
  144373. */
  144374. getDefaultQueryExtent(): Vector3;
  144375. /**
  144376. * build the navmesh from a previously saved state using getNavmeshData
  144377. * @param data the Uint8Array returned by getNavmeshData
  144378. */
  144379. buildFromNavmeshData(data: Uint8Array): void;
  144380. /**
  144381. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144382. * @returns data the Uint8Array that can be saved and reused
  144383. */
  144384. getNavmeshData(): Uint8Array;
  144385. /**
  144386. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144387. * @param result output the box extent values
  144388. */
  144389. getDefaultQueryExtentToRef(result: Vector3): void;
  144390. /**
  144391. * Disposes
  144392. */
  144393. dispose(): void;
  144394. /**
  144395. * If this plugin is supported
  144396. * @returns true if plugin is supported
  144397. */
  144398. isSupported(): boolean;
  144399. }
  144400. /**
  144401. * Recast detour crowd implementation
  144402. */
  144403. export class RecastJSCrowd implements ICrowd {
  144404. /**
  144405. * Recast/detour plugin
  144406. */
  144407. bjsRECASTPlugin: RecastJSPlugin;
  144408. /**
  144409. * Link to the detour crowd
  144410. */
  144411. recastCrowd: any;
  144412. /**
  144413. * One transform per agent
  144414. */
  144415. transforms: TransformNode[];
  144416. /**
  144417. * All agents created
  144418. */
  144419. agents: number[];
  144420. /**
  144421. * Link to the scene is kept to unregister the crowd from the scene
  144422. */
  144423. private _scene;
  144424. /**
  144425. * Observer for crowd updates
  144426. */
  144427. private _onBeforeAnimationsObserver;
  144428. /**
  144429. * Constructor
  144430. * @param plugin recastJS plugin
  144431. * @param maxAgents the maximum agent count in the crowd
  144432. * @param maxAgentRadius the maximum radius an agent can have
  144433. * @param scene to attach the crowd to
  144434. * @returns the crowd you can add agents to
  144435. */
  144436. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  144437. /**
  144438. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144439. * You can attach anything to that node. The node position is updated in the scene update tick.
  144440. * @param pos world position that will be constrained by the navigation mesh
  144441. * @param parameters agent parameters
  144442. * @param transform hooked to the agent that will be update by the scene
  144443. * @returns agent index
  144444. */
  144445. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144446. /**
  144447. * Returns the agent position in world space
  144448. * @param index agent index returned by addAgent
  144449. * @returns world space position
  144450. */
  144451. getAgentPosition(index: number): Vector3;
  144452. /**
  144453. * Returns the agent position result in world space
  144454. * @param index agent index returned by addAgent
  144455. * @param result output world space position
  144456. */
  144457. getAgentPositionToRef(index: number, result: Vector3): void;
  144458. /**
  144459. * Returns the agent velocity in world space
  144460. * @param index agent index returned by addAgent
  144461. * @returns world space velocity
  144462. */
  144463. getAgentVelocity(index: number): Vector3;
  144464. /**
  144465. * Returns the agent velocity result in world space
  144466. * @param index agent index returned by addAgent
  144467. * @param result output world space velocity
  144468. */
  144469. getAgentVelocityToRef(index: number, result: Vector3): void;
  144470. /**
  144471. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144472. * @param index agent index returned by addAgent
  144473. * @param destination targeted world position
  144474. */
  144475. agentGoto(index: number, destination: Vector3): void;
  144476. /**
  144477. * Teleport the agent to a new position
  144478. * @param index agent index returned by addAgent
  144479. * @param destination targeted world position
  144480. */
  144481. agentTeleport(index: number, destination: Vector3): void;
  144482. /**
  144483. * Update agent parameters
  144484. * @param index agent index returned by addAgent
  144485. * @param parameters agent parameters
  144486. */
  144487. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144488. /**
  144489. * remove a particular agent previously created
  144490. * @param index agent index returned by addAgent
  144491. */
  144492. removeAgent(index: number): void;
  144493. /**
  144494. * get the list of all agents attached to this crowd
  144495. * @returns list of agent indices
  144496. */
  144497. getAgents(): number[];
  144498. /**
  144499. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144500. * @param deltaTime in seconds
  144501. */
  144502. update(deltaTime: number): void;
  144503. /**
  144504. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144505. * The queries will try to find a solution within those bounds
  144506. * default is (1,1,1)
  144507. * @param extent x,y,z value that define the extent around the queries point of reference
  144508. */
  144509. setDefaultQueryExtent(extent: Vector3): void;
  144510. /**
  144511. * Get the Bounding box extent specified by setDefaultQueryExtent
  144512. * @returns the box extent values
  144513. */
  144514. getDefaultQueryExtent(): Vector3;
  144515. /**
  144516. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144517. * @param result output the box extent values
  144518. */
  144519. getDefaultQueryExtentToRef(result: Vector3): void;
  144520. /**
  144521. * Release all resources
  144522. */
  144523. dispose(): void;
  144524. }
  144525. }
  144526. declare module BABYLON {
  144527. /**
  144528. * Class used to enable access to IndexedDB
  144529. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  144530. */
  144531. export class Database implements IOfflineProvider {
  144532. private _callbackManifestChecked;
  144533. private _currentSceneUrl;
  144534. private _db;
  144535. private _enableSceneOffline;
  144536. private _enableTexturesOffline;
  144537. private _manifestVersionFound;
  144538. private _mustUpdateRessources;
  144539. private _hasReachedQuota;
  144540. private _isSupported;
  144541. private _idbFactory;
  144542. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  144543. private static IsUASupportingBlobStorage;
  144544. /**
  144545. * Gets a boolean indicating if Database storate is enabled (off by default)
  144546. */
  144547. static IDBStorageEnabled: boolean;
  144548. /**
  144549. * Gets a boolean indicating if scene must be saved in the database
  144550. */
  144551. get enableSceneOffline(): boolean;
  144552. /**
  144553. * Gets a boolean indicating if textures must be saved in the database
  144554. */
  144555. get enableTexturesOffline(): boolean;
  144556. /**
  144557. * Creates a new Database
  144558. * @param urlToScene defines the url to load the scene
  144559. * @param callbackManifestChecked defines the callback to use when manifest is checked
  144560. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  144561. */
  144562. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  144563. private static _ParseURL;
  144564. private static _ReturnFullUrlLocation;
  144565. private _checkManifestFile;
  144566. /**
  144567. * Open the database and make it available
  144568. * @param successCallback defines the callback to call on success
  144569. * @param errorCallback defines the callback to call on error
  144570. */
  144571. open(successCallback: () => void, errorCallback: () => void): void;
  144572. /**
  144573. * Loads an image from the database
  144574. * @param url defines the url to load from
  144575. * @param image defines the target DOM image
  144576. */
  144577. loadImage(url: string, image: HTMLImageElement): void;
  144578. private _loadImageFromDBAsync;
  144579. private _saveImageIntoDBAsync;
  144580. private _checkVersionFromDB;
  144581. private _loadVersionFromDBAsync;
  144582. private _saveVersionIntoDBAsync;
  144583. /**
  144584. * Loads a file from database
  144585. * @param url defines the URL to load from
  144586. * @param sceneLoaded defines a callback to call on success
  144587. * @param progressCallBack defines a callback to call when progress changed
  144588. * @param errorCallback defines a callback to call on error
  144589. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  144590. */
  144591. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  144592. private _loadFileAsync;
  144593. private _saveFileAsync;
  144594. /**
  144595. * Validates if xhr data is correct
  144596. * @param xhr defines the request to validate
  144597. * @param dataType defines the expected data type
  144598. * @returns true if data is correct
  144599. */
  144600. private static _ValidateXHRData;
  144601. }
  144602. }
  144603. declare module BABYLON {
  144604. /** @hidden */
  144605. export var gpuUpdateParticlesPixelShader: {
  144606. name: string;
  144607. shader: string;
  144608. };
  144609. }
  144610. declare module BABYLON {
  144611. /** @hidden */
  144612. export var gpuUpdateParticlesVertexShader: {
  144613. name: string;
  144614. shader: string;
  144615. };
  144616. }
  144617. declare module BABYLON {
  144618. /** @hidden */
  144619. export var clipPlaneFragmentDeclaration2: {
  144620. name: string;
  144621. shader: string;
  144622. };
  144623. }
  144624. declare module BABYLON {
  144625. /** @hidden */
  144626. export var gpuRenderParticlesPixelShader: {
  144627. name: string;
  144628. shader: string;
  144629. };
  144630. }
  144631. declare module BABYLON {
  144632. /** @hidden */
  144633. export var clipPlaneVertexDeclaration2: {
  144634. name: string;
  144635. shader: string;
  144636. };
  144637. }
  144638. declare module BABYLON {
  144639. /** @hidden */
  144640. export var gpuRenderParticlesVertexShader: {
  144641. name: string;
  144642. shader: string;
  144643. };
  144644. }
  144645. declare module BABYLON {
  144646. /**
  144647. * This represents a GPU particle system in Babylon
  144648. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  144649. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  144650. */
  144651. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  144652. /**
  144653. * The layer mask we are rendering the particles through.
  144654. */
  144655. layerMask: number;
  144656. private _capacity;
  144657. private _activeCount;
  144658. private _currentActiveCount;
  144659. private _accumulatedCount;
  144660. private _renderEffect;
  144661. private _updateEffect;
  144662. private _buffer0;
  144663. private _buffer1;
  144664. private _spriteBuffer;
  144665. private _updateVAO;
  144666. private _renderVAO;
  144667. private _targetIndex;
  144668. private _sourceBuffer;
  144669. private _targetBuffer;
  144670. private _engine;
  144671. private _currentRenderId;
  144672. private _started;
  144673. private _stopped;
  144674. private _timeDelta;
  144675. private _randomTexture;
  144676. private _randomTexture2;
  144677. private _attributesStrideSize;
  144678. private _updateEffectOptions;
  144679. private _randomTextureSize;
  144680. private _actualFrame;
  144681. private _customEffect;
  144682. private readonly _rawTextureWidth;
  144683. /**
  144684. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  144685. */
  144686. static get IsSupported(): boolean;
  144687. /**
  144688. * An event triggered when the system is disposed.
  144689. */
  144690. onDisposeObservable: Observable<IParticleSystem>;
  144691. /**
  144692. * Gets the maximum number of particles active at the same time.
  144693. * @returns The max number of active particles.
  144694. */
  144695. getCapacity(): number;
  144696. /**
  144697. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  144698. * to override the particles.
  144699. */
  144700. forceDepthWrite: boolean;
  144701. /**
  144702. * Gets or set the number of active particles
  144703. */
  144704. get activeParticleCount(): number;
  144705. set activeParticleCount(value: number);
  144706. private _preWarmDone;
  144707. /**
  144708. * Specifies if the particles are updated in emitter local space or world space.
  144709. */
  144710. isLocal: boolean;
  144711. /**
  144712. * Is this system ready to be used/rendered
  144713. * @return true if the system is ready
  144714. */
  144715. isReady(): boolean;
  144716. /**
  144717. * Gets if the system has been started. (Note: this will still be true after stop is called)
  144718. * @returns True if it has been started, otherwise false.
  144719. */
  144720. isStarted(): boolean;
  144721. /**
  144722. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  144723. * @returns True if it has been stopped, otherwise false.
  144724. */
  144725. isStopped(): boolean;
  144726. /**
  144727. * Gets a boolean indicating that the system is stopping
  144728. * @returns true if the system is currently stopping
  144729. */
  144730. isStopping(): boolean;
  144731. /**
  144732. * Gets the number of particles active at the same time.
  144733. * @returns The number of active particles.
  144734. */
  144735. getActiveCount(): number;
  144736. /**
  144737. * Starts the particle system and begins to emit
  144738. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  144739. */
  144740. start(delay?: number): void;
  144741. /**
  144742. * Stops the particle system.
  144743. */
  144744. stop(): void;
  144745. /**
  144746. * Remove all active particles
  144747. */
  144748. reset(): void;
  144749. /**
  144750. * Returns the string "GPUParticleSystem"
  144751. * @returns a string containing the class name
  144752. */
  144753. getClassName(): string;
  144754. /**
  144755. * Gets the custom effect used to render the particles
  144756. * @param blendMode Blend mode for which the effect should be retrieved
  144757. * @returns The effect
  144758. */
  144759. getCustomEffect(blendMode?: number): Nullable<Effect>;
  144760. /**
  144761. * Sets the custom effect used to render the particles
  144762. * @param effect The effect to set
  144763. * @param blendMode Blend mode for which the effect should be set
  144764. */
  144765. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  144766. /** @hidden */
  144767. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  144768. /**
  144769. * Observable that will be called just before the particles are drawn
  144770. */
  144771. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  144772. /**
  144773. * Gets the name of the particle vertex shader
  144774. */
  144775. get vertexShaderName(): string;
  144776. private _colorGradientsTexture;
  144777. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  144778. /**
  144779. * Adds a new color gradient
  144780. * @param gradient defines the gradient to use (between 0 and 1)
  144781. * @param color1 defines the color to affect to the specified gradient
  144782. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  144783. * @returns the current particle system
  144784. */
  144785. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  144786. private _refreshColorGradient;
  144787. /** Force the system to rebuild all gradients that need to be resync */
  144788. forceRefreshGradients(): void;
  144789. /**
  144790. * Remove a specific color gradient
  144791. * @param gradient defines the gradient to remove
  144792. * @returns the current particle system
  144793. */
  144794. removeColorGradient(gradient: number): GPUParticleSystem;
  144795. private _angularSpeedGradientsTexture;
  144796. private _sizeGradientsTexture;
  144797. private _velocityGradientsTexture;
  144798. private _limitVelocityGradientsTexture;
  144799. private _dragGradientsTexture;
  144800. private _addFactorGradient;
  144801. /**
  144802. * Adds a new size gradient
  144803. * @param gradient defines the gradient to use (between 0 and 1)
  144804. * @param factor defines the size factor to affect to the specified gradient
  144805. * @returns the current particle system
  144806. */
  144807. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  144808. /**
  144809. * Remove a specific size gradient
  144810. * @param gradient defines the gradient to remove
  144811. * @returns the current particle system
  144812. */
  144813. removeSizeGradient(gradient: number): GPUParticleSystem;
  144814. private _refreshFactorGradient;
  144815. /**
  144816. * Adds a new angular speed gradient
  144817. * @param gradient defines the gradient to use (between 0 and 1)
  144818. * @param factor defines the angular speed to affect to the specified gradient
  144819. * @returns the current particle system
  144820. */
  144821. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  144822. /**
  144823. * Remove a specific angular speed gradient
  144824. * @param gradient defines the gradient to remove
  144825. * @returns the current particle system
  144826. */
  144827. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  144828. /**
  144829. * Adds a new velocity gradient
  144830. * @param gradient defines the gradient to use (between 0 and 1)
  144831. * @param factor defines the velocity to affect to the specified gradient
  144832. * @returns the current particle system
  144833. */
  144834. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144835. /**
  144836. * Remove a specific velocity gradient
  144837. * @param gradient defines the gradient to remove
  144838. * @returns the current particle system
  144839. */
  144840. removeVelocityGradient(gradient: number): GPUParticleSystem;
  144841. /**
  144842. * Adds a new limit velocity gradient
  144843. * @param gradient defines the gradient to use (between 0 and 1)
  144844. * @param factor defines the limit velocity value to affect to the specified gradient
  144845. * @returns the current particle system
  144846. */
  144847. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144848. /**
  144849. * Remove a specific limit velocity gradient
  144850. * @param gradient defines the gradient to remove
  144851. * @returns the current particle system
  144852. */
  144853. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  144854. /**
  144855. * Adds a new drag gradient
  144856. * @param gradient defines the gradient to use (between 0 and 1)
  144857. * @param factor defines the drag value to affect to the specified gradient
  144858. * @returns the current particle system
  144859. */
  144860. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  144861. /**
  144862. * Remove a specific drag gradient
  144863. * @param gradient defines the gradient to remove
  144864. * @returns the current particle system
  144865. */
  144866. removeDragGradient(gradient: number): GPUParticleSystem;
  144867. /**
  144868. * Not supported by GPUParticleSystem
  144869. * @param gradient defines the gradient to use (between 0 and 1)
  144870. * @param factor defines the emit rate value to affect to the specified gradient
  144871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144872. * @returns the current particle system
  144873. */
  144874. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144875. /**
  144876. * Not supported by GPUParticleSystem
  144877. * @param gradient defines the gradient to remove
  144878. * @returns the current particle system
  144879. */
  144880. removeEmitRateGradient(gradient: number): IParticleSystem;
  144881. /**
  144882. * Not supported by GPUParticleSystem
  144883. * @param gradient defines the gradient to use (between 0 and 1)
  144884. * @param factor defines the start size value to affect to the specified gradient
  144885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144886. * @returns the current particle system
  144887. */
  144888. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144889. /**
  144890. * Not supported by GPUParticleSystem
  144891. * @param gradient defines the gradient to remove
  144892. * @returns the current particle system
  144893. */
  144894. removeStartSizeGradient(gradient: number): IParticleSystem;
  144895. /**
  144896. * Not supported by GPUParticleSystem
  144897. * @param gradient defines the gradient to use (between 0 and 1)
  144898. * @param min defines the color remap minimal range
  144899. * @param max defines the color remap maximal range
  144900. * @returns the current particle system
  144901. */
  144902. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144903. /**
  144904. * Not supported by GPUParticleSystem
  144905. * @param gradient defines the gradient to remove
  144906. * @returns the current particle system
  144907. */
  144908. removeColorRemapGradient(): IParticleSystem;
  144909. /**
  144910. * Not supported by GPUParticleSystem
  144911. * @param gradient defines the gradient to use (between 0 and 1)
  144912. * @param min defines the alpha remap minimal range
  144913. * @param max defines the alpha remap maximal range
  144914. * @returns the current particle system
  144915. */
  144916. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144917. /**
  144918. * Not supported by GPUParticleSystem
  144919. * @param gradient defines the gradient to remove
  144920. * @returns the current particle system
  144921. */
  144922. removeAlphaRemapGradient(): IParticleSystem;
  144923. /**
  144924. * Not supported by GPUParticleSystem
  144925. * @param gradient defines the gradient to use (between 0 and 1)
  144926. * @param color defines the color to affect to the specified gradient
  144927. * @returns the current particle system
  144928. */
  144929. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  144930. /**
  144931. * Not supported by GPUParticleSystem
  144932. * @param gradient defines the gradient to remove
  144933. * @returns the current particle system
  144934. */
  144935. removeRampGradient(): IParticleSystem;
  144936. /**
  144937. * Not supported by GPUParticleSystem
  144938. * @returns the list of ramp gradients
  144939. */
  144940. getRampGradients(): Nullable<Array<Color3Gradient>>;
  144941. /**
  144942. * Not supported by GPUParticleSystem
  144943. * Gets or sets a boolean indicating that ramp gradients must be used
  144944. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  144945. */
  144946. get useRampGradients(): boolean;
  144947. set useRampGradients(value: boolean);
  144948. /**
  144949. * Not supported by GPUParticleSystem
  144950. * @param gradient defines the gradient to use (between 0 and 1)
  144951. * @param factor defines the life time factor to affect to the specified gradient
  144952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144953. * @returns the current particle system
  144954. */
  144955. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144956. /**
  144957. * Not supported by GPUParticleSystem
  144958. * @param gradient defines the gradient to remove
  144959. * @returns the current particle system
  144960. */
  144961. removeLifeTimeGradient(gradient: number): IParticleSystem;
  144962. /**
  144963. * Instantiates a GPU particle system.
  144964. * 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.
  144965. * @param name The name of the particle system
  144966. * @param options The options used to create the system
  144967. * @param scene The scene the particle system belongs to
  144968. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  144969. * @param customEffect a custom effect used to change the way particles are rendered by default
  144970. */
  144971. constructor(name: string, options: Partial<{
  144972. capacity: number;
  144973. randomTextureSize: number;
  144974. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  144975. protected _reset(): void;
  144976. private _createUpdateVAO;
  144977. private _createRenderVAO;
  144978. private _initialize;
  144979. /** @hidden */
  144980. _recreateUpdateEffect(): void;
  144981. private _getEffect;
  144982. /**
  144983. * Fill the defines array according to the current settings of the particle system
  144984. * @param defines Array to be updated
  144985. * @param blendMode blend mode to take into account when updating the array
  144986. */
  144987. fillDefines(defines: Array<string>, blendMode?: number): void;
  144988. /**
  144989. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  144990. * @param uniforms Uniforms array to fill
  144991. * @param attributes Attributes array to fill
  144992. * @param samplers Samplers array to fill
  144993. */
  144994. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  144995. /** @hidden */
  144996. _recreateRenderEffect(): Effect;
  144997. /**
  144998. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  144999. * @param preWarm defines if we are in the pre-warmimg phase
  145000. */
  145001. animate(preWarm?: boolean): void;
  145002. private _createFactorGradientTexture;
  145003. private _createSizeGradientTexture;
  145004. private _createAngularSpeedGradientTexture;
  145005. private _createVelocityGradientTexture;
  145006. private _createLimitVelocityGradientTexture;
  145007. private _createDragGradientTexture;
  145008. private _createColorGradientTexture;
  145009. /**
  145010. * Renders the particle system in its current state
  145011. * @param preWarm defines if the system should only update the particles but not render them
  145012. * @returns the current number of particles
  145013. */
  145014. render(preWarm?: boolean): number;
  145015. /**
  145016. * Rebuilds the particle system
  145017. */
  145018. rebuild(): void;
  145019. private _releaseBuffers;
  145020. private _releaseVAOs;
  145021. /**
  145022. * Disposes the particle system and free the associated resources
  145023. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  145024. */
  145025. dispose(disposeTexture?: boolean): void;
  145026. /**
  145027. * Clones the particle system.
  145028. * @param name The name of the cloned object
  145029. * @param newEmitter The new emitter to use
  145030. * @returns the cloned particle system
  145031. */
  145032. clone(name: string, newEmitter: any): GPUParticleSystem;
  145033. /**
  145034. * Serializes the particle system to a JSON object
  145035. * @param serializeTexture defines if the texture must be serialized as well
  145036. * @returns the JSON object
  145037. */
  145038. serialize(serializeTexture?: boolean): any;
  145039. /**
  145040. * Parses a JSON object to create a GPU particle system.
  145041. * @param parsedParticleSystem The JSON object to parse
  145042. * @param scene The scene to create the particle system in
  145043. * @param rootUrl The root url to use to load external dependencies like texture
  145044. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  145045. * @returns the parsed GPU particle system
  145046. */
  145047. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  145048. }
  145049. }
  145050. declare module BABYLON {
  145051. /**
  145052. * Represents a set of particle systems working together to create a specific effect
  145053. */
  145054. export class ParticleSystemSet implements IDisposable {
  145055. /**
  145056. * Gets or sets base Assets URL
  145057. */
  145058. static BaseAssetsUrl: string;
  145059. private _emitterCreationOptions;
  145060. private _emitterNode;
  145061. /**
  145062. * Gets the particle system list
  145063. */
  145064. systems: IParticleSystem[];
  145065. /**
  145066. * Gets the emitter node used with this set
  145067. */
  145068. get emitterNode(): Nullable<TransformNode>;
  145069. /**
  145070. * Creates a new emitter mesh as a sphere
  145071. * @param options defines the options used to create the sphere
  145072. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  145073. * @param scene defines the hosting scene
  145074. */
  145075. setEmitterAsSphere(options: {
  145076. diameter: number;
  145077. segments: number;
  145078. color: Color3;
  145079. }, renderingGroupId: number, scene: Scene): void;
  145080. /**
  145081. * Starts all particle systems of the set
  145082. * @param emitter defines an optional mesh to use as emitter for the particle systems
  145083. */
  145084. start(emitter?: AbstractMesh): void;
  145085. /**
  145086. * Release all associated resources
  145087. */
  145088. dispose(): void;
  145089. /**
  145090. * Serialize the set into a JSON compatible object
  145091. * @param serializeTexture defines if the texture must be serialized as well
  145092. * @returns a JSON compatible representation of the set
  145093. */
  145094. serialize(serializeTexture?: boolean): any;
  145095. /**
  145096. * Parse a new ParticleSystemSet from a serialized source
  145097. * @param data defines a JSON compatible representation of the set
  145098. * @param scene defines the hosting scene
  145099. * @param gpu defines if we want GPU particles or CPU particles
  145100. * @returns a new ParticleSystemSet
  145101. */
  145102. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  145103. }
  145104. }
  145105. declare module BABYLON {
  145106. /**
  145107. * This class is made for on one-liner static method to help creating particle system set.
  145108. */
  145109. export class ParticleHelper {
  145110. /**
  145111. * Gets or sets base Assets URL
  145112. */
  145113. static BaseAssetsUrl: string;
  145114. /** Define the Url to load snippets */
  145115. static SnippetUrl: string;
  145116. /**
  145117. * Create a default particle system that you can tweak
  145118. * @param emitter defines the emitter to use
  145119. * @param capacity defines the system capacity (default is 500 particles)
  145120. * @param scene defines the hosting scene
  145121. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  145122. * @returns the new Particle system
  145123. */
  145124. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  145125. /**
  145126. * This is the main static method (one-liner) of this helper to create different particle systems
  145127. * @param type This string represents the type to the particle system to create
  145128. * @param scene The scene where the particle system should live
  145129. * @param gpu If the system will use gpu
  145130. * @returns the ParticleSystemSet created
  145131. */
  145132. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  145133. /**
  145134. * Static function used to export a particle system to a ParticleSystemSet variable.
  145135. * Please note that the emitter shape is not exported
  145136. * @param systems defines the particle systems to export
  145137. * @returns the created particle system set
  145138. */
  145139. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  145140. /**
  145141. * Creates a particle system from a snippet saved in a remote file
  145142. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  145143. * @param url defines the url to load from
  145144. * @param scene defines the hosting scene
  145145. * @param gpu If the system will use gpu
  145146. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145147. * @returns a promise that will resolve to the new particle system
  145148. */
  145149. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145150. /**
  145151. * Creates a particle system from a snippet saved by the particle system editor
  145152. * @param snippetId defines the snippet to load
  145153. * @param scene defines the hosting scene
  145154. * @param gpu If the system will use gpu
  145155. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145156. * @returns a promise that will resolve to the new particle system
  145157. */
  145158. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145159. }
  145160. }
  145161. declare module BABYLON {
  145162. interface Engine {
  145163. /**
  145164. * Create an effect to use with particle systems.
  145165. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  145166. * the particle system for which you want to create a custom effect in the last parameter
  145167. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  145168. * @param uniformsNames defines a list of attribute names
  145169. * @param samplers defines an array of string used to represent textures
  145170. * @param defines defines the string containing the defines to use to compile the shaders
  145171. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  145172. * @param onCompiled defines a function to call when the effect creation is successful
  145173. * @param onError defines a function to call when the effect creation has failed
  145174. * @param particleSystem the particle system you want to create the effect for
  145175. * @returns the new Effect
  145176. */
  145177. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  145178. }
  145179. interface Mesh {
  145180. /**
  145181. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  145182. * @returns an array of IParticleSystem
  145183. */
  145184. getEmittedParticleSystems(): IParticleSystem[];
  145185. /**
  145186. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  145187. * @returns an array of IParticleSystem
  145188. */
  145189. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  145190. }
  145191. }
  145192. declare module BABYLON {
  145193. /** Defines the 4 color options */
  145194. export enum PointColor {
  145195. /** color value */
  145196. Color = 2,
  145197. /** uv value */
  145198. UV = 1,
  145199. /** random value */
  145200. Random = 0,
  145201. /** stated value */
  145202. Stated = 3
  145203. }
  145204. /**
  145205. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  145206. * 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.
  145207. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  145208. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  145209. *
  145210. * Full documentation here : TO BE ENTERED
  145211. */
  145212. export class PointsCloudSystem implements IDisposable {
  145213. /**
  145214. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  145215. * Example : var p = SPS.particles[i];
  145216. */
  145217. particles: CloudPoint[];
  145218. /**
  145219. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  145220. */
  145221. nbParticles: number;
  145222. /**
  145223. * This a counter for your own usage. It's not set by any SPS functions.
  145224. */
  145225. counter: number;
  145226. /**
  145227. * The PCS name. This name is also given to the underlying mesh.
  145228. */
  145229. name: string;
  145230. /**
  145231. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  145232. */
  145233. mesh: Mesh;
  145234. /**
  145235. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  145236. * Please read :
  145237. */
  145238. vars: any;
  145239. /**
  145240. * @hidden
  145241. */
  145242. _size: number;
  145243. private _scene;
  145244. private _promises;
  145245. private _positions;
  145246. private _indices;
  145247. private _normals;
  145248. private _colors;
  145249. private _uvs;
  145250. private _indices32;
  145251. private _positions32;
  145252. private _colors32;
  145253. private _uvs32;
  145254. private _updatable;
  145255. private _isVisibilityBoxLocked;
  145256. private _alwaysVisible;
  145257. private _groups;
  145258. private _groupCounter;
  145259. private _computeParticleColor;
  145260. private _computeParticleTexture;
  145261. private _computeParticleRotation;
  145262. private _computeBoundingBox;
  145263. private _isReady;
  145264. /**
  145265. * Creates a PCS (Points Cloud System) object
  145266. * @param name (String) is the PCS name, this will be the underlying mesh name
  145267. * @param pointSize (number) is the size for each point
  145268. * @param scene (Scene) is the scene in which the PCS is added
  145269. * @param options defines the options of the PCS e.g.
  145270. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  145271. */
  145272. constructor(name: string, pointSize: number, scene: Scene, options?: {
  145273. updatable?: boolean;
  145274. });
  145275. /**
  145276. * Builds the PCS underlying mesh. Returns a standard Mesh.
  145277. * If no points were added to the PCS, the returned mesh is just a single point.
  145278. * @returns a promise for the created mesh
  145279. */
  145280. buildMeshAsync(): Promise<Mesh>;
  145281. /**
  145282. * @hidden
  145283. */
  145284. private _buildMesh;
  145285. private _addParticle;
  145286. private _randomUnitVector;
  145287. private _getColorIndicesForCoord;
  145288. private _setPointsColorOrUV;
  145289. private _colorFromTexture;
  145290. private _calculateDensity;
  145291. /**
  145292. * Adds points to the PCS in random positions within a unit sphere
  145293. * @param nb (positive integer) the number of particles to be created from this model
  145294. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  145295. * @returns the number of groups in the system
  145296. */
  145297. addPoints(nb: number, pointFunction?: any): number;
  145298. /**
  145299. * Adds points to the PCS from the surface of the model shape
  145300. * @param mesh is any Mesh object that will be used as a surface model for the points
  145301. * @param nb (positive integer) the number of particles to be created from this model
  145302. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  145303. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  145304. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  145305. * @returns the number of groups in the system
  145306. */
  145307. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  145308. /**
  145309. * Adds points to the PCS inside the model shape
  145310. * @param mesh is any Mesh object that will be used as a surface model for the points
  145311. * @param nb (positive integer) the number of particles to be created from this model
  145312. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  145313. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  145314. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  145315. * @returns the number of groups in the system
  145316. */
  145317. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  145318. /**
  145319. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  145320. * This method calls `updateParticle()` for each particle of the SPS.
  145321. * For an animated SPS, it is usually called within the render loop.
  145322. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  145323. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  145324. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  145325. * @returns the PCS.
  145326. */
  145327. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  145328. /**
  145329. * Disposes the PCS.
  145330. */
  145331. dispose(): void;
  145332. /**
  145333. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  145334. * doc :
  145335. * @returns the PCS.
  145336. */
  145337. refreshVisibleSize(): PointsCloudSystem;
  145338. /**
  145339. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  145340. * @param size the size (float) of the visibility box
  145341. * note : this doesn't lock the PCS mesh bounding box.
  145342. * doc :
  145343. */
  145344. setVisibilityBox(size: number): void;
  145345. /**
  145346. * Gets whether the PCS is always visible or not
  145347. * doc :
  145348. */
  145349. get isAlwaysVisible(): boolean;
  145350. /**
  145351. * Sets the PCS as always visible or not
  145352. * doc :
  145353. */
  145354. set isAlwaysVisible(val: boolean);
  145355. /**
  145356. * Tells to `setParticles()` to compute the particle rotations or not
  145357. * Default value : false. The PCS is faster when it's set to false
  145358. * Note : particle rotations are only applied to parent particles
  145359. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  145360. */
  145361. set computeParticleRotation(val: boolean);
  145362. /**
  145363. * Tells to `setParticles()` to compute the particle colors or not.
  145364. * Default value : true. The PCS is faster when it's set to false.
  145365. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  145366. */
  145367. set computeParticleColor(val: boolean);
  145368. set computeParticleTexture(val: boolean);
  145369. /**
  145370. * Gets if `setParticles()` computes the particle colors or not.
  145371. * Default value : false. The PCS is faster when it's set to false.
  145372. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  145373. */
  145374. get computeParticleColor(): boolean;
  145375. /**
  145376. * Gets if `setParticles()` computes the particle textures or not.
  145377. * Default value : false. The PCS is faster when it's set to false.
  145378. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  145379. */
  145380. get computeParticleTexture(): boolean;
  145381. /**
  145382. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  145383. */
  145384. set computeBoundingBox(val: boolean);
  145385. /**
  145386. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  145387. */
  145388. get computeBoundingBox(): boolean;
  145389. /**
  145390. * This function does nothing. It may be overwritten to set all the particle first values.
  145391. * The PCS doesn't call this function, you may have to call it by your own.
  145392. * doc :
  145393. */
  145394. initParticles(): void;
  145395. /**
  145396. * This function does nothing. It may be overwritten to recycle a particle
  145397. * The PCS doesn't call this function, you can to call it
  145398. * doc :
  145399. * @param particle The particle to recycle
  145400. * @returns the recycled particle
  145401. */
  145402. recycleParticle(particle: CloudPoint): CloudPoint;
  145403. /**
  145404. * Updates a particle : this function should be overwritten by the user.
  145405. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  145406. * doc :
  145407. * @example : just set a particle position or velocity and recycle conditions
  145408. * @param particle The particle to update
  145409. * @returns the updated particle
  145410. */
  145411. updateParticle(particle: CloudPoint): CloudPoint;
  145412. /**
  145413. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  145414. * This does nothing and may be overwritten by the user.
  145415. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  145416. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  145417. * @param update the boolean update value actually passed to setParticles()
  145418. */
  145419. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  145420. /**
  145421. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  145422. * This will be passed three parameters.
  145423. * This does nothing and may be overwritten by the user.
  145424. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  145425. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  145426. * @param update the boolean update value actually passed to setParticles()
  145427. */
  145428. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  145429. }
  145430. }
  145431. declare module BABYLON {
  145432. /**
  145433. * Represents one particle of a points cloud system.
  145434. */
  145435. export class CloudPoint {
  145436. /**
  145437. * particle global index
  145438. */
  145439. idx: number;
  145440. /**
  145441. * The color of the particle
  145442. */
  145443. color: Nullable<Color4>;
  145444. /**
  145445. * The world space position of the particle.
  145446. */
  145447. position: Vector3;
  145448. /**
  145449. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  145450. */
  145451. rotation: Vector3;
  145452. /**
  145453. * The world space rotation quaternion of the particle.
  145454. */
  145455. rotationQuaternion: Nullable<Quaternion>;
  145456. /**
  145457. * The uv of the particle.
  145458. */
  145459. uv: Nullable<Vector2>;
  145460. /**
  145461. * The current speed of the particle.
  145462. */
  145463. velocity: Vector3;
  145464. /**
  145465. * The pivot point in the particle local space.
  145466. */
  145467. pivot: Vector3;
  145468. /**
  145469. * Must the particle be translated from its pivot point in its local space ?
  145470. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  145471. * Default : false
  145472. */
  145473. translateFromPivot: boolean;
  145474. /**
  145475. * Index of this particle in the global "positions" array (Internal use)
  145476. * @hidden
  145477. */
  145478. _pos: number;
  145479. /**
  145480. * @hidden Index of this particle in the global "indices" array (Internal use)
  145481. */
  145482. _ind: number;
  145483. /**
  145484. * Group this particle belongs to
  145485. */
  145486. _group: PointsGroup;
  145487. /**
  145488. * Group id of this particle
  145489. */
  145490. groupId: number;
  145491. /**
  145492. * Index of the particle in its group id (Internal use)
  145493. */
  145494. idxInGroup: number;
  145495. /**
  145496. * @hidden Particle BoundingInfo object (Internal use)
  145497. */
  145498. _boundingInfo: BoundingInfo;
  145499. /**
  145500. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  145501. */
  145502. _pcs: PointsCloudSystem;
  145503. /**
  145504. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  145505. */
  145506. _stillInvisible: boolean;
  145507. /**
  145508. * @hidden Last computed particle rotation matrix
  145509. */
  145510. _rotationMatrix: number[];
  145511. /**
  145512. * Parent particle Id, if any.
  145513. * Default null.
  145514. */
  145515. parentId: Nullable<number>;
  145516. /**
  145517. * @hidden Internal global position in the PCS.
  145518. */
  145519. _globalPosition: Vector3;
  145520. /**
  145521. * Creates a Point Cloud object.
  145522. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  145523. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  145524. * @param group (PointsGroup) is the group the particle belongs to
  145525. * @param groupId (integer) is the group identifier in the PCS.
  145526. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  145527. * @param pcs defines the PCS it is associated to
  145528. */
  145529. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  145530. /**
  145531. * get point size
  145532. */
  145533. get size(): Vector3;
  145534. /**
  145535. * Set point size
  145536. */
  145537. set size(scale: Vector3);
  145538. /**
  145539. * Legacy support, changed quaternion to rotationQuaternion
  145540. */
  145541. get quaternion(): Nullable<Quaternion>;
  145542. /**
  145543. * Legacy support, changed quaternion to rotationQuaternion
  145544. */
  145545. set quaternion(q: Nullable<Quaternion>);
  145546. /**
  145547. * Returns a boolean. True if the particle intersects a mesh, else false
  145548. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  145549. * @param target is the object (point or mesh) what the intersection is computed against
  145550. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  145551. * @returns true if it intersects
  145552. */
  145553. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  145554. /**
  145555. * get the rotation matrix of the particle
  145556. * @hidden
  145557. */
  145558. getRotationMatrix(m: Matrix): void;
  145559. }
  145560. /**
  145561. * Represents a group of points in a points cloud system
  145562. * * PCS internal tool, don't use it manually.
  145563. */
  145564. export class PointsGroup {
  145565. /**
  145566. * The group id
  145567. * @hidden
  145568. */
  145569. groupID: number;
  145570. /**
  145571. * image data for group (internal use)
  145572. * @hidden
  145573. */
  145574. _groupImageData: Nullable<ArrayBufferView>;
  145575. /**
  145576. * Image Width (internal use)
  145577. * @hidden
  145578. */
  145579. _groupImgWidth: number;
  145580. /**
  145581. * Image Height (internal use)
  145582. * @hidden
  145583. */
  145584. _groupImgHeight: number;
  145585. /**
  145586. * Custom position function (internal use)
  145587. * @hidden
  145588. */
  145589. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  145590. /**
  145591. * density per facet for surface points
  145592. * @hidden
  145593. */
  145594. _groupDensity: number[];
  145595. /**
  145596. * Only when points are colored by texture carries pointer to texture list array
  145597. * @hidden
  145598. */
  145599. _textureNb: number;
  145600. /**
  145601. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  145602. * PCS internal tool, don't use it manually.
  145603. * @hidden
  145604. */
  145605. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  145606. }
  145607. }
  145608. declare module BABYLON {
  145609. interface Scene {
  145610. /** @hidden (Backing field) */
  145611. _physicsEngine: Nullable<IPhysicsEngine>;
  145612. /** @hidden */
  145613. _physicsTimeAccumulator: number;
  145614. /**
  145615. * Gets the current physics engine
  145616. * @returns a IPhysicsEngine or null if none attached
  145617. */
  145618. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  145619. /**
  145620. * Enables physics to the current scene
  145621. * @param gravity defines the scene's gravity for the physics engine
  145622. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  145623. * @return a boolean indicating if the physics engine was initialized
  145624. */
  145625. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  145626. /**
  145627. * Disables and disposes the physics engine associated with the scene
  145628. */
  145629. disablePhysicsEngine(): void;
  145630. /**
  145631. * Gets a boolean indicating if there is an active physics engine
  145632. * @returns a boolean indicating if there is an active physics engine
  145633. */
  145634. isPhysicsEnabled(): boolean;
  145635. /**
  145636. * Deletes a physics compound impostor
  145637. * @param compound defines the compound to delete
  145638. */
  145639. deleteCompoundImpostor(compound: any): void;
  145640. /**
  145641. * An event triggered when physic simulation is about to be run
  145642. */
  145643. onBeforePhysicsObservable: Observable<Scene>;
  145644. /**
  145645. * An event triggered when physic simulation has been done
  145646. */
  145647. onAfterPhysicsObservable: Observable<Scene>;
  145648. }
  145649. interface AbstractMesh {
  145650. /** @hidden */
  145651. _physicsImpostor: Nullable<PhysicsImpostor>;
  145652. /**
  145653. * Gets or sets impostor used for physic simulation
  145654. * @see https://doc.babylonjs.com/features/physics_engine
  145655. */
  145656. physicsImpostor: Nullable<PhysicsImpostor>;
  145657. /**
  145658. * Gets the current physics impostor
  145659. * @see https://doc.babylonjs.com/features/physics_engine
  145660. * @returns a physics impostor or null
  145661. */
  145662. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  145663. /** Apply a physic impulse to the mesh
  145664. * @param force defines the force to apply
  145665. * @param contactPoint defines where to apply the force
  145666. * @returns the current mesh
  145667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  145668. */
  145669. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  145670. /**
  145671. * Creates a physic joint between two meshes
  145672. * @param otherMesh defines the other mesh to use
  145673. * @param pivot1 defines the pivot to use on this mesh
  145674. * @param pivot2 defines the pivot to use on the other mesh
  145675. * @param options defines additional options (can be plugin dependent)
  145676. * @returns the current mesh
  145677. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  145678. */
  145679. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  145680. /** @hidden */
  145681. _disposePhysicsObserver: Nullable<Observer<Node>>;
  145682. }
  145683. /**
  145684. * Defines the physics engine scene component responsible to manage a physics engine
  145685. */
  145686. export class PhysicsEngineSceneComponent implements ISceneComponent {
  145687. /**
  145688. * The component name helpful to identify the component in the list of scene components.
  145689. */
  145690. readonly name: string;
  145691. /**
  145692. * The scene the component belongs to.
  145693. */
  145694. scene: Scene;
  145695. /**
  145696. * Creates a new instance of the component for the given scene
  145697. * @param scene Defines the scene to register the component in
  145698. */
  145699. constructor(scene: Scene);
  145700. /**
  145701. * Registers the component in a given scene
  145702. */
  145703. register(): void;
  145704. /**
  145705. * Rebuilds the elements related to this component in case of
  145706. * context lost for instance.
  145707. */
  145708. rebuild(): void;
  145709. /**
  145710. * Disposes the component and the associated ressources
  145711. */
  145712. dispose(): void;
  145713. }
  145714. }
  145715. declare module BABYLON {
  145716. /**
  145717. * A helper for physics simulations
  145718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145719. */
  145720. export class PhysicsHelper {
  145721. private _scene;
  145722. private _physicsEngine;
  145723. /**
  145724. * Initializes the Physics helper
  145725. * @param scene Babylon.js scene
  145726. */
  145727. constructor(scene: Scene);
  145728. /**
  145729. * Applies a radial explosion impulse
  145730. * @param origin the origin of the explosion
  145731. * @param radiusOrEventOptions the radius or the options of radial explosion
  145732. * @param strength the explosion strength
  145733. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145734. * @returns A physics radial explosion event, or null
  145735. */
  145736. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145737. /**
  145738. * Applies a radial explosion force
  145739. * @param origin the origin of the explosion
  145740. * @param radiusOrEventOptions the radius or the options of radial explosion
  145741. * @param strength the explosion strength
  145742. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145743. * @returns A physics radial explosion event, or null
  145744. */
  145745. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145746. /**
  145747. * Creates a gravitational field
  145748. * @param origin the origin of the explosion
  145749. * @param radiusOrEventOptions the radius or the options of radial explosion
  145750. * @param strength the explosion strength
  145751. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145752. * @returns A physics gravitational field event, or null
  145753. */
  145754. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  145755. /**
  145756. * Creates a physics updraft event
  145757. * @param origin the origin of the updraft
  145758. * @param radiusOrEventOptions the radius or the options of the updraft
  145759. * @param strength the strength of the updraft
  145760. * @param height the height of the updraft
  145761. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  145762. * @returns A physics updraft event, or null
  145763. */
  145764. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  145765. /**
  145766. * Creates a physics vortex event
  145767. * @param origin the of the vortex
  145768. * @param radiusOrEventOptions the radius or the options of the vortex
  145769. * @param strength the strength of the vortex
  145770. * @param height the height of the vortex
  145771. * @returns a Physics vortex event, or null
  145772. * A physics vortex event or null
  145773. */
  145774. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  145775. }
  145776. /**
  145777. * Represents a physics radial explosion event
  145778. */
  145779. class PhysicsRadialExplosionEvent {
  145780. private _scene;
  145781. private _options;
  145782. private _sphere;
  145783. private _dataFetched;
  145784. /**
  145785. * Initializes a radial explosioin event
  145786. * @param _scene BabylonJS scene
  145787. * @param _options The options for the vortex event
  145788. */
  145789. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  145790. /**
  145791. * Returns the data related to the radial explosion event (sphere).
  145792. * @returns The radial explosion event data
  145793. */
  145794. getData(): PhysicsRadialExplosionEventData;
  145795. /**
  145796. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  145797. * @param impostor A physics imposter
  145798. * @param origin the origin of the explosion
  145799. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  145800. */
  145801. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  145802. /**
  145803. * Triggers affecterd impostors callbacks
  145804. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  145805. */
  145806. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  145807. /**
  145808. * Disposes the sphere.
  145809. * @param force Specifies if the sphere should be disposed by force
  145810. */
  145811. dispose(force?: boolean): void;
  145812. /*** Helpers ***/
  145813. private _prepareSphere;
  145814. private _intersectsWithSphere;
  145815. }
  145816. /**
  145817. * Represents a gravitational field event
  145818. */
  145819. class PhysicsGravitationalFieldEvent {
  145820. private _physicsHelper;
  145821. private _scene;
  145822. private _origin;
  145823. private _options;
  145824. private _tickCallback;
  145825. private _sphere;
  145826. private _dataFetched;
  145827. /**
  145828. * Initializes the physics gravitational field event
  145829. * @param _physicsHelper A physics helper
  145830. * @param _scene BabylonJS scene
  145831. * @param _origin The origin position of the gravitational field event
  145832. * @param _options The options for the vortex event
  145833. */
  145834. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  145835. /**
  145836. * Returns the data related to the gravitational field event (sphere).
  145837. * @returns A gravitational field event
  145838. */
  145839. getData(): PhysicsGravitationalFieldEventData;
  145840. /**
  145841. * Enables the gravitational field.
  145842. */
  145843. enable(): void;
  145844. /**
  145845. * Disables the gravitational field.
  145846. */
  145847. disable(): void;
  145848. /**
  145849. * Disposes the sphere.
  145850. * @param force The force to dispose from the gravitational field event
  145851. */
  145852. dispose(force?: boolean): void;
  145853. private _tick;
  145854. }
  145855. /**
  145856. * Represents a physics updraft event
  145857. */
  145858. class PhysicsUpdraftEvent {
  145859. private _scene;
  145860. private _origin;
  145861. private _options;
  145862. private _physicsEngine;
  145863. private _originTop;
  145864. private _originDirection;
  145865. private _tickCallback;
  145866. private _cylinder;
  145867. private _cylinderPosition;
  145868. private _dataFetched;
  145869. /**
  145870. * Initializes the physics updraft event
  145871. * @param _scene BabylonJS scene
  145872. * @param _origin The origin position of the updraft
  145873. * @param _options The options for the updraft event
  145874. */
  145875. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  145876. /**
  145877. * Returns the data related to the updraft event (cylinder).
  145878. * @returns A physics updraft event
  145879. */
  145880. getData(): PhysicsUpdraftEventData;
  145881. /**
  145882. * Enables the updraft.
  145883. */
  145884. enable(): void;
  145885. /**
  145886. * Disables the updraft.
  145887. */
  145888. disable(): void;
  145889. /**
  145890. * Disposes the cylinder.
  145891. * @param force Specifies if the updraft should be disposed by force
  145892. */
  145893. dispose(force?: boolean): void;
  145894. private getImpostorHitData;
  145895. private _tick;
  145896. /*** Helpers ***/
  145897. private _prepareCylinder;
  145898. private _intersectsWithCylinder;
  145899. }
  145900. /**
  145901. * Represents a physics vortex event
  145902. */
  145903. class PhysicsVortexEvent {
  145904. private _scene;
  145905. private _origin;
  145906. private _options;
  145907. private _physicsEngine;
  145908. private _originTop;
  145909. private _tickCallback;
  145910. private _cylinder;
  145911. private _cylinderPosition;
  145912. private _dataFetched;
  145913. /**
  145914. * Initializes the physics vortex event
  145915. * @param _scene The BabylonJS scene
  145916. * @param _origin The origin position of the vortex
  145917. * @param _options The options for the vortex event
  145918. */
  145919. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  145920. /**
  145921. * Returns the data related to the vortex event (cylinder).
  145922. * @returns The physics vortex event data
  145923. */
  145924. getData(): PhysicsVortexEventData;
  145925. /**
  145926. * Enables the vortex.
  145927. */
  145928. enable(): void;
  145929. /**
  145930. * Disables the cortex.
  145931. */
  145932. disable(): void;
  145933. /**
  145934. * Disposes the sphere.
  145935. * @param force
  145936. */
  145937. dispose(force?: boolean): void;
  145938. private getImpostorHitData;
  145939. private _tick;
  145940. /*** Helpers ***/
  145941. private _prepareCylinder;
  145942. private _intersectsWithCylinder;
  145943. }
  145944. /**
  145945. * Options fot the radial explosion event
  145946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145947. */
  145948. export class PhysicsRadialExplosionEventOptions {
  145949. /**
  145950. * The radius of the sphere for the radial explosion.
  145951. */
  145952. radius: number;
  145953. /**
  145954. * The strenth of the explosion.
  145955. */
  145956. strength: number;
  145957. /**
  145958. * The strenght of the force in correspondence to the distance of the affected object
  145959. */
  145960. falloff: PhysicsRadialImpulseFalloff;
  145961. /**
  145962. * Sphere options for the radial explosion.
  145963. */
  145964. sphere: {
  145965. segments: number;
  145966. diameter: number;
  145967. };
  145968. /**
  145969. * Sphere options for the radial explosion.
  145970. */
  145971. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  145972. }
  145973. /**
  145974. * Options fot the updraft event
  145975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145976. */
  145977. export class PhysicsUpdraftEventOptions {
  145978. /**
  145979. * The radius of the cylinder for the vortex
  145980. */
  145981. radius: number;
  145982. /**
  145983. * The strenth of the updraft.
  145984. */
  145985. strength: number;
  145986. /**
  145987. * The height of the cylinder for the updraft.
  145988. */
  145989. height: number;
  145990. /**
  145991. * The mode for the the updraft.
  145992. */
  145993. updraftMode: PhysicsUpdraftMode;
  145994. }
  145995. /**
  145996. * Options fot the vortex event
  145997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145998. */
  145999. export class PhysicsVortexEventOptions {
  146000. /**
  146001. * The radius of the cylinder for the vortex
  146002. */
  146003. radius: number;
  146004. /**
  146005. * The strenth of the vortex.
  146006. */
  146007. strength: number;
  146008. /**
  146009. * The height of the cylinder for the vortex.
  146010. */
  146011. height: number;
  146012. /**
  146013. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  146014. */
  146015. centripetalForceThreshold: number;
  146016. /**
  146017. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  146018. */
  146019. centripetalForceMultiplier: number;
  146020. /**
  146021. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  146022. */
  146023. centrifugalForceMultiplier: number;
  146024. /**
  146025. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  146026. */
  146027. updraftForceMultiplier: number;
  146028. }
  146029. /**
  146030. * The strenght of the force in correspondence to the distance of the affected object
  146031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146032. */
  146033. export enum PhysicsRadialImpulseFalloff {
  146034. /** Defines that impulse is constant in strength across it's whole radius */
  146035. Constant = 0,
  146036. /** Defines that impulse gets weaker if it's further from the origin */
  146037. Linear = 1
  146038. }
  146039. /**
  146040. * The strength of the force in correspondence to the distance of the affected object
  146041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146042. */
  146043. export enum PhysicsUpdraftMode {
  146044. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  146045. Center = 0,
  146046. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  146047. Perpendicular = 1
  146048. }
  146049. /**
  146050. * Interface for a physics hit data
  146051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146052. */
  146053. export interface PhysicsHitData {
  146054. /**
  146055. * The force applied at the contact point
  146056. */
  146057. force: Vector3;
  146058. /**
  146059. * The contact point
  146060. */
  146061. contactPoint: Vector3;
  146062. /**
  146063. * The distance from the origin to the contact point
  146064. */
  146065. distanceFromOrigin: number;
  146066. }
  146067. /**
  146068. * Interface for radial explosion event data
  146069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146070. */
  146071. export interface PhysicsRadialExplosionEventData {
  146072. /**
  146073. * A sphere used for the radial explosion event
  146074. */
  146075. sphere: Mesh;
  146076. }
  146077. /**
  146078. * Interface for gravitational field event data
  146079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146080. */
  146081. export interface PhysicsGravitationalFieldEventData {
  146082. /**
  146083. * A sphere mesh used for the gravitational field event
  146084. */
  146085. sphere: Mesh;
  146086. }
  146087. /**
  146088. * Interface for updraft event data
  146089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146090. */
  146091. export interface PhysicsUpdraftEventData {
  146092. /**
  146093. * A cylinder used for the updraft event
  146094. */
  146095. cylinder: Mesh;
  146096. }
  146097. /**
  146098. * Interface for vortex event data
  146099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146100. */
  146101. export interface PhysicsVortexEventData {
  146102. /**
  146103. * A cylinder used for the vortex event
  146104. */
  146105. cylinder: Mesh;
  146106. }
  146107. /**
  146108. * Interface for an affected physics impostor
  146109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146110. */
  146111. export interface PhysicsAffectedImpostorWithData {
  146112. /**
  146113. * The impostor affected by the effect
  146114. */
  146115. impostor: PhysicsImpostor;
  146116. /**
  146117. * The data about the hit/horce from the explosion
  146118. */
  146119. hitData: PhysicsHitData;
  146120. }
  146121. }
  146122. declare module BABYLON {
  146123. /** @hidden */
  146124. export var blackAndWhitePixelShader: {
  146125. name: string;
  146126. shader: string;
  146127. };
  146128. }
  146129. declare module BABYLON {
  146130. /**
  146131. * Post process used to render in black and white
  146132. */
  146133. export class BlackAndWhitePostProcess extends PostProcess {
  146134. /**
  146135. * Linear about to convert he result to black and white (default: 1)
  146136. */
  146137. degree: number;
  146138. /**
  146139. * Creates a black and white post process
  146140. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  146141. * @param name The name of the effect.
  146142. * @param options The required width/height ratio to downsize to before computing the render pass.
  146143. * @param camera The camera to apply the render pass to.
  146144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146145. * @param engine The engine which the post process will be applied. (default: current engine)
  146146. * @param reusable If the post process can be reused on the same frame. (default: false)
  146147. */
  146148. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146149. }
  146150. }
  146151. declare module BABYLON {
  146152. /**
  146153. * This represents a set of one or more post processes in Babylon.
  146154. * A post process can be used to apply a shader to a texture after it is rendered.
  146155. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146156. */
  146157. export class PostProcessRenderEffect {
  146158. private _postProcesses;
  146159. private _getPostProcesses;
  146160. private _singleInstance;
  146161. private _cameras;
  146162. private _indicesForCamera;
  146163. /**
  146164. * Name of the effect
  146165. * @hidden
  146166. */
  146167. _name: string;
  146168. /**
  146169. * Instantiates a post process render effect.
  146170. * A post process can be used to apply a shader to a texture after it is rendered.
  146171. * @param engine The engine the effect is tied to
  146172. * @param name The name of the effect
  146173. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  146174. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  146175. */
  146176. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  146177. /**
  146178. * Checks if all the post processes in the effect are supported.
  146179. */
  146180. get isSupported(): boolean;
  146181. /**
  146182. * Updates the current state of the effect
  146183. * @hidden
  146184. */
  146185. _update(): void;
  146186. /**
  146187. * Attaches the effect on cameras
  146188. * @param cameras The camera to attach to.
  146189. * @hidden
  146190. */
  146191. _attachCameras(cameras: Camera): void;
  146192. /**
  146193. * Attaches the effect on cameras
  146194. * @param cameras The camera to attach to.
  146195. * @hidden
  146196. */
  146197. _attachCameras(cameras: Camera[]): void;
  146198. /**
  146199. * Detaches the effect on cameras
  146200. * @param cameras The camera to detatch from.
  146201. * @hidden
  146202. */
  146203. _detachCameras(cameras: Camera): void;
  146204. /**
  146205. * Detatches the effect on cameras
  146206. * @param cameras The camera to detatch from.
  146207. * @hidden
  146208. */
  146209. _detachCameras(cameras: Camera[]): void;
  146210. /**
  146211. * Enables the effect on given cameras
  146212. * @param cameras The camera to enable.
  146213. * @hidden
  146214. */
  146215. _enable(cameras: Camera): void;
  146216. /**
  146217. * Enables the effect on given cameras
  146218. * @param cameras The camera to enable.
  146219. * @hidden
  146220. */
  146221. _enable(cameras: Nullable<Camera[]>): void;
  146222. /**
  146223. * Disables the effect on the given cameras
  146224. * @param cameras The camera to disable.
  146225. * @hidden
  146226. */
  146227. _disable(cameras: Camera): void;
  146228. /**
  146229. * Disables the effect on the given cameras
  146230. * @param cameras The camera to disable.
  146231. * @hidden
  146232. */
  146233. _disable(cameras: Nullable<Camera[]>): void;
  146234. /**
  146235. * Gets a list of the post processes contained in the effect.
  146236. * @param camera The camera to get the post processes on.
  146237. * @returns The list of the post processes in the effect.
  146238. */
  146239. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  146240. }
  146241. }
  146242. declare module BABYLON {
  146243. /** @hidden */
  146244. export var extractHighlightsPixelShader: {
  146245. name: string;
  146246. shader: string;
  146247. };
  146248. }
  146249. declare module BABYLON {
  146250. /**
  146251. * 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.
  146252. */
  146253. export class ExtractHighlightsPostProcess extends PostProcess {
  146254. /**
  146255. * The luminance threshold, pixels below this value will be set to black.
  146256. */
  146257. threshold: number;
  146258. /** @hidden */
  146259. _exposure: number;
  146260. /**
  146261. * Post process which has the input texture to be used when performing highlight extraction
  146262. * @hidden
  146263. */
  146264. _inputPostProcess: Nullable<PostProcess>;
  146265. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146266. }
  146267. }
  146268. declare module BABYLON {
  146269. /** @hidden */
  146270. export var bloomMergePixelShader: {
  146271. name: string;
  146272. shader: string;
  146273. };
  146274. }
  146275. declare module BABYLON {
  146276. /**
  146277. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146278. */
  146279. export class BloomMergePostProcess extends PostProcess {
  146280. /** Weight of the bloom to be added to the original input. */
  146281. weight: number;
  146282. /**
  146283. * Creates a new instance of @see BloomMergePostProcess
  146284. * @param name The name of the effect.
  146285. * @param originalFromInput Post process which's input will be used for the merge.
  146286. * @param blurred Blurred highlights post process which's output will be used.
  146287. * @param weight Weight of the bloom to be added to the original input.
  146288. * @param options The required width/height ratio to downsize to before computing the render pass.
  146289. * @param camera The camera to apply the render pass to.
  146290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146291. * @param engine The engine which the post process will be applied. (default: current engine)
  146292. * @param reusable If the post process can be reused on the same frame. (default: false)
  146293. * @param textureType Type of textures used when performing the post process. (default: 0)
  146294. * @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)
  146295. */
  146296. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  146297. /** Weight of the bloom to be added to the original input. */
  146298. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146299. }
  146300. }
  146301. declare module BABYLON {
  146302. /**
  146303. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  146304. */
  146305. export class BloomEffect extends PostProcessRenderEffect {
  146306. private bloomScale;
  146307. /**
  146308. * @hidden Internal
  146309. */
  146310. _effects: Array<PostProcess>;
  146311. /**
  146312. * @hidden Internal
  146313. */
  146314. _downscale: ExtractHighlightsPostProcess;
  146315. private _blurX;
  146316. private _blurY;
  146317. private _merge;
  146318. /**
  146319. * The luminance threshold to find bright areas of the image to bloom.
  146320. */
  146321. get threshold(): number;
  146322. set threshold(value: number);
  146323. /**
  146324. * The strength of the bloom.
  146325. */
  146326. get weight(): number;
  146327. set weight(value: number);
  146328. /**
  146329. * Specifies the size of the bloom blur kernel, relative to the final output size
  146330. */
  146331. get kernel(): number;
  146332. set kernel(value: number);
  146333. /**
  146334. * Creates a new instance of @see BloomEffect
  146335. * @param scene The scene the effect belongs to.
  146336. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  146337. * @param bloomKernel The size of the kernel to be used when applying the blur.
  146338. * @param bloomWeight The the strength of bloom.
  146339. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  146340. * @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)
  146341. */
  146342. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  146343. /**
  146344. * Disposes each of the internal effects for a given camera.
  146345. * @param camera The camera to dispose the effect on.
  146346. */
  146347. disposeEffects(camera: Camera): void;
  146348. /**
  146349. * @hidden Internal
  146350. */
  146351. _updateEffects(): void;
  146352. /**
  146353. * Internal
  146354. * @returns if all the contained post processes are ready.
  146355. * @hidden
  146356. */
  146357. _isReady(): boolean;
  146358. }
  146359. }
  146360. declare module BABYLON {
  146361. /** @hidden */
  146362. export var chromaticAberrationPixelShader: {
  146363. name: string;
  146364. shader: string;
  146365. };
  146366. }
  146367. declare module BABYLON {
  146368. /**
  146369. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  146370. */
  146371. export class ChromaticAberrationPostProcess extends PostProcess {
  146372. /**
  146373. * The amount of seperation of rgb channels (default: 30)
  146374. */
  146375. aberrationAmount: number;
  146376. /**
  146377. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  146378. */
  146379. radialIntensity: number;
  146380. /**
  146381. * 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))
  146382. */
  146383. direction: Vector2;
  146384. /**
  146385. * 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))
  146386. */
  146387. centerPosition: Vector2;
  146388. /**
  146389. * Creates a new instance ChromaticAberrationPostProcess
  146390. * @param name The name of the effect.
  146391. * @param screenWidth The width of the screen to apply the effect on.
  146392. * @param screenHeight The height of the screen to apply the effect on.
  146393. * @param options The required width/height ratio to downsize to before computing the render pass.
  146394. * @param camera The camera to apply the render pass to.
  146395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146396. * @param engine The engine which the post process will be applied. (default: current engine)
  146397. * @param reusable If the post process can be reused on the same frame. (default: false)
  146398. * @param textureType Type of textures used when performing the post process. (default: 0)
  146399. * @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)
  146400. */
  146401. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146402. }
  146403. }
  146404. declare module BABYLON {
  146405. /** @hidden */
  146406. export var circleOfConfusionPixelShader: {
  146407. name: string;
  146408. shader: string;
  146409. };
  146410. }
  146411. declare module BABYLON {
  146412. /**
  146413. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  146414. */
  146415. export class CircleOfConfusionPostProcess extends PostProcess {
  146416. /**
  146417. * 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.
  146418. */
  146419. lensSize: number;
  146420. /**
  146421. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  146422. */
  146423. fStop: number;
  146424. /**
  146425. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  146426. */
  146427. focusDistance: number;
  146428. /**
  146429. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  146430. */
  146431. focalLength: number;
  146432. private _depthTexture;
  146433. /**
  146434. * Creates a new instance CircleOfConfusionPostProcess
  146435. * @param name The name of the effect.
  146436. * @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.
  146437. * @param options The required width/height ratio to downsize to before computing the render pass.
  146438. * @param camera The camera to apply the render pass to.
  146439. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146440. * @param engine The engine which the post process will be applied. (default: current engine)
  146441. * @param reusable If the post process can be reused on the same frame. (default: false)
  146442. * @param textureType Type of textures used when performing the post process. (default: 0)
  146443. * @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)
  146444. */
  146445. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146446. /**
  146447. * 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.
  146448. */
  146449. set depthTexture(value: RenderTargetTexture);
  146450. }
  146451. }
  146452. declare module BABYLON {
  146453. /** @hidden */
  146454. export var colorCorrectionPixelShader: {
  146455. name: string;
  146456. shader: string;
  146457. };
  146458. }
  146459. declare module BABYLON {
  146460. /**
  146461. *
  146462. * This post-process allows the modification of rendered colors by using
  146463. * a 'look-up table' (LUT). This effect is also called Color Grading.
  146464. *
  146465. * The object needs to be provided an url to a texture containing the color
  146466. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  146467. * Use an image editing software to tweak the LUT to match your needs.
  146468. *
  146469. * For an example of a color LUT, see here:
  146470. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  146471. * For explanations on color grading, see here:
  146472. * @see http://udn.epicgames.com/Three/ColorGrading.html
  146473. *
  146474. */
  146475. export class ColorCorrectionPostProcess extends PostProcess {
  146476. private _colorTableTexture;
  146477. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146478. }
  146479. }
  146480. declare module BABYLON {
  146481. /** @hidden */
  146482. export var convolutionPixelShader: {
  146483. name: string;
  146484. shader: string;
  146485. };
  146486. }
  146487. declare module BABYLON {
  146488. /**
  146489. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  146490. * input texture to perform effects such as edge detection or sharpening
  146491. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  146492. */
  146493. export class ConvolutionPostProcess extends PostProcess {
  146494. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146495. kernel: number[];
  146496. /**
  146497. * Creates a new instance ConvolutionPostProcess
  146498. * @param name The name of the effect.
  146499. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  146500. * @param options The required width/height ratio to downsize to before computing the render pass.
  146501. * @param camera The camera to apply the render pass to.
  146502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146503. * @param engine The engine which the post process will be applied. (default: current engine)
  146504. * @param reusable If the post process can be reused on the same frame. (default: false)
  146505. * @param textureType Type of textures used when performing the post process. (default: 0)
  146506. */
  146507. constructor(name: string,
  146508. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146509. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146510. /**
  146511. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146512. */
  146513. static EdgeDetect0Kernel: number[];
  146514. /**
  146515. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146516. */
  146517. static EdgeDetect1Kernel: number[];
  146518. /**
  146519. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146520. */
  146521. static EdgeDetect2Kernel: number[];
  146522. /**
  146523. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146524. */
  146525. static SharpenKernel: number[];
  146526. /**
  146527. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146528. */
  146529. static EmbossKernel: number[];
  146530. /**
  146531. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146532. */
  146533. static GaussianKernel: number[];
  146534. }
  146535. }
  146536. declare module BABYLON {
  146537. /**
  146538. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  146539. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  146540. * based on samples that have a large difference in distance than the center pixel.
  146541. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  146542. */
  146543. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  146544. direction: Vector2;
  146545. /**
  146546. * Creates a new instance CircleOfConfusionPostProcess
  146547. * @param name The name of the effect.
  146548. * @param scene The scene the effect belongs to.
  146549. * @param direction The direction the blur should be applied.
  146550. * @param kernel The size of the kernel used to blur.
  146551. * @param options The required width/height ratio to downsize to before computing the render pass.
  146552. * @param camera The camera to apply the render pass to.
  146553. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  146554. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  146555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146556. * @param engine The engine which the post process will be applied. (default: current engine)
  146557. * @param reusable If the post process can be reused on the same frame. (default: false)
  146558. * @param textureType Type of textures used when performing the post process. (default: 0)
  146559. * @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)
  146560. */
  146561. 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);
  146562. }
  146563. }
  146564. declare module BABYLON {
  146565. /** @hidden */
  146566. export var depthOfFieldMergePixelShader: {
  146567. name: string;
  146568. shader: string;
  146569. };
  146570. }
  146571. declare module BABYLON {
  146572. /**
  146573. * Options to be set when merging outputs from the default pipeline.
  146574. */
  146575. export class DepthOfFieldMergePostProcessOptions {
  146576. /**
  146577. * The original image to merge on top of
  146578. */
  146579. originalFromInput: PostProcess;
  146580. /**
  146581. * Parameters to perform the merge of the depth of field effect
  146582. */
  146583. depthOfField?: {
  146584. circleOfConfusion: PostProcess;
  146585. blurSteps: Array<PostProcess>;
  146586. };
  146587. /**
  146588. * Parameters to perform the merge of bloom effect
  146589. */
  146590. bloom?: {
  146591. blurred: PostProcess;
  146592. weight: number;
  146593. };
  146594. }
  146595. /**
  146596. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146597. */
  146598. export class DepthOfFieldMergePostProcess extends PostProcess {
  146599. private blurSteps;
  146600. /**
  146601. * Creates a new instance of DepthOfFieldMergePostProcess
  146602. * @param name The name of the effect.
  146603. * @param originalFromInput Post process which's input will be used for the merge.
  146604. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  146605. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  146606. * @param options The required width/height ratio to downsize to before computing the render pass.
  146607. * @param camera The camera to apply the render pass to.
  146608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146609. * @param engine The engine which the post process will be applied. (default: current engine)
  146610. * @param reusable If the post process can be reused on the same frame. (default: false)
  146611. * @param textureType Type of textures used when performing the post process. (default: 0)
  146612. * @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)
  146613. */
  146614. 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);
  146615. /**
  146616. * Updates the effect with the current post process compile time values and recompiles the shader.
  146617. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  146618. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  146619. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  146620. * @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
  146621. * @param onCompiled Called when the shader has been compiled.
  146622. * @param onError Called if there is an error when compiling a shader.
  146623. */
  146624. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  146625. }
  146626. }
  146627. declare module BABYLON {
  146628. /**
  146629. * Specifies the level of max blur that should be applied when using the depth of field effect
  146630. */
  146631. export enum DepthOfFieldEffectBlurLevel {
  146632. /**
  146633. * Subtle blur
  146634. */
  146635. Low = 0,
  146636. /**
  146637. * Medium blur
  146638. */
  146639. Medium = 1,
  146640. /**
  146641. * Large blur
  146642. */
  146643. High = 2
  146644. }
  146645. /**
  146646. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  146647. */
  146648. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  146649. private _circleOfConfusion;
  146650. /**
  146651. * @hidden Internal, blurs from high to low
  146652. */
  146653. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  146654. private _depthOfFieldBlurY;
  146655. private _dofMerge;
  146656. /**
  146657. * @hidden Internal post processes in depth of field effect
  146658. */
  146659. _effects: Array<PostProcess>;
  146660. /**
  146661. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  146662. */
  146663. set focalLength(value: number);
  146664. get focalLength(): number;
  146665. /**
  146666. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  146667. */
  146668. set fStop(value: number);
  146669. get fStop(): number;
  146670. /**
  146671. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  146672. */
  146673. set focusDistance(value: number);
  146674. get focusDistance(): number;
  146675. /**
  146676. * 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.
  146677. */
  146678. set lensSize(value: number);
  146679. get lensSize(): number;
  146680. /**
  146681. * Creates a new instance DepthOfFieldEffect
  146682. * @param scene The scene the effect belongs to.
  146683. * @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.
  146684. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  146685. * @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)
  146686. */
  146687. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  146688. /**
  146689. * Get the current class name of the current effet
  146690. * @returns "DepthOfFieldEffect"
  146691. */
  146692. getClassName(): string;
  146693. /**
  146694. * 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.
  146695. */
  146696. set depthTexture(value: RenderTargetTexture);
  146697. /**
  146698. * Disposes each of the internal effects for a given camera.
  146699. * @param camera The camera to dispose the effect on.
  146700. */
  146701. disposeEffects(camera: Camera): void;
  146702. /**
  146703. * @hidden Internal
  146704. */
  146705. _updateEffects(): void;
  146706. /**
  146707. * Internal
  146708. * @returns if all the contained post processes are ready.
  146709. * @hidden
  146710. */
  146711. _isReady(): boolean;
  146712. }
  146713. }
  146714. declare module BABYLON {
  146715. /** @hidden */
  146716. export var displayPassPixelShader: {
  146717. name: string;
  146718. shader: string;
  146719. };
  146720. }
  146721. declare module BABYLON {
  146722. /**
  146723. * DisplayPassPostProcess which produces an output the same as it's input
  146724. */
  146725. export class DisplayPassPostProcess extends PostProcess {
  146726. /**
  146727. * Creates the DisplayPassPostProcess
  146728. * @param name The name of the effect.
  146729. * @param options The required width/height ratio to downsize to before computing the render pass.
  146730. * @param camera The camera to apply the render pass to.
  146731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146732. * @param engine The engine which the post process will be applied. (default: current engine)
  146733. * @param reusable If the post process can be reused on the same frame. (default: false)
  146734. */
  146735. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146736. }
  146737. }
  146738. declare module BABYLON {
  146739. /** @hidden */
  146740. export var filterPixelShader: {
  146741. name: string;
  146742. shader: string;
  146743. };
  146744. }
  146745. declare module BABYLON {
  146746. /**
  146747. * Applies a kernel filter to the image
  146748. */
  146749. export class FilterPostProcess extends PostProcess {
  146750. /** The matrix to be applied to the image */
  146751. kernelMatrix: Matrix;
  146752. /**
  146753. *
  146754. * @param name The name of the effect.
  146755. * @param kernelMatrix The matrix to be applied to the image
  146756. * @param options The required width/height ratio to downsize to before computing the render pass.
  146757. * @param camera The camera to apply the render pass to.
  146758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146759. * @param engine The engine which the post process will be applied. (default: current engine)
  146760. * @param reusable If the post process can be reused on the same frame. (default: false)
  146761. */
  146762. constructor(name: string,
  146763. /** The matrix to be applied to the image */
  146764. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146765. }
  146766. }
  146767. declare module BABYLON {
  146768. /** @hidden */
  146769. export var fxaaPixelShader: {
  146770. name: string;
  146771. shader: string;
  146772. };
  146773. }
  146774. declare module BABYLON {
  146775. /** @hidden */
  146776. export var fxaaVertexShader: {
  146777. name: string;
  146778. shader: string;
  146779. };
  146780. }
  146781. declare module BABYLON {
  146782. /**
  146783. * Fxaa post process
  146784. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  146785. */
  146786. export class FxaaPostProcess extends PostProcess {
  146787. /** @hidden */
  146788. texelWidth: number;
  146789. /** @hidden */
  146790. texelHeight: number;
  146791. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146792. private _getDefines;
  146793. }
  146794. }
  146795. declare module BABYLON {
  146796. /** @hidden */
  146797. export var grainPixelShader: {
  146798. name: string;
  146799. shader: string;
  146800. };
  146801. }
  146802. declare module BABYLON {
  146803. /**
  146804. * The GrainPostProcess adds noise to the image at mid luminance levels
  146805. */
  146806. export class GrainPostProcess extends PostProcess {
  146807. /**
  146808. * The intensity of the grain added (default: 30)
  146809. */
  146810. intensity: number;
  146811. /**
  146812. * If the grain should be randomized on every frame
  146813. */
  146814. animated: boolean;
  146815. /**
  146816. * Creates a new instance of @see GrainPostProcess
  146817. * @param name The name of the effect.
  146818. * @param options The required width/height ratio to downsize to before computing the render pass.
  146819. * @param camera The camera to apply the render pass to.
  146820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146821. * @param engine The engine which the post process will be applied. (default: current engine)
  146822. * @param reusable If the post process can be reused on the same frame. (default: false)
  146823. * @param textureType Type of textures used when performing the post process. (default: 0)
  146824. * @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)
  146825. */
  146826. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146827. }
  146828. }
  146829. declare module BABYLON {
  146830. /** @hidden */
  146831. export var highlightsPixelShader: {
  146832. name: string;
  146833. shader: string;
  146834. };
  146835. }
  146836. declare module BABYLON {
  146837. /**
  146838. * Extracts highlights from the image
  146839. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146840. */
  146841. export class HighlightsPostProcess extends PostProcess {
  146842. /**
  146843. * Extracts highlights from the image
  146844. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146845. * @param name The name of the effect.
  146846. * @param options The required width/height ratio to downsize to before computing the render pass.
  146847. * @param camera The camera to apply the render pass to.
  146848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146849. * @param engine The engine which the post process will be applied. (default: current engine)
  146850. * @param reusable If the post process can be reused on the same frame. (default: false)
  146851. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  146852. */
  146853. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146854. }
  146855. }
  146856. declare module BABYLON {
  146857. /** @hidden */
  146858. export var mrtFragmentDeclaration: {
  146859. name: string;
  146860. shader: string;
  146861. };
  146862. }
  146863. declare module BABYLON {
  146864. /** @hidden */
  146865. export var geometryPixelShader: {
  146866. name: string;
  146867. shader: string;
  146868. };
  146869. }
  146870. declare module BABYLON {
  146871. /** @hidden */
  146872. export var geometryVertexShader: {
  146873. name: string;
  146874. shader: string;
  146875. };
  146876. }
  146877. declare module BABYLON {
  146878. /** @hidden */
  146879. interface ISavedTransformationMatrix {
  146880. world: Matrix;
  146881. viewProjection: Matrix;
  146882. }
  146883. /**
  146884. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  146885. */
  146886. export class GeometryBufferRenderer {
  146887. /**
  146888. * Constant used to retrieve the position texture index in the G-Buffer textures array
  146889. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  146890. */
  146891. static readonly POSITION_TEXTURE_TYPE: number;
  146892. /**
  146893. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  146894. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  146895. */
  146896. static readonly VELOCITY_TEXTURE_TYPE: number;
  146897. /**
  146898. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  146899. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  146900. */
  146901. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  146902. /**
  146903. * Dictionary used to store the previous transformation matrices of each rendered mesh
  146904. * in order to compute objects velocities when enableVelocity is set to "true"
  146905. * @hidden
  146906. */
  146907. _previousTransformationMatrices: {
  146908. [index: number]: ISavedTransformationMatrix;
  146909. };
  146910. /**
  146911. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  146912. * in order to compute objects velocities when enableVelocity is set to "true"
  146913. * @hidden
  146914. */
  146915. _previousBonesTransformationMatrices: {
  146916. [index: number]: Float32Array;
  146917. };
  146918. /**
  146919. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  146920. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  146921. */
  146922. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  146923. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  146924. renderTransparentMeshes: boolean;
  146925. private _scene;
  146926. private _multiRenderTarget;
  146927. private _ratio;
  146928. private _enablePosition;
  146929. private _enableVelocity;
  146930. private _enableReflectivity;
  146931. private _positionIndex;
  146932. private _velocityIndex;
  146933. private _reflectivityIndex;
  146934. protected _effect: Effect;
  146935. protected _cachedDefines: string;
  146936. /**
  146937. * Set the render list (meshes to be rendered) used in the G buffer.
  146938. */
  146939. set renderList(meshes: Mesh[]);
  146940. /**
  146941. * Gets wether or not G buffer are supported by the running hardware.
  146942. * This requires draw buffer supports
  146943. */
  146944. get isSupported(): boolean;
  146945. /**
  146946. * Returns the index of the given texture type in the G-Buffer textures array
  146947. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  146948. * @returns the index of the given texture type in the G-Buffer textures array
  146949. */
  146950. getTextureIndex(textureType: number): number;
  146951. /**
  146952. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  146953. */
  146954. get enablePosition(): boolean;
  146955. /**
  146956. * Sets whether or not objects positions are enabled for the G buffer.
  146957. */
  146958. set enablePosition(enable: boolean);
  146959. /**
  146960. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  146961. */
  146962. get enableVelocity(): boolean;
  146963. /**
  146964. * Sets wether or not objects velocities are enabled for the G buffer.
  146965. */
  146966. set enableVelocity(enable: boolean);
  146967. /**
  146968. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  146969. */
  146970. get enableReflectivity(): boolean;
  146971. /**
  146972. * Sets wether or not objects roughness are enabled for the G buffer.
  146973. */
  146974. set enableReflectivity(enable: boolean);
  146975. /**
  146976. * Gets the scene associated with the buffer.
  146977. */
  146978. get scene(): Scene;
  146979. /**
  146980. * Gets the ratio used by the buffer during its creation.
  146981. * How big is the buffer related to the main canvas.
  146982. */
  146983. get ratio(): number;
  146984. /** @hidden */
  146985. static _SceneComponentInitialization: (scene: Scene) => void;
  146986. /**
  146987. * Creates a new G Buffer for the scene
  146988. * @param scene The scene the buffer belongs to
  146989. * @param ratio How big is the buffer related to the main canvas.
  146990. */
  146991. constructor(scene: Scene, ratio?: number);
  146992. /**
  146993. * Checks wether everything is ready to render a submesh to the G buffer.
  146994. * @param subMesh the submesh to check readiness for
  146995. * @param useInstances is the mesh drawn using instance or not
  146996. * @returns true if ready otherwise false
  146997. */
  146998. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  146999. /**
  147000. * Gets the current underlying G Buffer.
  147001. * @returns the buffer
  147002. */
  147003. getGBuffer(): MultiRenderTarget;
  147004. /**
  147005. * Gets the number of samples used to render the buffer (anti aliasing).
  147006. */
  147007. get samples(): number;
  147008. /**
  147009. * Sets the number of samples used to render the buffer (anti aliasing).
  147010. */
  147011. set samples(value: number);
  147012. /**
  147013. * Disposes the renderer and frees up associated resources.
  147014. */
  147015. dispose(): void;
  147016. protected _createRenderTargets(): void;
  147017. private _copyBonesTransformationMatrices;
  147018. }
  147019. }
  147020. declare module BABYLON {
  147021. interface Scene {
  147022. /** @hidden (Backing field) */
  147023. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147024. /**
  147025. * Gets or Sets the current geometry buffer associated to the scene.
  147026. */
  147027. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147028. /**
  147029. * Enables a GeometryBufferRender and associates it with the scene
  147030. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  147031. * @returns the GeometryBufferRenderer
  147032. */
  147033. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  147034. /**
  147035. * Disables the GeometryBufferRender associated with the scene
  147036. */
  147037. disableGeometryBufferRenderer(): void;
  147038. }
  147039. /**
  147040. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  147041. * in several rendering techniques.
  147042. */
  147043. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  147044. /**
  147045. * The component name helpful to identify the component in the list of scene components.
  147046. */
  147047. readonly name: string;
  147048. /**
  147049. * The scene the component belongs to.
  147050. */
  147051. scene: Scene;
  147052. /**
  147053. * Creates a new instance of the component for the given scene
  147054. * @param scene Defines the scene to register the component in
  147055. */
  147056. constructor(scene: Scene);
  147057. /**
  147058. * Registers the component in a given scene
  147059. */
  147060. register(): void;
  147061. /**
  147062. * Rebuilds the elements related to this component in case of
  147063. * context lost for instance.
  147064. */
  147065. rebuild(): void;
  147066. /**
  147067. * Disposes the component and the associated ressources
  147068. */
  147069. dispose(): void;
  147070. private _gatherRenderTargets;
  147071. }
  147072. }
  147073. declare module BABYLON {
  147074. /** @hidden */
  147075. export var motionBlurPixelShader: {
  147076. name: string;
  147077. shader: string;
  147078. };
  147079. }
  147080. declare module BABYLON {
  147081. /**
  147082. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  147083. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  147084. * As an example, all you have to do is to create the post-process:
  147085. * var mb = new BABYLON.MotionBlurPostProcess(
  147086. * 'mb', // The name of the effect.
  147087. * scene, // The scene containing the objects to blur according to their velocity.
  147088. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  147089. * camera // The camera to apply the render pass to.
  147090. * );
  147091. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  147092. */
  147093. export class MotionBlurPostProcess extends PostProcess {
  147094. /**
  147095. * Defines how much the image is blurred by the movement. Default value is equal to 1
  147096. */
  147097. motionStrength: number;
  147098. /**
  147099. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  147100. */
  147101. get motionBlurSamples(): number;
  147102. /**
  147103. * Sets the number of iterations to be used for motion blur quality
  147104. */
  147105. set motionBlurSamples(samples: number);
  147106. private _motionBlurSamples;
  147107. private _geometryBufferRenderer;
  147108. /**
  147109. * Creates a new instance MotionBlurPostProcess
  147110. * @param name The name of the effect.
  147111. * @param scene The scene containing the objects to blur according to their velocity.
  147112. * @param options The required width/height ratio to downsize to before computing the render pass.
  147113. * @param camera The camera to apply the render pass to.
  147114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147115. * @param engine The engine which the post process will be applied. (default: current engine)
  147116. * @param reusable If the post process can be reused on the same frame. (default: false)
  147117. * @param textureType Type of textures used when performing the post process. (default: 0)
  147118. * @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)
  147119. */
  147120. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147121. /**
  147122. * Excludes the given skinned mesh from computing bones velocities.
  147123. * 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.
  147124. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  147125. */
  147126. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147127. /**
  147128. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  147129. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  147130. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  147131. */
  147132. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147133. /**
  147134. * Disposes the post process.
  147135. * @param camera The camera to dispose the post process on.
  147136. */
  147137. dispose(camera?: Camera): void;
  147138. }
  147139. }
  147140. declare module BABYLON {
  147141. /** @hidden */
  147142. export var refractionPixelShader: {
  147143. name: string;
  147144. shader: string;
  147145. };
  147146. }
  147147. declare module BABYLON {
  147148. /**
  147149. * Post process which applies a refractin texture
  147150. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147151. */
  147152. export class RefractionPostProcess extends PostProcess {
  147153. /** the base color of the refraction (used to taint the rendering) */
  147154. color: Color3;
  147155. /** simulated refraction depth */
  147156. depth: number;
  147157. /** the coefficient of the base color (0 to remove base color tainting) */
  147158. colorLevel: number;
  147159. private _refTexture;
  147160. private _ownRefractionTexture;
  147161. /**
  147162. * Gets or sets the refraction texture
  147163. * Please note that you are responsible for disposing the texture if you set it manually
  147164. */
  147165. get refractionTexture(): Texture;
  147166. set refractionTexture(value: Texture);
  147167. /**
  147168. * Initializes the RefractionPostProcess
  147169. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147170. * @param name The name of the effect.
  147171. * @param refractionTextureUrl Url of the refraction texture to use
  147172. * @param color the base color of the refraction (used to taint the rendering)
  147173. * @param depth simulated refraction depth
  147174. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  147175. * @param camera The camera to apply the render pass to.
  147176. * @param options The required width/height ratio to downsize to before computing the render pass.
  147177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147178. * @param engine The engine which the post process will be applied. (default: current engine)
  147179. * @param reusable If the post process can be reused on the same frame. (default: false)
  147180. */
  147181. constructor(name: string, refractionTextureUrl: string,
  147182. /** the base color of the refraction (used to taint the rendering) */
  147183. color: Color3,
  147184. /** simulated refraction depth */
  147185. depth: number,
  147186. /** the coefficient of the base color (0 to remove base color tainting) */
  147187. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147188. /**
  147189. * Disposes of the post process
  147190. * @param camera Camera to dispose post process on
  147191. */
  147192. dispose(camera: Camera): void;
  147193. }
  147194. }
  147195. declare module BABYLON {
  147196. /** @hidden */
  147197. export var sharpenPixelShader: {
  147198. name: string;
  147199. shader: string;
  147200. };
  147201. }
  147202. declare module BABYLON {
  147203. /**
  147204. * The SharpenPostProcess applies a sharpen kernel to every pixel
  147205. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147206. */
  147207. export class SharpenPostProcess extends PostProcess {
  147208. /**
  147209. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  147210. */
  147211. colorAmount: number;
  147212. /**
  147213. * How much sharpness should be applied (default: 0.3)
  147214. */
  147215. edgeAmount: number;
  147216. /**
  147217. * Creates a new instance ConvolutionPostProcess
  147218. * @param name The name of the effect.
  147219. * @param options The required width/height ratio to downsize to before computing the render pass.
  147220. * @param camera The camera to apply the render pass to.
  147221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147222. * @param engine The engine which the post process will be applied. (default: current engine)
  147223. * @param reusable If the post process can be reused on the same frame. (default: false)
  147224. * @param textureType Type of textures used when performing the post process. (default: 0)
  147225. * @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)
  147226. */
  147227. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147228. }
  147229. }
  147230. declare module BABYLON {
  147231. /**
  147232. * PostProcessRenderPipeline
  147233. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147234. */
  147235. export class PostProcessRenderPipeline {
  147236. private engine;
  147237. private _renderEffects;
  147238. private _renderEffectsForIsolatedPass;
  147239. /**
  147240. * List of inspectable custom properties (used by the Inspector)
  147241. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  147242. */
  147243. inspectableCustomProperties: IInspectable[];
  147244. /**
  147245. * @hidden
  147246. */
  147247. protected _cameras: Camera[];
  147248. /** @hidden */
  147249. _name: string;
  147250. /**
  147251. * Gets pipeline name
  147252. */
  147253. get name(): string;
  147254. /** Gets the list of attached cameras */
  147255. get cameras(): Camera[];
  147256. /**
  147257. * Initializes a PostProcessRenderPipeline
  147258. * @param engine engine to add the pipeline to
  147259. * @param name name of the pipeline
  147260. */
  147261. constructor(engine: Engine, name: string);
  147262. /**
  147263. * Gets the class name
  147264. * @returns "PostProcessRenderPipeline"
  147265. */
  147266. getClassName(): string;
  147267. /**
  147268. * If all the render effects in the pipeline are supported
  147269. */
  147270. get isSupported(): boolean;
  147271. /**
  147272. * Adds an effect to the pipeline
  147273. * @param renderEffect the effect to add
  147274. */
  147275. addEffect(renderEffect: PostProcessRenderEffect): void;
  147276. /** @hidden */
  147277. _rebuild(): void;
  147278. /** @hidden */
  147279. _enableEffect(renderEffectName: string, cameras: Camera): void;
  147280. /** @hidden */
  147281. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  147282. /** @hidden */
  147283. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  147284. /** @hidden */
  147285. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  147286. /** @hidden */
  147287. _attachCameras(cameras: Camera, unique: boolean): void;
  147288. /** @hidden */
  147289. _attachCameras(cameras: Camera[], unique: boolean): void;
  147290. /** @hidden */
  147291. _detachCameras(cameras: Camera): void;
  147292. /** @hidden */
  147293. _detachCameras(cameras: Nullable<Camera[]>): void;
  147294. /** @hidden */
  147295. _update(): void;
  147296. /** @hidden */
  147297. _reset(): void;
  147298. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  147299. /**
  147300. * Disposes of the pipeline
  147301. */
  147302. dispose(): void;
  147303. }
  147304. }
  147305. declare module BABYLON {
  147306. /**
  147307. * PostProcessRenderPipelineManager class
  147308. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147309. */
  147310. export class PostProcessRenderPipelineManager {
  147311. private _renderPipelines;
  147312. /**
  147313. * Initializes a PostProcessRenderPipelineManager
  147314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147315. */
  147316. constructor();
  147317. /**
  147318. * Gets the list of supported render pipelines
  147319. */
  147320. get supportedPipelines(): PostProcessRenderPipeline[];
  147321. /**
  147322. * Adds a pipeline to the manager
  147323. * @param renderPipeline The pipeline to add
  147324. */
  147325. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  147326. /**
  147327. * Attaches a camera to the pipeline
  147328. * @param renderPipelineName The name of the pipeline to attach to
  147329. * @param cameras the camera to attach
  147330. * @param unique if the camera can be attached multiple times to the pipeline
  147331. */
  147332. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  147333. /**
  147334. * Detaches a camera from the pipeline
  147335. * @param renderPipelineName The name of the pipeline to detach from
  147336. * @param cameras the camera to detach
  147337. */
  147338. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  147339. /**
  147340. * Enables an effect by name on a pipeline
  147341. * @param renderPipelineName the name of the pipeline to enable the effect in
  147342. * @param renderEffectName the name of the effect to enable
  147343. * @param cameras the cameras that the effect should be enabled on
  147344. */
  147345. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  147346. /**
  147347. * Disables an effect by name on a pipeline
  147348. * @param renderPipelineName the name of the pipeline to disable the effect in
  147349. * @param renderEffectName the name of the effect to disable
  147350. * @param cameras the cameras that the effect should be disabled on
  147351. */
  147352. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  147353. /**
  147354. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  147355. */
  147356. update(): void;
  147357. /** @hidden */
  147358. _rebuild(): void;
  147359. /**
  147360. * Disposes of the manager and pipelines
  147361. */
  147362. dispose(): void;
  147363. }
  147364. }
  147365. declare module BABYLON {
  147366. interface Scene {
  147367. /** @hidden (Backing field) */
  147368. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  147369. /**
  147370. * Gets the postprocess render pipeline manager
  147371. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147372. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  147373. */
  147374. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  147375. }
  147376. /**
  147377. * Defines the Render Pipeline scene component responsible to rendering pipelines
  147378. */
  147379. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  147380. /**
  147381. * The component name helpfull to identify the component in the list of scene components.
  147382. */
  147383. readonly name: string;
  147384. /**
  147385. * The scene the component belongs to.
  147386. */
  147387. scene: Scene;
  147388. /**
  147389. * Creates a new instance of the component for the given scene
  147390. * @param scene Defines the scene to register the component in
  147391. */
  147392. constructor(scene: Scene);
  147393. /**
  147394. * Registers the component in a given scene
  147395. */
  147396. register(): void;
  147397. /**
  147398. * Rebuilds the elements related to this component in case of
  147399. * context lost for instance.
  147400. */
  147401. rebuild(): void;
  147402. /**
  147403. * Disposes the component and the associated ressources
  147404. */
  147405. dispose(): void;
  147406. private _gatherRenderTargets;
  147407. }
  147408. }
  147409. declare module BABYLON {
  147410. /**
  147411. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  147412. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  147413. */
  147414. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  147415. private _scene;
  147416. private _camerasToBeAttached;
  147417. /**
  147418. * ID of the sharpen post process,
  147419. */
  147420. private readonly SharpenPostProcessId;
  147421. /**
  147422. * @ignore
  147423. * ID of the image processing post process;
  147424. */
  147425. readonly ImageProcessingPostProcessId: string;
  147426. /**
  147427. * @ignore
  147428. * ID of the Fast Approximate Anti-Aliasing post process;
  147429. */
  147430. readonly FxaaPostProcessId: string;
  147431. /**
  147432. * ID of the chromatic aberration post process,
  147433. */
  147434. private readonly ChromaticAberrationPostProcessId;
  147435. /**
  147436. * ID of the grain post process
  147437. */
  147438. private readonly GrainPostProcessId;
  147439. /**
  147440. * Sharpen post process which will apply a sharpen convolution to enhance edges
  147441. */
  147442. sharpen: SharpenPostProcess;
  147443. private _sharpenEffect;
  147444. private bloom;
  147445. /**
  147446. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  147447. */
  147448. depthOfField: DepthOfFieldEffect;
  147449. /**
  147450. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  147451. */
  147452. fxaa: FxaaPostProcess;
  147453. /**
  147454. * Image post processing pass used to perform operations such as tone mapping or color grading.
  147455. */
  147456. imageProcessing: ImageProcessingPostProcess;
  147457. /**
  147458. * Chromatic aberration post process which will shift rgb colors in the image
  147459. */
  147460. chromaticAberration: ChromaticAberrationPostProcess;
  147461. private _chromaticAberrationEffect;
  147462. /**
  147463. * Grain post process which add noise to the image
  147464. */
  147465. grain: GrainPostProcess;
  147466. private _grainEffect;
  147467. /**
  147468. * Glow post process which adds a glow to emissive areas of the image
  147469. */
  147470. private _glowLayer;
  147471. /**
  147472. * Animations which can be used to tweak settings over a period of time
  147473. */
  147474. animations: Animation[];
  147475. private _imageProcessingConfigurationObserver;
  147476. private _sharpenEnabled;
  147477. private _bloomEnabled;
  147478. private _depthOfFieldEnabled;
  147479. private _depthOfFieldBlurLevel;
  147480. private _fxaaEnabled;
  147481. private _imageProcessingEnabled;
  147482. private _defaultPipelineTextureType;
  147483. private _bloomScale;
  147484. private _chromaticAberrationEnabled;
  147485. private _grainEnabled;
  147486. private _buildAllowed;
  147487. /**
  147488. * Gets active scene
  147489. */
  147490. get scene(): Scene;
  147491. /**
  147492. * Enable or disable the sharpen process from the pipeline
  147493. */
  147494. set sharpenEnabled(enabled: boolean);
  147495. get sharpenEnabled(): boolean;
  147496. private _resizeObserver;
  147497. private _hardwareScaleLevel;
  147498. private _bloomKernel;
  147499. /**
  147500. * Specifies the size of the bloom blur kernel, relative to the final output size
  147501. */
  147502. get bloomKernel(): number;
  147503. set bloomKernel(value: number);
  147504. /**
  147505. * Specifies the weight of the bloom in the final rendering
  147506. */
  147507. private _bloomWeight;
  147508. /**
  147509. * Specifies the luma threshold for the area that will be blurred by the bloom
  147510. */
  147511. private _bloomThreshold;
  147512. private _hdr;
  147513. /**
  147514. * The strength of the bloom.
  147515. */
  147516. set bloomWeight(value: number);
  147517. get bloomWeight(): number;
  147518. /**
  147519. * The strength of the bloom.
  147520. */
  147521. set bloomThreshold(value: number);
  147522. get bloomThreshold(): number;
  147523. /**
  147524. * The scale of the bloom, lower value will provide better performance.
  147525. */
  147526. set bloomScale(value: number);
  147527. get bloomScale(): number;
  147528. /**
  147529. * Enable or disable the bloom from the pipeline
  147530. */
  147531. set bloomEnabled(enabled: boolean);
  147532. get bloomEnabled(): boolean;
  147533. private _rebuildBloom;
  147534. /**
  147535. * If the depth of field is enabled.
  147536. */
  147537. get depthOfFieldEnabled(): boolean;
  147538. set depthOfFieldEnabled(enabled: boolean);
  147539. /**
  147540. * Blur level of the depth of field effect. (Higher blur will effect performance)
  147541. */
  147542. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  147543. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  147544. /**
  147545. * If the anti aliasing is enabled.
  147546. */
  147547. set fxaaEnabled(enabled: boolean);
  147548. get fxaaEnabled(): boolean;
  147549. private _samples;
  147550. /**
  147551. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  147552. */
  147553. set samples(sampleCount: number);
  147554. get samples(): number;
  147555. /**
  147556. * If image processing is enabled.
  147557. */
  147558. set imageProcessingEnabled(enabled: boolean);
  147559. get imageProcessingEnabled(): boolean;
  147560. /**
  147561. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  147562. */
  147563. set glowLayerEnabled(enabled: boolean);
  147564. get glowLayerEnabled(): boolean;
  147565. /**
  147566. * Gets the glow layer (or null if not defined)
  147567. */
  147568. get glowLayer(): Nullable<GlowLayer>;
  147569. /**
  147570. * Enable or disable the chromaticAberration process from the pipeline
  147571. */
  147572. set chromaticAberrationEnabled(enabled: boolean);
  147573. get chromaticAberrationEnabled(): boolean;
  147574. /**
  147575. * Enable or disable the grain process from the pipeline
  147576. */
  147577. set grainEnabled(enabled: boolean);
  147578. get grainEnabled(): boolean;
  147579. /**
  147580. * @constructor
  147581. * @param name - The rendering pipeline name (default: "")
  147582. * @param hdr - If high dynamic range textures should be used (default: true)
  147583. * @param scene - The scene linked to this pipeline (default: the last created scene)
  147584. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  147585. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  147586. */
  147587. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  147588. /**
  147589. * Get the class name
  147590. * @returns "DefaultRenderingPipeline"
  147591. */
  147592. getClassName(): string;
  147593. /**
  147594. * Force the compilation of the entire pipeline.
  147595. */
  147596. prepare(): void;
  147597. private _hasCleared;
  147598. private _prevPostProcess;
  147599. private _prevPrevPostProcess;
  147600. private _setAutoClearAndTextureSharing;
  147601. private _depthOfFieldSceneObserver;
  147602. private _buildPipeline;
  147603. private _disposePostProcesses;
  147604. /**
  147605. * Adds a camera to the pipeline
  147606. * @param camera the camera to be added
  147607. */
  147608. addCamera(camera: Camera): void;
  147609. /**
  147610. * Removes a camera from the pipeline
  147611. * @param camera the camera to remove
  147612. */
  147613. removeCamera(camera: Camera): void;
  147614. /**
  147615. * Dispose of the pipeline and stop all post processes
  147616. */
  147617. dispose(): void;
  147618. /**
  147619. * Serialize the rendering pipeline (Used when exporting)
  147620. * @returns the serialized object
  147621. */
  147622. serialize(): any;
  147623. /**
  147624. * Parse the serialized pipeline
  147625. * @param source Source pipeline.
  147626. * @param scene The scene to load the pipeline to.
  147627. * @param rootUrl The URL of the serialized pipeline.
  147628. * @returns An instantiated pipeline from the serialized object.
  147629. */
  147630. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  147631. }
  147632. }
  147633. declare module BABYLON {
  147634. /** @hidden */
  147635. export var lensHighlightsPixelShader: {
  147636. name: string;
  147637. shader: string;
  147638. };
  147639. }
  147640. declare module BABYLON {
  147641. /** @hidden */
  147642. export var depthOfFieldPixelShader: {
  147643. name: string;
  147644. shader: string;
  147645. };
  147646. }
  147647. declare module BABYLON {
  147648. /**
  147649. * BABYLON.JS Chromatic Aberration GLSL Shader
  147650. * Author: Olivier Guyot
  147651. * Separates very slightly R, G and B colors on the edges of the screen
  147652. * Inspired by Francois Tarlier & Martins Upitis
  147653. */
  147654. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  147655. /**
  147656. * @ignore
  147657. * The chromatic aberration PostProcess id in the pipeline
  147658. */
  147659. LensChromaticAberrationEffect: string;
  147660. /**
  147661. * @ignore
  147662. * The highlights enhancing PostProcess id in the pipeline
  147663. */
  147664. HighlightsEnhancingEffect: string;
  147665. /**
  147666. * @ignore
  147667. * The depth-of-field PostProcess id in the pipeline
  147668. */
  147669. LensDepthOfFieldEffect: string;
  147670. private _scene;
  147671. private _depthTexture;
  147672. private _grainTexture;
  147673. private _chromaticAberrationPostProcess;
  147674. private _highlightsPostProcess;
  147675. private _depthOfFieldPostProcess;
  147676. private _edgeBlur;
  147677. private _grainAmount;
  147678. private _chromaticAberration;
  147679. private _distortion;
  147680. private _highlightsGain;
  147681. private _highlightsThreshold;
  147682. private _dofDistance;
  147683. private _dofAperture;
  147684. private _dofDarken;
  147685. private _dofPentagon;
  147686. private _blurNoise;
  147687. /**
  147688. * @constructor
  147689. *
  147690. * Effect parameters are as follow:
  147691. * {
  147692. * chromatic_aberration: number; // from 0 to x (1 for realism)
  147693. * edge_blur: number; // from 0 to x (1 for realism)
  147694. * distortion: number; // from 0 to x (1 for realism)
  147695. * grain_amount: number; // from 0 to 1
  147696. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  147697. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  147698. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  147699. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  147700. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  147701. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  147702. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  147703. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  147704. * }
  147705. * Note: if an effect parameter is unset, effect is disabled
  147706. *
  147707. * @param name The rendering pipeline name
  147708. * @param parameters - An object containing all parameters (see above)
  147709. * @param scene The scene linked to this pipeline
  147710. * @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)
  147711. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147712. */
  147713. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  147714. /**
  147715. * Get the class name
  147716. * @returns "LensRenderingPipeline"
  147717. */
  147718. getClassName(): string;
  147719. /**
  147720. * Gets associated scene
  147721. */
  147722. get scene(): Scene;
  147723. /**
  147724. * Gets or sets the edge blur
  147725. */
  147726. get edgeBlur(): number;
  147727. set edgeBlur(value: number);
  147728. /**
  147729. * Gets or sets the grain amount
  147730. */
  147731. get grainAmount(): number;
  147732. set grainAmount(value: number);
  147733. /**
  147734. * Gets or sets the chromatic aberration amount
  147735. */
  147736. get chromaticAberration(): number;
  147737. set chromaticAberration(value: number);
  147738. /**
  147739. * Gets or sets the depth of field aperture
  147740. */
  147741. get dofAperture(): number;
  147742. set dofAperture(value: number);
  147743. /**
  147744. * Gets or sets the edge distortion
  147745. */
  147746. get edgeDistortion(): number;
  147747. set edgeDistortion(value: number);
  147748. /**
  147749. * Gets or sets the depth of field distortion
  147750. */
  147751. get dofDistortion(): number;
  147752. set dofDistortion(value: number);
  147753. /**
  147754. * Gets or sets the darken out of focus amount
  147755. */
  147756. get darkenOutOfFocus(): number;
  147757. set darkenOutOfFocus(value: number);
  147758. /**
  147759. * Gets or sets a boolean indicating if blur noise is enabled
  147760. */
  147761. get blurNoise(): boolean;
  147762. set blurNoise(value: boolean);
  147763. /**
  147764. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  147765. */
  147766. get pentagonBokeh(): boolean;
  147767. set pentagonBokeh(value: boolean);
  147768. /**
  147769. * Gets or sets the highlight grain amount
  147770. */
  147771. get highlightsGain(): number;
  147772. set highlightsGain(value: number);
  147773. /**
  147774. * Gets or sets the highlight threshold
  147775. */
  147776. get highlightsThreshold(): number;
  147777. set highlightsThreshold(value: number);
  147778. /**
  147779. * Sets the amount of blur at the edges
  147780. * @param amount blur amount
  147781. */
  147782. setEdgeBlur(amount: number): void;
  147783. /**
  147784. * Sets edge blur to 0
  147785. */
  147786. disableEdgeBlur(): void;
  147787. /**
  147788. * Sets the amout of grain
  147789. * @param amount Amount of grain
  147790. */
  147791. setGrainAmount(amount: number): void;
  147792. /**
  147793. * Set grain amount to 0
  147794. */
  147795. disableGrain(): void;
  147796. /**
  147797. * Sets the chromatic aberration amount
  147798. * @param amount amount of chromatic aberration
  147799. */
  147800. setChromaticAberration(amount: number): void;
  147801. /**
  147802. * Sets chromatic aberration amount to 0
  147803. */
  147804. disableChromaticAberration(): void;
  147805. /**
  147806. * Sets the EdgeDistortion amount
  147807. * @param amount amount of EdgeDistortion
  147808. */
  147809. setEdgeDistortion(amount: number): void;
  147810. /**
  147811. * Sets edge distortion to 0
  147812. */
  147813. disableEdgeDistortion(): void;
  147814. /**
  147815. * Sets the FocusDistance amount
  147816. * @param amount amount of FocusDistance
  147817. */
  147818. setFocusDistance(amount: number): void;
  147819. /**
  147820. * Disables depth of field
  147821. */
  147822. disableDepthOfField(): void;
  147823. /**
  147824. * Sets the Aperture amount
  147825. * @param amount amount of Aperture
  147826. */
  147827. setAperture(amount: number): void;
  147828. /**
  147829. * Sets the DarkenOutOfFocus amount
  147830. * @param amount amount of DarkenOutOfFocus
  147831. */
  147832. setDarkenOutOfFocus(amount: number): void;
  147833. private _pentagonBokehIsEnabled;
  147834. /**
  147835. * Creates a pentagon bokeh effect
  147836. */
  147837. enablePentagonBokeh(): void;
  147838. /**
  147839. * Disables the pentagon bokeh effect
  147840. */
  147841. disablePentagonBokeh(): void;
  147842. /**
  147843. * Enables noise blur
  147844. */
  147845. enableNoiseBlur(): void;
  147846. /**
  147847. * Disables noise blur
  147848. */
  147849. disableNoiseBlur(): void;
  147850. /**
  147851. * Sets the HighlightsGain amount
  147852. * @param amount amount of HighlightsGain
  147853. */
  147854. setHighlightsGain(amount: number): void;
  147855. /**
  147856. * Sets the HighlightsThreshold amount
  147857. * @param amount amount of HighlightsThreshold
  147858. */
  147859. setHighlightsThreshold(amount: number): void;
  147860. /**
  147861. * Disables highlights
  147862. */
  147863. disableHighlights(): void;
  147864. /**
  147865. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  147866. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  147867. */
  147868. dispose(disableDepthRender?: boolean): void;
  147869. private _createChromaticAberrationPostProcess;
  147870. private _createHighlightsPostProcess;
  147871. private _createDepthOfFieldPostProcess;
  147872. private _createGrainTexture;
  147873. }
  147874. }
  147875. declare module BABYLON {
  147876. /** @hidden */
  147877. export var ssao2PixelShader: {
  147878. name: string;
  147879. shader: string;
  147880. };
  147881. }
  147882. declare module BABYLON {
  147883. /** @hidden */
  147884. export var ssaoCombinePixelShader: {
  147885. name: string;
  147886. shader: string;
  147887. };
  147888. }
  147889. declare module BABYLON {
  147890. /**
  147891. * Render pipeline to produce ssao effect
  147892. */
  147893. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  147894. /**
  147895. * @ignore
  147896. * The PassPostProcess id in the pipeline that contains the original scene color
  147897. */
  147898. SSAOOriginalSceneColorEffect: string;
  147899. /**
  147900. * @ignore
  147901. * The SSAO PostProcess id in the pipeline
  147902. */
  147903. SSAORenderEffect: string;
  147904. /**
  147905. * @ignore
  147906. * The horizontal blur PostProcess id in the pipeline
  147907. */
  147908. SSAOBlurHRenderEffect: string;
  147909. /**
  147910. * @ignore
  147911. * The vertical blur PostProcess id in the pipeline
  147912. */
  147913. SSAOBlurVRenderEffect: string;
  147914. /**
  147915. * @ignore
  147916. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147917. */
  147918. SSAOCombineRenderEffect: string;
  147919. /**
  147920. * The output strength of the SSAO post-process. Default value is 1.0.
  147921. */
  147922. totalStrength: number;
  147923. /**
  147924. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  147925. */
  147926. maxZ: number;
  147927. /**
  147928. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  147929. */
  147930. minZAspect: number;
  147931. private _samples;
  147932. /**
  147933. * Number of samples used for the SSAO calculations. Default value is 8
  147934. */
  147935. set samples(n: number);
  147936. get samples(): number;
  147937. private _textureSamples;
  147938. /**
  147939. * Number of samples to use for antialiasing
  147940. */
  147941. set textureSamples(n: number);
  147942. get textureSamples(): number;
  147943. /**
  147944. * Ratio object used for SSAO ratio and blur ratio
  147945. */
  147946. private _ratio;
  147947. /**
  147948. * Dynamically generated sphere sampler.
  147949. */
  147950. private _sampleSphere;
  147951. /**
  147952. * Blur filter offsets
  147953. */
  147954. private _samplerOffsets;
  147955. private _expensiveBlur;
  147956. /**
  147957. * If bilateral blur should be used
  147958. */
  147959. set expensiveBlur(b: boolean);
  147960. get expensiveBlur(): boolean;
  147961. /**
  147962. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  147963. */
  147964. radius: number;
  147965. /**
  147966. * The base color of the SSAO post-process
  147967. * The final result is "base + ssao" between [0, 1]
  147968. */
  147969. base: number;
  147970. /**
  147971. * Support test.
  147972. */
  147973. static get IsSupported(): boolean;
  147974. private _scene;
  147975. private _depthTexture;
  147976. private _normalTexture;
  147977. private _randomTexture;
  147978. private _originalColorPostProcess;
  147979. private _ssaoPostProcess;
  147980. private _blurHPostProcess;
  147981. private _blurVPostProcess;
  147982. private _ssaoCombinePostProcess;
  147983. /**
  147984. * Gets active scene
  147985. */
  147986. get scene(): Scene;
  147987. /**
  147988. * @constructor
  147989. * @param name The rendering pipeline name
  147990. * @param scene The scene linked to this pipeline
  147991. * @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 }
  147992. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147993. */
  147994. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147995. /**
  147996. * Get the class name
  147997. * @returns "SSAO2RenderingPipeline"
  147998. */
  147999. getClassName(): string;
  148000. /**
  148001. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  148002. */
  148003. dispose(disableGeometryBufferRenderer?: boolean): void;
  148004. private _createBlurPostProcess;
  148005. /** @hidden */
  148006. _rebuild(): void;
  148007. private _bits;
  148008. private _radicalInverse_VdC;
  148009. private _hammersley;
  148010. private _hemisphereSample_uniform;
  148011. private _generateHemisphere;
  148012. private _createSSAOPostProcess;
  148013. private _createSSAOCombinePostProcess;
  148014. private _createRandomTexture;
  148015. /**
  148016. * Serialize the rendering pipeline (Used when exporting)
  148017. * @returns the serialized object
  148018. */
  148019. serialize(): any;
  148020. /**
  148021. * Parse the serialized pipeline
  148022. * @param source Source pipeline.
  148023. * @param scene The scene to load the pipeline to.
  148024. * @param rootUrl The URL of the serialized pipeline.
  148025. * @returns An instantiated pipeline from the serialized object.
  148026. */
  148027. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  148028. }
  148029. }
  148030. declare module BABYLON {
  148031. /** @hidden */
  148032. export var ssaoPixelShader: {
  148033. name: string;
  148034. shader: string;
  148035. };
  148036. }
  148037. declare module BABYLON {
  148038. /**
  148039. * Render pipeline to produce ssao effect
  148040. */
  148041. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  148042. /**
  148043. * @ignore
  148044. * The PassPostProcess id in the pipeline that contains the original scene color
  148045. */
  148046. SSAOOriginalSceneColorEffect: string;
  148047. /**
  148048. * @ignore
  148049. * The SSAO PostProcess id in the pipeline
  148050. */
  148051. SSAORenderEffect: string;
  148052. /**
  148053. * @ignore
  148054. * The horizontal blur PostProcess id in the pipeline
  148055. */
  148056. SSAOBlurHRenderEffect: string;
  148057. /**
  148058. * @ignore
  148059. * The vertical blur PostProcess id in the pipeline
  148060. */
  148061. SSAOBlurVRenderEffect: string;
  148062. /**
  148063. * @ignore
  148064. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  148065. */
  148066. SSAOCombineRenderEffect: string;
  148067. /**
  148068. * The output strength of the SSAO post-process. Default value is 1.0.
  148069. */
  148070. totalStrength: number;
  148071. /**
  148072. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  148073. */
  148074. radius: number;
  148075. /**
  148076. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  148077. * Must not be equal to fallOff and superior to fallOff.
  148078. * Default value is 0.0075
  148079. */
  148080. area: number;
  148081. /**
  148082. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  148083. * Must not be equal to area and inferior to area.
  148084. * Default value is 0.000001
  148085. */
  148086. fallOff: number;
  148087. /**
  148088. * The base color of the SSAO post-process
  148089. * The final result is "base + ssao" between [0, 1]
  148090. */
  148091. base: number;
  148092. private _scene;
  148093. private _depthTexture;
  148094. private _randomTexture;
  148095. private _originalColorPostProcess;
  148096. private _ssaoPostProcess;
  148097. private _blurHPostProcess;
  148098. private _blurVPostProcess;
  148099. private _ssaoCombinePostProcess;
  148100. private _firstUpdate;
  148101. /**
  148102. * Gets active scene
  148103. */
  148104. get scene(): Scene;
  148105. /**
  148106. * @constructor
  148107. * @param name - The rendering pipeline name
  148108. * @param scene - The scene linked to this pipeline
  148109. * @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 }
  148110. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  148111. */
  148112. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  148113. /**
  148114. * Get the class name
  148115. * @returns "SSAORenderingPipeline"
  148116. */
  148117. getClassName(): string;
  148118. /**
  148119. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  148120. */
  148121. dispose(disableDepthRender?: boolean): void;
  148122. private _createBlurPostProcess;
  148123. /** @hidden */
  148124. _rebuild(): void;
  148125. private _createSSAOPostProcess;
  148126. private _createSSAOCombinePostProcess;
  148127. private _createRandomTexture;
  148128. }
  148129. }
  148130. declare module BABYLON {
  148131. /** @hidden */
  148132. export var screenSpaceReflectionPixelShader: {
  148133. name: string;
  148134. shader: string;
  148135. };
  148136. }
  148137. declare module BABYLON {
  148138. /**
  148139. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  148140. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  148141. */
  148142. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  148143. /**
  148144. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  148145. */
  148146. threshold: number;
  148147. /**
  148148. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  148149. */
  148150. strength: number;
  148151. /**
  148152. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  148153. */
  148154. reflectionSpecularFalloffExponent: number;
  148155. /**
  148156. * 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]
  148157. */
  148158. step: number;
  148159. /**
  148160. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  148161. */
  148162. roughnessFactor: number;
  148163. private _geometryBufferRenderer;
  148164. private _enableSmoothReflections;
  148165. private _reflectionSamples;
  148166. private _smoothSteps;
  148167. /**
  148168. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  148169. * @param name The name of the effect.
  148170. * @param scene The scene containing the objects to calculate reflections.
  148171. * @param options The required width/height ratio to downsize to before computing the render pass.
  148172. * @param camera The camera to apply the render pass to.
  148173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148174. * @param engine The engine which the post process will be applied. (default: current engine)
  148175. * @param reusable If the post process can be reused on the same frame. (default: false)
  148176. * @param textureType Type of textures used when performing the post process. (default: 0)
  148177. * @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)
  148178. */
  148179. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148180. /**
  148181. * Gets wether or not smoothing reflections is enabled.
  148182. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148183. */
  148184. get enableSmoothReflections(): boolean;
  148185. /**
  148186. * Sets wether or not smoothing reflections is enabled.
  148187. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148188. */
  148189. set enableSmoothReflections(enabled: boolean);
  148190. /**
  148191. * Gets the number of samples taken while computing reflections. More samples count is high,
  148192. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148193. */
  148194. get reflectionSamples(): number;
  148195. /**
  148196. * Sets the number of samples taken while computing reflections. More samples count is high,
  148197. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148198. */
  148199. set reflectionSamples(samples: number);
  148200. /**
  148201. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  148202. * more the post-process will require GPU power and can generate a drop in FPS.
  148203. * Default value (5.0) work pretty well in all cases but can be adjusted.
  148204. */
  148205. get smoothSteps(): number;
  148206. set smoothSteps(steps: number);
  148207. private _updateEffectDefines;
  148208. }
  148209. }
  148210. declare module BABYLON {
  148211. /** @hidden */
  148212. export var standardPixelShader: {
  148213. name: string;
  148214. shader: string;
  148215. };
  148216. }
  148217. declare module BABYLON {
  148218. /**
  148219. * Standard rendering pipeline
  148220. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  148221. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  148222. */
  148223. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  148224. /**
  148225. * Public members
  148226. */
  148227. /**
  148228. * Post-process which contains the original scene color before the pipeline applies all the effects
  148229. */
  148230. originalPostProcess: Nullable<PostProcess>;
  148231. /**
  148232. * Post-process used to down scale an image x4
  148233. */
  148234. downSampleX4PostProcess: Nullable<PostProcess>;
  148235. /**
  148236. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  148237. */
  148238. brightPassPostProcess: Nullable<PostProcess>;
  148239. /**
  148240. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  148241. */
  148242. blurHPostProcesses: PostProcess[];
  148243. /**
  148244. * Post-process array storing all the vertical blur post-processes used by the pipeline
  148245. */
  148246. blurVPostProcesses: PostProcess[];
  148247. /**
  148248. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  148249. */
  148250. textureAdderPostProcess: Nullable<PostProcess>;
  148251. /**
  148252. * Post-process used to create volumetric lighting effect
  148253. */
  148254. volumetricLightPostProcess: Nullable<PostProcess>;
  148255. /**
  148256. * Post-process used to smooth the previous volumetric light post-process on the X axis
  148257. */
  148258. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  148259. /**
  148260. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  148261. */
  148262. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  148263. /**
  148264. * Post-process used to merge the volumetric light effect and the real scene color
  148265. */
  148266. volumetricLightMergePostProces: Nullable<PostProcess>;
  148267. /**
  148268. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  148269. */
  148270. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  148271. /**
  148272. * Base post-process used to calculate the average luminance of the final image for HDR
  148273. */
  148274. luminancePostProcess: Nullable<PostProcess>;
  148275. /**
  148276. * Post-processes used to create down sample post-processes in order to get
  148277. * the average luminance of the final image for HDR
  148278. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  148279. */
  148280. luminanceDownSamplePostProcesses: PostProcess[];
  148281. /**
  148282. * Post-process used to create a HDR effect (light adaptation)
  148283. */
  148284. hdrPostProcess: Nullable<PostProcess>;
  148285. /**
  148286. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  148287. */
  148288. textureAdderFinalPostProcess: Nullable<PostProcess>;
  148289. /**
  148290. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  148291. */
  148292. lensFlareFinalPostProcess: Nullable<PostProcess>;
  148293. /**
  148294. * Post-process used to merge the final HDR post-process and the real scene color
  148295. */
  148296. hdrFinalPostProcess: Nullable<PostProcess>;
  148297. /**
  148298. * Post-process used to create a lens flare effect
  148299. */
  148300. lensFlarePostProcess: Nullable<PostProcess>;
  148301. /**
  148302. * Post-process that merges the result of the lens flare post-process and the real scene color
  148303. */
  148304. lensFlareComposePostProcess: Nullable<PostProcess>;
  148305. /**
  148306. * Post-process used to create a motion blur effect
  148307. */
  148308. motionBlurPostProcess: Nullable<PostProcess>;
  148309. /**
  148310. * Post-process used to create a depth of field effect
  148311. */
  148312. depthOfFieldPostProcess: Nullable<PostProcess>;
  148313. /**
  148314. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  148315. */
  148316. fxaaPostProcess: Nullable<FxaaPostProcess>;
  148317. /**
  148318. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  148319. */
  148320. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  148321. /**
  148322. * Represents the brightness threshold in order to configure the illuminated surfaces
  148323. */
  148324. brightThreshold: number;
  148325. /**
  148326. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  148327. */
  148328. blurWidth: number;
  148329. /**
  148330. * Sets if the blur for highlighted surfaces must be only horizontal
  148331. */
  148332. horizontalBlur: boolean;
  148333. /**
  148334. * Gets the overall exposure used by the pipeline
  148335. */
  148336. get exposure(): number;
  148337. /**
  148338. * Sets the overall exposure used by the pipeline
  148339. */
  148340. set exposure(value: number);
  148341. /**
  148342. * Texture used typically to simulate "dirty" on camera lens
  148343. */
  148344. lensTexture: Nullable<Texture>;
  148345. /**
  148346. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  148347. */
  148348. volumetricLightCoefficient: number;
  148349. /**
  148350. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  148351. */
  148352. volumetricLightPower: number;
  148353. /**
  148354. * Used the set the blur intensity to smooth the volumetric lights
  148355. */
  148356. volumetricLightBlurScale: number;
  148357. /**
  148358. * Light (spot or directional) used to generate the volumetric lights rays
  148359. * The source light must have a shadow generate so the pipeline can get its
  148360. * depth map
  148361. */
  148362. sourceLight: Nullable<SpotLight | DirectionalLight>;
  148363. /**
  148364. * For eye adaptation, represents the minimum luminance the eye can see
  148365. */
  148366. hdrMinimumLuminance: number;
  148367. /**
  148368. * For eye adaptation, represents the decrease luminance speed
  148369. */
  148370. hdrDecreaseRate: number;
  148371. /**
  148372. * For eye adaptation, represents the increase luminance speed
  148373. */
  148374. hdrIncreaseRate: number;
  148375. /**
  148376. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  148377. */
  148378. get hdrAutoExposure(): boolean;
  148379. /**
  148380. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  148381. */
  148382. set hdrAutoExposure(value: boolean);
  148383. /**
  148384. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  148385. */
  148386. lensColorTexture: Nullable<Texture>;
  148387. /**
  148388. * The overall strengh for the lens flare effect
  148389. */
  148390. lensFlareStrength: number;
  148391. /**
  148392. * Dispersion coefficient for lens flare ghosts
  148393. */
  148394. lensFlareGhostDispersal: number;
  148395. /**
  148396. * Main lens flare halo width
  148397. */
  148398. lensFlareHaloWidth: number;
  148399. /**
  148400. * Based on the lens distortion effect, defines how much the lens flare result
  148401. * is distorted
  148402. */
  148403. lensFlareDistortionStrength: number;
  148404. /**
  148405. * Configures the blur intensity used for for lens flare (halo)
  148406. */
  148407. lensFlareBlurWidth: number;
  148408. /**
  148409. * Lens star texture must be used to simulate rays on the flares and is available
  148410. * in the documentation
  148411. */
  148412. lensStarTexture: Nullable<Texture>;
  148413. /**
  148414. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  148415. * flare effect by taking account of the dirt texture
  148416. */
  148417. lensFlareDirtTexture: Nullable<Texture>;
  148418. /**
  148419. * Represents the focal length for the depth of field effect
  148420. */
  148421. depthOfFieldDistance: number;
  148422. /**
  148423. * Represents the blur intensity for the blurred part of the depth of field effect
  148424. */
  148425. depthOfFieldBlurWidth: number;
  148426. /**
  148427. * Gets how much the image is blurred by the movement while using the motion blur post-process
  148428. */
  148429. get motionStrength(): number;
  148430. /**
  148431. * Sets how much the image is blurred by the movement while using the motion blur post-process
  148432. */
  148433. set motionStrength(strength: number);
  148434. /**
  148435. * Gets wether or not the motion blur post-process is object based or screen based.
  148436. */
  148437. get objectBasedMotionBlur(): boolean;
  148438. /**
  148439. * Sets wether or not the motion blur post-process should be object based or screen based
  148440. */
  148441. set objectBasedMotionBlur(value: boolean);
  148442. /**
  148443. * List of animations for the pipeline (IAnimatable implementation)
  148444. */
  148445. animations: Animation[];
  148446. /**
  148447. * Private members
  148448. */
  148449. private _scene;
  148450. private _currentDepthOfFieldSource;
  148451. private _basePostProcess;
  148452. private _fixedExposure;
  148453. private _currentExposure;
  148454. private _hdrAutoExposure;
  148455. private _hdrCurrentLuminance;
  148456. private _motionStrength;
  148457. private _isObjectBasedMotionBlur;
  148458. private _floatTextureType;
  148459. private _camerasToBeAttached;
  148460. private _ratio;
  148461. private _bloomEnabled;
  148462. private _depthOfFieldEnabled;
  148463. private _vlsEnabled;
  148464. private _lensFlareEnabled;
  148465. private _hdrEnabled;
  148466. private _motionBlurEnabled;
  148467. private _fxaaEnabled;
  148468. private _screenSpaceReflectionsEnabled;
  148469. private _motionBlurSamples;
  148470. private _volumetricLightStepsCount;
  148471. private _samples;
  148472. /**
  148473. * @ignore
  148474. * Specifies if the bloom pipeline is enabled
  148475. */
  148476. get BloomEnabled(): boolean;
  148477. set BloomEnabled(enabled: boolean);
  148478. /**
  148479. * @ignore
  148480. * Specifies if the depth of field pipeline is enabed
  148481. */
  148482. get DepthOfFieldEnabled(): boolean;
  148483. set DepthOfFieldEnabled(enabled: boolean);
  148484. /**
  148485. * @ignore
  148486. * Specifies if the lens flare pipeline is enabed
  148487. */
  148488. get LensFlareEnabled(): boolean;
  148489. set LensFlareEnabled(enabled: boolean);
  148490. /**
  148491. * @ignore
  148492. * Specifies if the HDR pipeline is enabled
  148493. */
  148494. get HDREnabled(): boolean;
  148495. set HDREnabled(enabled: boolean);
  148496. /**
  148497. * @ignore
  148498. * Specifies if the volumetric lights scattering effect is enabled
  148499. */
  148500. get VLSEnabled(): boolean;
  148501. set VLSEnabled(enabled: boolean);
  148502. /**
  148503. * @ignore
  148504. * Specifies if the motion blur effect is enabled
  148505. */
  148506. get MotionBlurEnabled(): boolean;
  148507. set MotionBlurEnabled(enabled: boolean);
  148508. /**
  148509. * Specifies if anti-aliasing is enabled
  148510. */
  148511. get fxaaEnabled(): boolean;
  148512. set fxaaEnabled(enabled: boolean);
  148513. /**
  148514. * Specifies if screen space reflections are enabled.
  148515. */
  148516. get screenSpaceReflectionsEnabled(): boolean;
  148517. set screenSpaceReflectionsEnabled(enabled: boolean);
  148518. /**
  148519. * Specifies the number of steps used to calculate the volumetric lights
  148520. * Typically in interval [50, 200]
  148521. */
  148522. get volumetricLightStepsCount(): number;
  148523. set volumetricLightStepsCount(count: number);
  148524. /**
  148525. * Specifies the number of samples used for the motion blur effect
  148526. * Typically in interval [16, 64]
  148527. */
  148528. get motionBlurSamples(): number;
  148529. set motionBlurSamples(samples: number);
  148530. /**
  148531. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  148532. */
  148533. get samples(): number;
  148534. set samples(sampleCount: number);
  148535. /**
  148536. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  148537. * @constructor
  148538. * @param name The rendering pipeline name
  148539. * @param scene The scene linked to this pipeline
  148540. * @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)
  148541. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  148542. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148543. */
  148544. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  148545. private _buildPipeline;
  148546. private _createDownSampleX4PostProcess;
  148547. private _createBrightPassPostProcess;
  148548. private _createBlurPostProcesses;
  148549. private _createTextureAdderPostProcess;
  148550. private _createVolumetricLightPostProcess;
  148551. private _createLuminancePostProcesses;
  148552. private _createHdrPostProcess;
  148553. private _createLensFlarePostProcess;
  148554. private _createDepthOfFieldPostProcess;
  148555. private _createMotionBlurPostProcess;
  148556. private _getDepthTexture;
  148557. private _disposePostProcesses;
  148558. /**
  148559. * Dispose of the pipeline and stop all post processes
  148560. */
  148561. dispose(): void;
  148562. /**
  148563. * Serialize the rendering pipeline (Used when exporting)
  148564. * @returns the serialized object
  148565. */
  148566. serialize(): any;
  148567. /**
  148568. * Parse the serialized pipeline
  148569. * @param source Source pipeline.
  148570. * @param scene The scene to load the pipeline to.
  148571. * @param rootUrl The URL of the serialized pipeline.
  148572. * @returns An instantiated pipeline from the serialized object.
  148573. */
  148574. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  148575. /**
  148576. * Luminance steps
  148577. */
  148578. static LuminanceSteps: number;
  148579. }
  148580. }
  148581. declare module BABYLON {
  148582. /** @hidden */
  148583. export var stereoscopicInterlacePixelShader: {
  148584. name: string;
  148585. shader: string;
  148586. };
  148587. }
  148588. declare module BABYLON {
  148589. /**
  148590. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  148591. */
  148592. export class StereoscopicInterlacePostProcessI extends PostProcess {
  148593. private _stepSize;
  148594. private _passedProcess;
  148595. /**
  148596. * Initializes a StereoscopicInterlacePostProcessI
  148597. * @param name The name of the effect.
  148598. * @param rigCameras The rig cameras to be appled to the post process
  148599. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  148600. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  148601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148602. * @param engine The engine which the post process will be applied. (default: current engine)
  148603. * @param reusable If the post process can be reused on the same frame. (default: false)
  148604. */
  148605. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148606. }
  148607. /**
  148608. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  148609. */
  148610. export class StereoscopicInterlacePostProcess extends PostProcess {
  148611. private _stepSize;
  148612. private _passedProcess;
  148613. /**
  148614. * Initializes a StereoscopicInterlacePostProcess
  148615. * @param name The name of the effect.
  148616. * @param rigCameras The rig cameras to be appled to the post process
  148617. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  148618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148619. * @param engine The engine which the post process will be applied. (default: current engine)
  148620. * @param reusable If the post process can be reused on the same frame. (default: false)
  148621. */
  148622. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148623. }
  148624. }
  148625. declare module BABYLON {
  148626. /** @hidden */
  148627. export var tonemapPixelShader: {
  148628. name: string;
  148629. shader: string;
  148630. };
  148631. }
  148632. declare module BABYLON {
  148633. /** Defines operator used for tonemapping */
  148634. export enum TonemappingOperator {
  148635. /** Hable */
  148636. Hable = 0,
  148637. /** Reinhard */
  148638. Reinhard = 1,
  148639. /** HejiDawson */
  148640. HejiDawson = 2,
  148641. /** Photographic */
  148642. Photographic = 3
  148643. }
  148644. /**
  148645. * Defines a post process to apply tone mapping
  148646. */
  148647. export class TonemapPostProcess extends PostProcess {
  148648. private _operator;
  148649. /** Defines the required exposure adjustement */
  148650. exposureAdjustment: number;
  148651. /**
  148652. * Creates a new TonemapPostProcess
  148653. * @param name defines the name of the postprocess
  148654. * @param _operator defines the operator to use
  148655. * @param exposureAdjustment defines the required exposure adjustement
  148656. * @param camera defines the camera to use (can be null)
  148657. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  148658. * @param engine defines the hosting engine (can be ignore if camera is set)
  148659. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  148660. */
  148661. constructor(name: string, _operator: TonemappingOperator,
  148662. /** Defines the required exposure adjustement */
  148663. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  148664. }
  148665. }
  148666. declare module BABYLON {
  148667. /** @hidden */
  148668. export var volumetricLightScatteringPixelShader: {
  148669. name: string;
  148670. shader: string;
  148671. };
  148672. }
  148673. declare module BABYLON {
  148674. /** @hidden */
  148675. export var volumetricLightScatteringPassVertexShader: {
  148676. name: string;
  148677. shader: string;
  148678. };
  148679. }
  148680. declare module BABYLON {
  148681. /** @hidden */
  148682. export var volumetricLightScatteringPassPixelShader: {
  148683. name: string;
  148684. shader: string;
  148685. };
  148686. }
  148687. declare module BABYLON {
  148688. /**
  148689. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  148690. */
  148691. export class VolumetricLightScatteringPostProcess extends PostProcess {
  148692. private _volumetricLightScatteringPass;
  148693. private _volumetricLightScatteringRTT;
  148694. private _viewPort;
  148695. private _screenCoordinates;
  148696. private _cachedDefines;
  148697. /**
  148698. * If not undefined, the mesh position is computed from the attached node position
  148699. */
  148700. attachedNode: {
  148701. position: Vector3;
  148702. };
  148703. /**
  148704. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  148705. */
  148706. customMeshPosition: Vector3;
  148707. /**
  148708. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  148709. */
  148710. useCustomMeshPosition: boolean;
  148711. /**
  148712. * If the post-process should inverse the light scattering direction
  148713. */
  148714. invert: boolean;
  148715. /**
  148716. * The internal mesh used by the post-process
  148717. */
  148718. mesh: Mesh;
  148719. /**
  148720. * @hidden
  148721. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  148722. */
  148723. get useDiffuseColor(): boolean;
  148724. set useDiffuseColor(useDiffuseColor: boolean);
  148725. /**
  148726. * Array containing the excluded meshes not rendered in the internal pass
  148727. */
  148728. excludedMeshes: AbstractMesh[];
  148729. /**
  148730. * Controls the overall intensity of the post-process
  148731. */
  148732. exposure: number;
  148733. /**
  148734. * Dissipates each sample's contribution in range [0, 1]
  148735. */
  148736. decay: number;
  148737. /**
  148738. * Controls the overall intensity of each sample
  148739. */
  148740. weight: number;
  148741. /**
  148742. * Controls the density of each sample
  148743. */
  148744. density: number;
  148745. /**
  148746. * @constructor
  148747. * @param name The post-process name
  148748. * @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)
  148749. * @param camera The camera that the post-process will be attached to
  148750. * @param mesh The mesh used to create the light scattering
  148751. * @param samples The post-process quality, default 100
  148752. * @param samplingModeThe post-process filtering mode
  148753. * @param engine The babylon engine
  148754. * @param reusable If the post-process is reusable
  148755. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  148756. */
  148757. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  148758. /**
  148759. * Returns the string "VolumetricLightScatteringPostProcess"
  148760. * @returns "VolumetricLightScatteringPostProcess"
  148761. */
  148762. getClassName(): string;
  148763. private _isReady;
  148764. /**
  148765. * Sets the new light position for light scattering effect
  148766. * @param position The new custom light position
  148767. */
  148768. setCustomMeshPosition(position: Vector3): void;
  148769. /**
  148770. * Returns the light position for light scattering effect
  148771. * @return Vector3 The custom light position
  148772. */
  148773. getCustomMeshPosition(): Vector3;
  148774. /**
  148775. * Disposes the internal assets and detaches the post-process from the camera
  148776. */
  148777. dispose(camera: Camera): void;
  148778. /**
  148779. * Returns the render target texture used by the post-process
  148780. * @return the render target texture used by the post-process
  148781. */
  148782. getPass(): RenderTargetTexture;
  148783. private _meshExcluded;
  148784. private _createPass;
  148785. private _updateMeshScreenCoordinates;
  148786. /**
  148787. * Creates a default mesh for the Volumeric Light Scattering post-process
  148788. * @param name The mesh name
  148789. * @param scene The scene where to create the mesh
  148790. * @return the default mesh
  148791. */
  148792. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  148793. }
  148794. }
  148795. declare module BABYLON {
  148796. interface Scene {
  148797. /** @hidden (Backing field) */
  148798. _boundingBoxRenderer: BoundingBoxRenderer;
  148799. /** @hidden (Backing field) */
  148800. _forceShowBoundingBoxes: boolean;
  148801. /**
  148802. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  148803. */
  148804. forceShowBoundingBoxes: boolean;
  148805. /**
  148806. * Gets the bounding box renderer associated with the scene
  148807. * @returns a BoundingBoxRenderer
  148808. */
  148809. getBoundingBoxRenderer(): BoundingBoxRenderer;
  148810. }
  148811. interface AbstractMesh {
  148812. /** @hidden (Backing field) */
  148813. _showBoundingBox: boolean;
  148814. /**
  148815. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  148816. */
  148817. showBoundingBox: boolean;
  148818. }
  148819. /**
  148820. * Component responsible of rendering the bounding box of the meshes in a scene.
  148821. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  148822. */
  148823. export class BoundingBoxRenderer implements ISceneComponent {
  148824. /**
  148825. * The component name helpfull to identify the component in the list of scene components.
  148826. */
  148827. readonly name: string;
  148828. /**
  148829. * The scene the component belongs to.
  148830. */
  148831. scene: Scene;
  148832. /**
  148833. * Color of the bounding box lines placed in front of an object
  148834. */
  148835. frontColor: Color3;
  148836. /**
  148837. * Color of the bounding box lines placed behind an object
  148838. */
  148839. backColor: Color3;
  148840. /**
  148841. * Defines if the renderer should show the back lines or not
  148842. */
  148843. showBackLines: boolean;
  148844. /**
  148845. * Observable raised before rendering a bounding box
  148846. */
  148847. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  148848. /**
  148849. * Observable raised after rendering a bounding box
  148850. */
  148851. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  148852. /**
  148853. * @hidden
  148854. */
  148855. renderList: SmartArray<BoundingBox>;
  148856. private _colorShader;
  148857. private _vertexBuffers;
  148858. private _indexBuffer;
  148859. private _fillIndexBuffer;
  148860. private _fillIndexData;
  148861. /**
  148862. * Instantiates a new bounding box renderer in a scene.
  148863. * @param scene the scene the renderer renders in
  148864. */
  148865. constructor(scene: Scene);
  148866. /**
  148867. * Registers the component in a given scene
  148868. */
  148869. register(): void;
  148870. private _evaluateSubMesh;
  148871. private _activeMesh;
  148872. private _prepareRessources;
  148873. private _createIndexBuffer;
  148874. /**
  148875. * Rebuilds the elements related to this component in case of
  148876. * context lost for instance.
  148877. */
  148878. rebuild(): void;
  148879. /**
  148880. * @hidden
  148881. */
  148882. reset(): void;
  148883. /**
  148884. * Render the bounding boxes of a specific rendering group
  148885. * @param renderingGroupId defines the rendering group to render
  148886. */
  148887. render(renderingGroupId: number): void;
  148888. /**
  148889. * In case of occlusion queries, we can render the occlusion bounding box through this method
  148890. * @param mesh Define the mesh to render the occlusion bounding box for
  148891. */
  148892. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  148893. /**
  148894. * Dispose and release the resources attached to this renderer.
  148895. */
  148896. dispose(): void;
  148897. }
  148898. }
  148899. declare module BABYLON {
  148900. interface Scene {
  148901. /** @hidden (Backing field) */
  148902. _depthRenderer: {
  148903. [id: string]: DepthRenderer;
  148904. };
  148905. /**
  148906. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  148907. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  148908. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  148909. * @returns the created depth renderer
  148910. */
  148911. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  148912. /**
  148913. * Disables a depth renderer for a given camera
  148914. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  148915. */
  148916. disableDepthRenderer(camera?: Nullable<Camera>): void;
  148917. }
  148918. /**
  148919. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  148920. * in several rendering techniques.
  148921. */
  148922. export class DepthRendererSceneComponent implements ISceneComponent {
  148923. /**
  148924. * The component name helpfull to identify the component in the list of scene components.
  148925. */
  148926. readonly name: string;
  148927. /**
  148928. * The scene the component belongs to.
  148929. */
  148930. scene: Scene;
  148931. /**
  148932. * Creates a new instance of the component for the given scene
  148933. * @param scene Defines the scene to register the component in
  148934. */
  148935. constructor(scene: Scene);
  148936. /**
  148937. * Registers the component in a given scene
  148938. */
  148939. register(): void;
  148940. /**
  148941. * Rebuilds the elements related to this component in case of
  148942. * context lost for instance.
  148943. */
  148944. rebuild(): void;
  148945. /**
  148946. * Disposes the component and the associated ressources
  148947. */
  148948. dispose(): void;
  148949. private _gatherRenderTargets;
  148950. private _gatherActiveCameraRenderTargets;
  148951. }
  148952. }
  148953. declare module BABYLON {
  148954. /** @hidden */
  148955. export var fibonacci: {
  148956. name: string;
  148957. shader: string;
  148958. };
  148959. }
  148960. declare module BABYLON {
  148961. /** @hidden */
  148962. export var diffusionProfile: {
  148963. name: string;
  148964. shader: string;
  148965. };
  148966. }
  148967. declare module BABYLON {
  148968. /** @hidden */
  148969. export var subSurfaceScatteringPixelShader: {
  148970. name: string;
  148971. shader: string;
  148972. };
  148973. }
  148974. declare module BABYLON {
  148975. /**
  148976. * Sub surface scattering post process
  148977. */
  148978. export class SubSurfaceScatteringPostProcess extends PostProcess {
  148979. /** @hidden */
  148980. texelWidth: number;
  148981. /** @hidden */
  148982. texelHeight: number;
  148983. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148984. }
  148985. }
  148986. declare module BABYLON {
  148987. /**
  148988. * Contains all parameters needed for the prepass to perform
  148989. * screen space subsurface scattering
  148990. */
  148991. export class SubSurfaceConfiguration {
  148992. private _ssDiffusionS;
  148993. private _ssFilterRadii;
  148994. private _ssDiffusionD;
  148995. /**
  148996. * Diffusion profile color for subsurface scattering
  148997. */
  148998. get ssDiffusionS(): number[];
  148999. /**
  149000. * Diffusion profile max color channel value for subsurface scattering
  149001. */
  149002. get ssDiffusionD(): number[];
  149003. /**
  149004. * Diffusion profile filter radius for subsurface scattering
  149005. */
  149006. get ssFilterRadii(): number[];
  149007. /**
  149008. * Diffusion profile colors for subsurface scattering
  149009. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  149010. * See ...
  149011. * Note that you can only store up to 5 of them
  149012. */
  149013. ssDiffusionProfileColors: Color3[];
  149014. /**
  149015. * Defines the ratio real world => scene units.
  149016. * Used for subsurface scattering
  149017. */
  149018. metersPerUnit: number;
  149019. /**
  149020. * Builds a subsurface configuration object
  149021. * @param scene The scene
  149022. */
  149023. constructor();
  149024. /**
  149025. * Adds a new diffusion profile.
  149026. * Useful for more realistic subsurface scattering on diverse materials.
  149027. * @param color The color of the diffusion profile. Should be the average color of the material.
  149028. * @return The index of the diffusion profile for the material subsurface configuration
  149029. */
  149030. addDiffusionProfile(color: Color3): number;
  149031. /**
  149032. * Deletes all diffusion profiles.
  149033. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  149034. */
  149035. clearAllDiffusionProfiles(): void;
  149036. /**
  149037. * Disposes this object
  149038. */
  149039. dispose(): void;
  149040. /**
  149041. * @hidden
  149042. * https://zero-radiance.github.io/post/sampling-diffusion/
  149043. *
  149044. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  149045. * ------------------------------------------------------------------------------------
  149046. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  149047. * PDF[r, phi, s] = r * R[r, phi, s]
  149048. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  149049. * ------------------------------------------------------------------------------------
  149050. * We importance sample the color channel with the widest scattering distance.
  149051. */
  149052. getDiffusionProfileParameters(color: Color3): number;
  149053. /**
  149054. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  149055. * 'u' is the random number (the value of the CDF): [0, 1).
  149056. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  149057. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  149058. */
  149059. private _sampleBurleyDiffusionProfile;
  149060. }
  149061. }
  149062. declare module BABYLON {
  149063. /**
  149064. * Renders a pre pass of the scene
  149065. * This means every mesh in the scene will be rendered to a render target texture
  149066. * And then this texture will be composited to the rendering canvas with post processes
  149067. * It is necessary for effects like subsurface scattering or deferred shading
  149068. */
  149069. export class PrePassRenderer {
  149070. /** @hidden */
  149071. static _SceneComponentInitialization: (scene: Scene) => void;
  149072. private _scene;
  149073. private _engine;
  149074. private _isDirty;
  149075. /**
  149076. * Number of textures in the multi render target texture where the scene is directly rendered
  149077. */
  149078. readonly mrtCount: number;
  149079. /**
  149080. * The render target where the scene is directly rendered
  149081. */
  149082. prePassRT: MultiRenderTarget;
  149083. private _mrtTypes;
  149084. private _multiRenderAttachments;
  149085. private _defaultAttachments;
  149086. private _clearAttachments;
  149087. private readonly _clearColor;
  149088. /**
  149089. * Image processing post process for composition
  149090. */
  149091. imageProcessingPostProcess: ImageProcessingPostProcess;
  149092. /**
  149093. * Post process for subsurface scattering
  149094. */
  149095. subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
  149096. /**
  149097. * Configuration for sub surface scattering post process
  149098. */
  149099. subSurfaceConfiguration: SubSurfaceConfiguration;
  149100. private _enabled;
  149101. /**
  149102. * Indicates if the prepass is enabled
  149103. */
  149104. get enabled(): boolean;
  149105. /**
  149106. * How many samples are used for MSAA of the scene render target
  149107. */
  149108. get samples(): number;
  149109. set samples(n: number);
  149110. /**
  149111. * Instanciates a prepass renderer
  149112. * @param scene The scene
  149113. */
  149114. constructor(scene: Scene);
  149115. private _initializeAttachments;
  149116. private _createEffects;
  149117. /**
  149118. * Indicates if rendering a prepass is supported
  149119. */
  149120. get isSupported(): boolean;
  149121. /**
  149122. * Sets the proper output textures to draw in the engine.
  149123. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  149124. */
  149125. bindAttachmentsForEffect(effect: Effect): void;
  149126. /**
  149127. * @hidden
  149128. */
  149129. _beforeCameraDraw(): void;
  149130. /**
  149131. * @hidden
  149132. */
  149133. _afterCameraDraw(): void;
  149134. private _checkRTSize;
  149135. private _bindFrameBuffer;
  149136. /**
  149137. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  149138. */
  149139. clear(): void;
  149140. private _setState;
  149141. private _enable;
  149142. private _disable;
  149143. /**
  149144. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  149145. */
  149146. markAsDirty(): void;
  149147. private _update;
  149148. /**
  149149. * Disposes the prepass renderer.
  149150. */
  149151. dispose(): void;
  149152. }
  149153. }
  149154. declare module BABYLON {
  149155. interface AbstractScene {
  149156. /** @hidden (Backing field) */
  149157. _prePassRenderer: Nullable<PrePassRenderer>;
  149158. /**
  149159. * Gets or Sets the current prepass renderer associated to the scene.
  149160. */
  149161. prePassRenderer: Nullable<PrePassRenderer>;
  149162. /**
  149163. * Enables the prepass and associates it with the scene
  149164. * @returns the PrePassRenderer
  149165. */
  149166. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  149167. /**
  149168. * Disables the prepass associated with the scene
  149169. */
  149170. disablePrePassRenderer(): void;
  149171. }
  149172. /**
  149173. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149174. * in several rendering techniques.
  149175. */
  149176. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  149177. /**
  149178. * The component name helpful to identify the component in the list of scene components.
  149179. */
  149180. readonly name: string;
  149181. /**
  149182. * The scene the component belongs to.
  149183. */
  149184. scene: Scene;
  149185. /**
  149186. * Creates a new instance of the component for the given scene
  149187. * @param scene Defines the scene to register the component in
  149188. */
  149189. constructor(scene: Scene);
  149190. /**
  149191. * Registers the component in a given scene
  149192. */
  149193. register(): void;
  149194. private _beforeCameraDraw;
  149195. private _afterCameraDraw;
  149196. private _beforeClearStage;
  149197. /**
  149198. * Serializes the component data to the specified json object
  149199. * @param serializationObject The object to serialize to
  149200. */
  149201. serialize(serializationObject: any): void;
  149202. /**
  149203. * Adds all the elements from the container to the scene
  149204. * @param container the container holding the elements
  149205. */
  149206. addFromContainer(container: AbstractScene): void;
  149207. /**
  149208. * Removes all the elements in the container from the scene
  149209. * @param container contains the elements to remove
  149210. * @param dispose if the removed element should be disposed (default: false)
  149211. */
  149212. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  149213. /**
  149214. * Rebuilds the elements related to this component in case of
  149215. * context lost for instance.
  149216. */
  149217. rebuild(): void;
  149218. /**
  149219. * Disposes the component and the associated ressources
  149220. */
  149221. dispose(): void;
  149222. }
  149223. }
  149224. declare module BABYLON {
  149225. /** @hidden */
  149226. export var outlinePixelShader: {
  149227. name: string;
  149228. shader: string;
  149229. };
  149230. }
  149231. declare module BABYLON {
  149232. /** @hidden */
  149233. export var outlineVertexShader: {
  149234. name: string;
  149235. shader: string;
  149236. };
  149237. }
  149238. declare module BABYLON {
  149239. interface Scene {
  149240. /** @hidden */
  149241. _outlineRenderer: OutlineRenderer;
  149242. /**
  149243. * Gets the outline renderer associated with the scene
  149244. * @returns a OutlineRenderer
  149245. */
  149246. getOutlineRenderer(): OutlineRenderer;
  149247. }
  149248. interface AbstractMesh {
  149249. /** @hidden (Backing field) */
  149250. _renderOutline: boolean;
  149251. /**
  149252. * Gets or sets a boolean indicating if the outline must be rendered as well
  149253. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  149254. */
  149255. renderOutline: boolean;
  149256. /** @hidden (Backing field) */
  149257. _renderOverlay: boolean;
  149258. /**
  149259. * Gets or sets a boolean indicating if the overlay must be rendered as well
  149260. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  149261. */
  149262. renderOverlay: boolean;
  149263. }
  149264. /**
  149265. * This class is responsible to draw bothe outline/overlay of meshes.
  149266. * It should not be used directly but through the available method on mesh.
  149267. */
  149268. export class OutlineRenderer implements ISceneComponent {
  149269. /**
  149270. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  149271. */
  149272. private static _StencilReference;
  149273. /**
  149274. * The name of the component. Each component must have a unique name.
  149275. */
  149276. name: string;
  149277. /**
  149278. * The scene the component belongs to.
  149279. */
  149280. scene: Scene;
  149281. /**
  149282. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  149283. */
  149284. zOffset: number;
  149285. private _engine;
  149286. private _effect;
  149287. private _cachedDefines;
  149288. private _savedDepthWrite;
  149289. /**
  149290. * Instantiates a new outline renderer. (There could be only one per scene).
  149291. * @param scene Defines the scene it belongs to
  149292. */
  149293. constructor(scene: Scene);
  149294. /**
  149295. * Register the component to one instance of a scene.
  149296. */
  149297. register(): void;
  149298. /**
  149299. * Rebuilds the elements related to this component in case of
  149300. * context lost for instance.
  149301. */
  149302. rebuild(): void;
  149303. /**
  149304. * Disposes the component and the associated ressources.
  149305. */
  149306. dispose(): void;
  149307. /**
  149308. * Renders the outline in the canvas.
  149309. * @param subMesh Defines the sumesh to render
  149310. * @param batch Defines the batch of meshes in case of instances
  149311. * @param useOverlay Defines if the rendering is for the overlay or the outline
  149312. */
  149313. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  149314. /**
  149315. * Returns whether or not the outline renderer is ready for a given submesh.
  149316. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  149317. * @param subMesh Defines the submesh to check readyness for
  149318. * @param useInstances Defines wheter wee are trying to render instances or not
  149319. * @returns true if ready otherwise false
  149320. */
  149321. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149322. private _beforeRenderingMesh;
  149323. private _afterRenderingMesh;
  149324. }
  149325. }
  149326. declare module BABYLON {
  149327. /**
  149328. * Defines the basic options interface of a Sprite Frame Source Size.
  149329. */
  149330. export interface ISpriteJSONSpriteSourceSize {
  149331. /**
  149332. * number of the original width of the Frame
  149333. */
  149334. w: number;
  149335. /**
  149336. * number of the original height of the Frame
  149337. */
  149338. h: number;
  149339. }
  149340. /**
  149341. * Defines the basic options interface of a Sprite Frame Data.
  149342. */
  149343. export interface ISpriteJSONSpriteFrameData {
  149344. /**
  149345. * number of the x offset of the Frame
  149346. */
  149347. x: number;
  149348. /**
  149349. * number of the y offset of the Frame
  149350. */
  149351. y: number;
  149352. /**
  149353. * number of the width of the Frame
  149354. */
  149355. w: number;
  149356. /**
  149357. * number of the height of the Frame
  149358. */
  149359. h: number;
  149360. }
  149361. /**
  149362. * Defines the basic options interface of a JSON Sprite.
  149363. */
  149364. export interface ISpriteJSONSprite {
  149365. /**
  149366. * string name of the Frame
  149367. */
  149368. filename: string;
  149369. /**
  149370. * ISpriteJSONSpriteFrame basic object of the frame data
  149371. */
  149372. frame: ISpriteJSONSpriteFrameData;
  149373. /**
  149374. * boolean to flag is the frame was rotated.
  149375. */
  149376. rotated: boolean;
  149377. /**
  149378. * boolean to flag is the frame was trimmed.
  149379. */
  149380. trimmed: boolean;
  149381. /**
  149382. * ISpriteJSONSpriteFrame basic object of the source data
  149383. */
  149384. spriteSourceSize: ISpriteJSONSpriteFrameData;
  149385. /**
  149386. * ISpriteJSONSpriteFrame basic object of the source data
  149387. */
  149388. sourceSize: ISpriteJSONSpriteSourceSize;
  149389. }
  149390. /**
  149391. * Defines the basic options interface of a JSON atlas.
  149392. */
  149393. export interface ISpriteJSONAtlas {
  149394. /**
  149395. * Array of objects that contain the frame data.
  149396. */
  149397. frames: Array<ISpriteJSONSprite>;
  149398. /**
  149399. * object basic object containing the sprite meta data.
  149400. */
  149401. meta?: object;
  149402. }
  149403. }
  149404. declare module BABYLON {
  149405. /** @hidden */
  149406. export var spriteMapPixelShader: {
  149407. name: string;
  149408. shader: string;
  149409. };
  149410. }
  149411. declare module BABYLON {
  149412. /** @hidden */
  149413. export var spriteMapVertexShader: {
  149414. name: string;
  149415. shader: string;
  149416. };
  149417. }
  149418. declare module BABYLON {
  149419. /**
  149420. * Defines the basic options interface of a SpriteMap
  149421. */
  149422. export interface ISpriteMapOptions {
  149423. /**
  149424. * Vector2 of the number of cells in the grid.
  149425. */
  149426. stageSize?: Vector2;
  149427. /**
  149428. * Vector2 of the size of the output plane in World Units.
  149429. */
  149430. outputSize?: Vector2;
  149431. /**
  149432. * Vector3 of the position of the output plane in World Units.
  149433. */
  149434. outputPosition?: Vector3;
  149435. /**
  149436. * Vector3 of the rotation of the output plane.
  149437. */
  149438. outputRotation?: Vector3;
  149439. /**
  149440. * number of layers that the system will reserve in resources.
  149441. */
  149442. layerCount?: number;
  149443. /**
  149444. * number of max animation frames a single cell will reserve in resources.
  149445. */
  149446. maxAnimationFrames?: number;
  149447. /**
  149448. * number cell index of the base tile when the system compiles.
  149449. */
  149450. baseTile?: number;
  149451. /**
  149452. * boolean flip the sprite after its been repositioned by the framing data.
  149453. */
  149454. flipU?: boolean;
  149455. /**
  149456. * Vector3 scalar of the global RGB values of the SpriteMap.
  149457. */
  149458. colorMultiply?: Vector3;
  149459. }
  149460. /**
  149461. * Defines the IDisposable interface in order to be cleanable from resources.
  149462. */
  149463. export interface ISpriteMap extends IDisposable {
  149464. /**
  149465. * String name of the SpriteMap.
  149466. */
  149467. name: string;
  149468. /**
  149469. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  149470. */
  149471. atlasJSON: ISpriteJSONAtlas;
  149472. /**
  149473. * Texture of the SpriteMap.
  149474. */
  149475. spriteSheet: Texture;
  149476. /**
  149477. * The parameters to initialize the SpriteMap with.
  149478. */
  149479. options: ISpriteMapOptions;
  149480. }
  149481. /**
  149482. * Class used to manage a grid restricted sprite deployment on an Output plane.
  149483. */
  149484. export class SpriteMap implements ISpriteMap {
  149485. /** The Name of the spriteMap */
  149486. name: string;
  149487. /** The JSON file with the frame and meta data */
  149488. atlasJSON: ISpriteJSONAtlas;
  149489. /** The systems Sprite Sheet Texture */
  149490. spriteSheet: Texture;
  149491. /** Arguments passed with the Constructor */
  149492. options: ISpriteMapOptions;
  149493. /** Public Sprite Storage array, parsed from atlasJSON */
  149494. sprites: Array<ISpriteJSONSprite>;
  149495. /** Returns the Number of Sprites in the System */
  149496. get spriteCount(): number;
  149497. /** Returns the Position of Output Plane*/
  149498. get position(): Vector3;
  149499. /** Returns the Position of Output Plane*/
  149500. set position(v: Vector3);
  149501. /** Returns the Rotation of Output Plane*/
  149502. get rotation(): Vector3;
  149503. /** Returns the Rotation of Output Plane*/
  149504. set rotation(v: Vector3);
  149505. /** Sets the AnimationMap*/
  149506. get animationMap(): RawTexture;
  149507. /** Sets the AnimationMap*/
  149508. set animationMap(v: RawTexture);
  149509. /** Scene that the SpriteMap was created in */
  149510. private _scene;
  149511. /** Texture Buffer of Float32 that holds tile frame data*/
  149512. private _frameMap;
  149513. /** Texture Buffers of Float32 that holds tileMap data*/
  149514. private _tileMaps;
  149515. /** Texture Buffer of Float32 that holds Animation Data*/
  149516. private _animationMap;
  149517. /** Custom ShaderMaterial Central to the System*/
  149518. private _material;
  149519. /** Custom ShaderMaterial Central to the System*/
  149520. private _output;
  149521. /** Systems Time Ticker*/
  149522. private _time;
  149523. /**
  149524. * Creates a new SpriteMap
  149525. * @param name defines the SpriteMaps Name
  149526. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  149527. * @param spriteSheet is the Texture that the Sprites are on.
  149528. * @param options a basic deployment configuration
  149529. * @param scene The Scene that the map is deployed on
  149530. */
  149531. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  149532. /**
  149533. * Returns tileID location
  149534. * @returns Vector2 the cell position ID
  149535. */
  149536. getTileID(): Vector2;
  149537. /**
  149538. * Gets the UV location of the mouse over the SpriteMap.
  149539. * @returns Vector2 the UV position of the mouse interaction
  149540. */
  149541. getMousePosition(): Vector2;
  149542. /**
  149543. * Creates the "frame" texture Buffer
  149544. * -------------------------------------
  149545. * Structure of frames
  149546. * "filename": "Falling-Water-2.png",
  149547. * "frame": {"x":69,"y":103,"w":24,"h":32},
  149548. * "rotated": true,
  149549. * "trimmed": true,
  149550. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  149551. * "sourceSize": {"w":32,"h":32}
  149552. * @returns RawTexture of the frameMap
  149553. */
  149554. private _createFrameBuffer;
  149555. /**
  149556. * Creates the tileMap texture Buffer
  149557. * @param buffer normally and array of numbers, or a false to generate from scratch
  149558. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  149559. * @returns RawTexture of the tileMap
  149560. */
  149561. private _createTileBuffer;
  149562. /**
  149563. * Modifies the data of the tileMaps
  149564. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  149565. * @param pos is the iVector2 Coordinates of the Tile
  149566. * @param tile The SpriteIndex of the new Tile
  149567. */
  149568. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  149569. /**
  149570. * Creates the animationMap texture Buffer
  149571. * @param buffer normally and array of numbers, or a false to generate from scratch
  149572. * @returns RawTexture of the animationMap
  149573. */
  149574. private _createTileAnimationBuffer;
  149575. /**
  149576. * Modifies the data of the animationMap
  149577. * @param cellID is the Index of the Sprite
  149578. * @param _frame is the target Animation frame
  149579. * @param toCell is the Target Index of the next frame of the animation
  149580. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  149581. * @param speed is a global scalar of the time variable on the map.
  149582. */
  149583. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  149584. /**
  149585. * Exports the .tilemaps file
  149586. */
  149587. saveTileMaps(): void;
  149588. /**
  149589. * Imports the .tilemaps file
  149590. * @param url of the .tilemaps file
  149591. */
  149592. loadTileMaps(url: string): void;
  149593. /**
  149594. * Release associated resources
  149595. */
  149596. dispose(): void;
  149597. }
  149598. }
  149599. declare module BABYLON {
  149600. /**
  149601. * Class used to manage multiple sprites of different sizes on the same spritesheet
  149602. * @see https://doc.babylonjs.com/babylon101/sprites
  149603. */
  149604. export class SpritePackedManager extends SpriteManager {
  149605. /** defines the packed manager's name */
  149606. name: string;
  149607. /**
  149608. * Creates a new sprite manager from a packed sprite sheet
  149609. * @param name defines the manager's name
  149610. * @param imgUrl defines the sprite sheet url
  149611. * @param capacity defines the maximum allowed number of sprites
  149612. * @param scene defines the hosting scene
  149613. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  149614. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  149615. * @param samplingMode defines the smapling mode to use with spritesheet
  149616. * @param fromPacked set to true; do not alter
  149617. */
  149618. constructor(
  149619. /** defines the packed manager's name */
  149620. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  149621. }
  149622. }
  149623. declare module BABYLON {
  149624. /**
  149625. * Defines the list of states available for a task inside a AssetsManager
  149626. */
  149627. export enum AssetTaskState {
  149628. /**
  149629. * Initialization
  149630. */
  149631. INIT = 0,
  149632. /**
  149633. * Running
  149634. */
  149635. RUNNING = 1,
  149636. /**
  149637. * Done
  149638. */
  149639. DONE = 2,
  149640. /**
  149641. * Error
  149642. */
  149643. ERROR = 3
  149644. }
  149645. /**
  149646. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  149647. */
  149648. export abstract class AbstractAssetTask {
  149649. /**
  149650. * Task name
  149651. */ name: string;
  149652. /**
  149653. * Callback called when the task is successful
  149654. */
  149655. onSuccess: (task: any) => void;
  149656. /**
  149657. * Callback called when the task is not successful
  149658. */
  149659. onError: (task: any, message?: string, exception?: any) => void;
  149660. /**
  149661. * Creates a new AssetsManager
  149662. * @param name defines the name of the task
  149663. */
  149664. constructor(
  149665. /**
  149666. * Task name
  149667. */ name: string);
  149668. private _isCompleted;
  149669. private _taskState;
  149670. private _errorObject;
  149671. /**
  149672. * Get if the task is completed
  149673. */
  149674. get isCompleted(): boolean;
  149675. /**
  149676. * Gets the current state of the task
  149677. */
  149678. get taskState(): AssetTaskState;
  149679. /**
  149680. * Gets the current error object (if task is in error)
  149681. */
  149682. get errorObject(): {
  149683. message?: string;
  149684. exception?: any;
  149685. };
  149686. /**
  149687. * Internal only
  149688. * @hidden
  149689. */
  149690. _setErrorObject(message?: string, exception?: any): void;
  149691. /**
  149692. * Execute the current task
  149693. * @param scene defines the scene where you want your assets to be loaded
  149694. * @param onSuccess is a callback called when the task is successfully executed
  149695. * @param onError is a callback called if an error occurs
  149696. */
  149697. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149698. /**
  149699. * Execute the current task
  149700. * @param scene defines the scene where you want your assets to be loaded
  149701. * @param onSuccess is a callback called when the task is successfully executed
  149702. * @param onError is a callback called if an error occurs
  149703. */
  149704. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149705. /**
  149706. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  149707. * This can be used with failed tasks that have the reason for failure fixed.
  149708. */
  149709. reset(): void;
  149710. private onErrorCallback;
  149711. private onDoneCallback;
  149712. }
  149713. /**
  149714. * Define the interface used by progress events raised during assets loading
  149715. */
  149716. export interface IAssetsProgressEvent {
  149717. /**
  149718. * Defines the number of remaining tasks to process
  149719. */
  149720. remainingCount: number;
  149721. /**
  149722. * Defines the total number of tasks
  149723. */
  149724. totalCount: number;
  149725. /**
  149726. * Defines the task that was just processed
  149727. */
  149728. task: AbstractAssetTask;
  149729. }
  149730. /**
  149731. * Class used to share progress information about assets loading
  149732. */
  149733. export class AssetsProgressEvent implements IAssetsProgressEvent {
  149734. /**
  149735. * Defines the number of remaining tasks to process
  149736. */
  149737. remainingCount: number;
  149738. /**
  149739. * Defines the total number of tasks
  149740. */
  149741. totalCount: number;
  149742. /**
  149743. * Defines the task that was just processed
  149744. */
  149745. task: AbstractAssetTask;
  149746. /**
  149747. * Creates a AssetsProgressEvent
  149748. * @param remainingCount defines the number of remaining tasks to process
  149749. * @param totalCount defines the total number of tasks
  149750. * @param task defines the task that was just processed
  149751. */
  149752. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  149753. }
  149754. /**
  149755. * Define a task used by AssetsManager to load meshes
  149756. */
  149757. export class MeshAssetTask extends AbstractAssetTask {
  149758. /**
  149759. * Defines the name of the task
  149760. */
  149761. name: string;
  149762. /**
  149763. * Defines the list of mesh's names you want to load
  149764. */
  149765. meshesNames: any;
  149766. /**
  149767. * Defines the root url to use as a base to load your meshes and associated resources
  149768. */
  149769. rootUrl: string;
  149770. /**
  149771. * Defines the filename or File of the scene to load from
  149772. */
  149773. sceneFilename: string | File;
  149774. /**
  149775. * Gets the list of loaded meshes
  149776. */
  149777. loadedMeshes: Array<AbstractMesh>;
  149778. /**
  149779. * Gets the list of loaded particle systems
  149780. */
  149781. loadedParticleSystems: Array<IParticleSystem>;
  149782. /**
  149783. * Gets the list of loaded skeletons
  149784. */
  149785. loadedSkeletons: Array<Skeleton>;
  149786. /**
  149787. * Gets the list of loaded animation groups
  149788. */
  149789. loadedAnimationGroups: Array<AnimationGroup>;
  149790. /**
  149791. * Callback called when the task is successful
  149792. */
  149793. onSuccess: (task: MeshAssetTask) => void;
  149794. /**
  149795. * Callback called when the task is successful
  149796. */
  149797. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  149798. /**
  149799. * Creates a new MeshAssetTask
  149800. * @param name defines the name of the task
  149801. * @param meshesNames defines the list of mesh's names you want to load
  149802. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  149803. * @param sceneFilename defines the filename or File of the scene to load from
  149804. */
  149805. constructor(
  149806. /**
  149807. * Defines the name of the task
  149808. */
  149809. name: string,
  149810. /**
  149811. * Defines the list of mesh's names you want to load
  149812. */
  149813. meshesNames: any,
  149814. /**
  149815. * Defines the root url to use as a base to load your meshes and associated resources
  149816. */
  149817. rootUrl: string,
  149818. /**
  149819. * Defines the filename or File of the scene to load from
  149820. */
  149821. sceneFilename: string | File);
  149822. /**
  149823. * Execute the current task
  149824. * @param scene defines the scene where you want your assets to be loaded
  149825. * @param onSuccess is a callback called when the task is successfully executed
  149826. * @param onError is a callback called if an error occurs
  149827. */
  149828. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149829. }
  149830. /**
  149831. * Define a task used by AssetsManager to load text content
  149832. */
  149833. export class TextFileAssetTask extends AbstractAssetTask {
  149834. /**
  149835. * Defines the name of the task
  149836. */
  149837. name: string;
  149838. /**
  149839. * Defines the location of the file to load
  149840. */
  149841. url: string;
  149842. /**
  149843. * Gets the loaded text string
  149844. */
  149845. text: string;
  149846. /**
  149847. * Callback called when the task is successful
  149848. */
  149849. onSuccess: (task: TextFileAssetTask) => void;
  149850. /**
  149851. * Callback called when the task is successful
  149852. */
  149853. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  149854. /**
  149855. * Creates a new TextFileAssetTask object
  149856. * @param name defines the name of the task
  149857. * @param url defines the location of the file to load
  149858. */
  149859. constructor(
  149860. /**
  149861. * Defines the name of the task
  149862. */
  149863. name: string,
  149864. /**
  149865. * Defines the location of the file to load
  149866. */
  149867. url: string);
  149868. /**
  149869. * Execute the current task
  149870. * @param scene defines the scene where you want your assets to be loaded
  149871. * @param onSuccess is a callback called when the task is successfully executed
  149872. * @param onError is a callback called if an error occurs
  149873. */
  149874. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149875. }
  149876. /**
  149877. * Define a task used by AssetsManager to load binary data
  149878. */
  149879. export class BinaryFileAssetTask extends AbstractAssetTask {
  149880. /**
  149881. * Defines the name of the task
  149882. */
  149883. name: string;
  149884. /**
  149885. * Defines the location of the file to load
  149886. */
  149887. url: string;
  149888. /**
  149889. * Gets the lodaded data (as an array buffer)
  149890. */
  149891. data: ArrayBuffer;
  149892. /**
  149893. * Callback called when the task is successful
  149894. */
  149895. onSuccess: (task: BinaryFileAssetTask) => void;
  149896. /**
  149897. * Callback called when the task is successful
  149898. */
  149899. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  149900. /**
  149901. * Creates a new BinaryFileAssetTask object
  149902. * @param name defines the name of the new task
  149903. * @param url defines the location of the file to load
  149904. */
  149905. constructor(
  149906. /**
  149907. * Defines the name of the task
  149908. */
  149909. name: string,
  149910. /**
  149911. * Defines the location of the file to load
  149912. */
  149913. url: string);
  149914. /**
  149915. * Execute the current task
  149916. * @param scene defines the scene where you want your assets to be loaded
  149917. * @param onSuccess is a callback called when the task is successfully executed
  149918. * @param onError is a callback called if an error occurs
  149919. */
  149920. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149921. }
  149922. /**
  149923. * Define a task used by AssetsManager to load images
  149924. */
  149925. export class ImageAssetTask extends AbstractAssetTask {
  149926. /**
  149927. * Defines the name of the task
  149928. */
  149929. name: string;
  149930. /**
  149931. * Defines the location of the image to load
  149932. */
  149933. url: string;
  149934. /**
  149935. * Gets the loaded images
  149936. */
  149937. image: HTMLImageElement;
  149938. /**
  149939. * Callback called when the task is successful
  149940. */
  149941. onSuccess: (task: ImageAssetTask) => void;
  149942. /**
  149943. * Callback called when the task is successful
  149944. */
  149945. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  149946. /**
  149947. * Creates a new ImageAssetTask
  149948. * @param name defines the name of the task
  149949. * @param url defines the location of the image to load
  149950. */
  149951. constructor(
  149952. /**
  149953. * Defines the name of the task
  149954. */
  149955. name: string,
  149956. /**
  149957. * Defines the location of the image to load
  149958. */
  149959. url: string);
  149960. /**
  149961. * Execute the current task
  149962. * @param scene defines the scene where you want your assets to be loaded
  149963. * @param onSuccess is a callback called when the task is successfully executed
  149964. * @param onError is a callback called if an error occurs
  149965. */
  149966. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149967. }
  149968. /**
  149969. * Defines the interface used by texture loading tasks
  149970. */
  149971. export interface ITextureAssetTask<TEX extends BaseTexture> {
  149972. /**
  149973. * Gets the loaded texture
  149974. */
  149975. texture: TEX;
  149976. }
  149977. /**
  149978. * Define a task used by AssetsManager to load 2D textures
  149979. */
  149980. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  149981. /**
  149982. * Defines the name of the task
  149983. */
  149984. name: string;
  149985. /**
  149986. * Defines the location of the file to load
  149987. */
  149988. url: string;
  149989. /**
  149990. * Defines if mipmap should not be generated (default is false)
  149991. */
  149992. noMipmap?: boolean | undefined;
  149993. /**
  149994. * Defines if texture must be inverted on Y axis (default is true)
  149995. */
  149996. invertY: boolean;
  149997. /**
  149998. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149999. */
  150000. samplingMode: number;
  150001. /**
  150002. * Gets the loaded texture
  150003. */
  150004. texture: Texture;
  150005. /**
  150006. * Callback called when the task is successful
  150007. */
  150008. onSuccess: (task: TextureAssetTask) => void;
  150009. /**
  150010. * Callback called when the task is successful
  150011. */
  150012. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  150013. /**
  150014. * Creates a new TextureAssetTask object
  150015. * @param name defines the name of the task
  150016. * @param url defines the location of the file to load
  150017. * @param noMipmap defines if mipmap should not be generated (default is false)
  150018. * @param invertY defines if texture must be inverted on Y axis (default is true)
  150019. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150020. */
  150021. constructor(
  150022. /**
  150023. * Defines the name of the task
  150024. */
  150025. name: string,
  150026. /**
  150027. * Defines the location of the file to load
  150028. */
  150029. url: string,
  150030. /**
  150031. * Defines if mipmap should not be generated (default is false)
  150032. */
  150033. noMipmap?: boolean | undefined,
  150034. /**
  150035. * Defines if texture must be inverted on Y axis (default is true)
  150036. */
  150037. invertY?: boolean,
  150038. /**
  150039. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150040. */
  150041. samplingMode?: number);
  150042. /**
  150043. * Execute the current task
  150044. * @param scene defines the scene where you want your assets to be loaded
  150045. * @param onSuccess is a callback called when the task is successfully executed
  150046. * @param onError is a callback called if an error occurs
  150047. */
  150048. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150049. }
  150050. /**
  150051. * Define a task used by AssetsManager to load cube textures
  150052. */
  150053. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  150054. /**
  150055. * Defines the name of the task
  150056. */
  150057. name: string;
  150058. /**
  150059. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150060. */
  150061. url: string;
  150062. /**
  150063. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150064. */
  150065. extensions?: string[] | undefined;
  150066. /**
  150067. * Defines if mipmaps should not be generated (default is false)
  150068. */
  150069. noMipmap?: boolean | undefined;
  150070. /**
  150071. * Defines the explicit list of files (undefined by default)
  150072. */
  150073. files?: string[] | undefined;
  150074. /**
  150075. * Gets the loaded texture
  150076. */
  150077. texture: CubeTexture;
  150078. /**
  150079. * Callback called when the task is successful
  150080. */
  150081. onSuccess: (task: CubeTextureAssetTask) => void;
  150082. /**
  150083. * Callback called when the task is successful
  150084. */
  150085. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  150086. /**
  150087. * Creates a new CubeTextureAssetTask
  150088. * @param name defines the name of the task
  150089. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150090. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150091. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150092. * @param files defines the explicit list of files (undefined by default)
  150093. */
  150094. constructor(
  150095. /**
  150096. * Defines the name of the task
  150097. */
  150098. name: string,
  150099. /**
  150100. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150101. */
  150102. url: string,
  150103. /**
  150104. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150105. */
  150106. extensions?: string[] | undefined,
  150107. /**
  150108. * Defines if mipmaps should not be generated (default is false)
  150109. */
  150110. noMipmap?: boolean | undefined,
  150111. /**
  150112. * Defines the explicit list of files (undefined by default)
  150113. */
  150114. files?: string[] | undefined);
  150115. /**
  150116. * Execute the current task
  150117. * @param scene defines the scene where you want your assets to be loaded
  150118. * @param onSuccess is a callback called when the task is successfully executed
  150119. * @param onError is a callback called if an error occurs
  150120. */
  150121. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150122. }
  150123. /**
  150124. * Define a task used by AssetsManager to load HDR cube textures
  150125. */
  150126. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  150127. /**
  150128. * Defines the name of the task
  150129. */
  150130. name: string;
  150131. /**
  150132. * Defines the location of the file to load
  150133. */
  150134. url: string;
  150135. /**
  150136. * Defines the desired size (the more it increases the longer the generation will be)
  150137. */
  150138. size: number;
  150139. /**
  150140. * Defines if mipmaps should not be generated (default is false)
  150141. */
  150142. noMipmap: boolean;
  150143. /**
  150144. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150145. */
  150146. generateHarmonics: boolean;
  150147. /**
  150148. * 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)
  150149. */
  150150. gammaSpace: boolean;
  150151. /**
  150152. * Internal Use Only
  150153. */
  150154. reserved: boolean;
  150155. /**
  150156. * Gets the loaded texture
  150157. */
  150158. texture: HDRCubeTexture;
  150159. /**
  150160. * Callback called when the task is successful
  150161. */
  150162. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  150163. /**
  150164. * Callback called when the task is successful
  150165. */
  150166. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  150167. /**
  150168. * Creates a new HDRCubeTextureAssetTask object
  150169. * @param name defines the name of the task
  150170. * @param url defines the location of the file to load
  150171. * @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.
  150172. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150173. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150174. * @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)
  150175. * @param reserved Internal use only
  150176. */
  150177. constructor(
  150178. /**
  150179. * Defines the name of the task
  150180. */
  150181. name: string,
  150182. /**
  150183. * Defines the location of the file to load
  150184. */
  150185. url: string,
  150186. /**
  150187. * Defines the desired size (the more it increases the longer the generation will be)
  150188. */
  150189. size: number,
  150190. /**
  150191. * Defines if mipmaps should not be generated (default is false)
  150192. */
  150193. noMipmap?: boolean,
  150194. /**
  150195. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150196. */
  150197. generateHarmonics?: boolean,
  150198. /**
  150199. * 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)
  150200. */
  150201. gammaSpace?: boolean,
  150202. /**
  150203. * Internal Use Only
  150204. */
  150205. reserved?: boolean);
  150206. /**
  150207. * Execute the current task
  150208. * @param scene defines the scene where you want your assets to be loaded
  150209. * @param onSuccess is a callback called when the task is successfully executed
  150210. * @param onError is a callback called if an error occurs
  150211. */
  150212. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150213. }
  150214. /**
  150215. * Define a task used by AssetsManager to load Equirectangular cube textures
  150216. */
  150217. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  150218. /**
  150219. * Defines the name of the task
  150220. */
  150221. name: string;
  150222. /**
  150223. * Defines the location of the file to load
  150224. */
  150225. url: string;
  150226. /**
  150227. * Defines the desired size (the more it increases the longer the generation will be)
  150228. */
  150229. size: number;
  150230. /**
  150231. * Defines if mipmaps should not be generated (default is false)
  150232. */
  150233. noMipmap: boolean;
  150234. /**
  150235. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150236. * but the standard material would require them in Gamma space) (default is true)
  150237. */
  150238. gammaSpace: boolean;
  150239. /**
  150240. * Gets the loaded texture
  150241. */
  150242. texture: EquiRectangularCubeTexture;
  150243. /**
  150244. * Callback called when the task is successful
  150245. */
  150246. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  150247. /**
  150248. * Callback called when the task is successful
  150249. */
  150250. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  150251. /**
  150252. * Creates a new EquiRectangularCubeTextureAssetTask object
  150253. * @param name defines the name of the task
  150254. * @param url defines the location of the file to load
  150255. * @param size defines the desired size (the more it increases the longer the generation will be)
  150256. * If the size is omitted this implies you are using a preprocessed cubemap.
  150257. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150258. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  150259. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  150260. * (default is true)
  150261. */
  150262. constructor(
  150263. /**
  150264. * Defines the name of the task
  150265. */
  150266. name: string,
  150267. /**
  150268. * Defines the location of the file to load
  150269. */
  150270. url: string,
  150271. /**
  150272. * Defines the desired size (the more it increases the longer the generation will be)
  150273. */
  150274. size: number,
  150275. /**
  150276. * Defines if mipmaps should not be generated (default is false)
  150277. */
  150278. noMipmap?: boolean,
  150279. /**
  150280. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150281. * but the standard material would require them in Gamma space) (default is true)
  150282. */
  150283. gammaSpace?: boolean);
  150284. /**
  150285. * Execute the current task
  150286. * @param scene defines the scene where you want your assets to be loaded
  150287. * @param onSuccess is a callback called when the task is successfully executed
  150288. * @param onError is a callback called if an error occurs
  150289. */
  150290. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150291. }
  150292. /**
  150293. * This class can be used to easily import assets into a scene
  150294. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  150295. */
  150296. export class AssetsManager {
  150297. private _scene;
  150298. private _isLoading;
  150299. protected _tasks: AbstractAssetTask[];
  150300. protected _waitingTasksCount: number;
  150301. protected _totalTasksCount: number;
  150302. /**
  150303. * Callback called when all tasks are processed
  150304. */
  150305. onFinish: (tasks: AbstractAssetTask[]) => void;
  150306. /**
  150307. * Callback called when a task is successful
  150308. */
  150309. onTaskSuccess: (task: AbstractAssetTask) => void;
  150310. /**
  150311. * Callback called when a task had an error
  150312. */
  150313. onTaskError: (task: AbstractAssetTask) => void;
  150314. /**
  150315. * Callback called when a task is done (whatever the result is)
  150316. */
  150317. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  150318. /**
  150319. * Observable called when all tasks are processed
  150320. */
  150321. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  150322. /**
  150323. * Observable called when a task had an error
  150324. */
  150325. onTaskErrorObservable: Observable<AbstractAssetTask>;
  150326. /**
  150327. * Observable called when all tasks were executed
  150328. */
  150329. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  150330. /**
  150331. * Observable called when a task is done (whatever the result is)
  150332. */
  150333. onProgressObservable: Observable<IAssetsProgressEvent>;
  150334. /**
  150335. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  150336. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  150337. */
  150338. useDefaultLoadingScreen: boolean;
  150339. /**
  150340. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  150341. * when all assets have been downloaded.
  150342. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  150343. */
  150344. autoHideLoadingUI: boolean;
  150345. /**
  150346. * Creates a new AssetsManager
  150347. * @param scene defines the scene to work on
  150348. */
  150349. constructor(scene: Scene);
  150350. /**
  150351. * Add a MeshAssetTask to the list of active tasks
  150352. * @param taskName defines the name of the new task
  150353. * @param meshesNames defines the name of meshes to load
  150354. * @param rootUrl defines the root url to use to locate files
  150355. * @param sceneFilename defines the filename of the scene file
  150356. * @returns a new MeshAssetTask object
  150357. */
  150358. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  150359. /**
  150360. * Add a TextFileAssetTask to the list of active tasks
  150361. * @param taskName defines the name of the new task
  150362. * @param url defines the url of the file to load
  150363. * @returns a new TextFileAssetTask object
  150364. */
  150365. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  150366. /**
  150367. * Add a BinaryFileAssetTask to the list of active tasks
  150368. * @param taskName defines the name of the new task
  150369. * @param url defines the url of the file to load
  150370. * @returns a new BinaryFileAssetTask object
  150371. */
  150372. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  150373. /**
  150374. * Add a ImageAssetTask to the list of active tasks
  150375. * @param taskName defines the name of the new task
  150376. * @param url defines the url of the file to load
  150377. * @returns a new ImageAssetTask object
  150378. */
  150379. addImageTask(taskName: string, url: string): ImageAssetTask;
  150380. /**
  150381. * Add a TextureAssetTask to the list of active tasks
  150382. * @param taskName defines the name of the new task
  150383. * @param url defines the url of the file to load
  150384. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150385. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  150386. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  150387. * @returns a new TextureAssetTask object
  150388. */
  150389. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  150390. /**
  150391. * Add a CubeTextureAssetTask to the list of active tasks
  150392. * @param taskName defines the name of the new task
  150393. * @param url defines the url of the file to load
  150394. * @param extensions defines the extension to use to load the cube map (can be null)
  150395. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150396. * @param files defines the list of files to load (can be null)
  150397. * @returns a new CubeTextureAssetTask object
  150398. */
  150399. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  150400. /**
  150401. *
  150402. * Add a HDRCubeTextureAssetTask to the list of active tasks
  150403. * @param taskName defines the name of the new task
  150404. * @param url defines the url of the file to load
  150405. * @param size defines the size you want for the cubemap (can be null)
  150406. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150407. * @param generateHarmonics defines if you want to automatically generate (true by default)
  150408. * @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)
  150409. * @param reserved Internal use only
  150410. * @returns a new HDRCubeTextureAssetTask object
  150411. */
  150412. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  150413. /**
  150414. *
  150415. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  150416. * @param taskName defines the name of the new task
  150417. * @param url defines the url of the file to load
  150418. * @param size defines the size you want for the cubemap (can be null)
  150419. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150420. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  150421. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  150422. * @returns a new EquiRectangularCubeTextureAssetTask object
  150423. */
  150424. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  150425. /**
  150426. * Remove a task from the assets manager.
  150427. * @param task the task to remove
  150428. */
  150429. removeTask(task: AbstractAssetTask): void;
  150430. private _decreaseWaitingTasksCount;
  150431. private _runTask;
  150432. /**
  150433. * Reset the AssetsManager and remove all tasks
  150434. * @return the current instance of the AssetsManager
  150435. */
  150436. reset(): AssetsManager;
  150437. /**
  150438. * Start the loading process
  150439. * @return the current instance of the AssetsManager
  150440. */
  150441. load(): AssetsManager;
  150442. /**
  150443. * Start the loading process as an async operation
  150444. * @return a promise returning the list of failed tasks
  150445. */
  150446. loadAsync(): Promise<void>;
  150447. }
  150448. }
  150449. declare module BABYLON {
  150450. /**
  150451. * Wrapper class for promise with external resolve and reject.
  150452. */
  150453. export class Deferred<T> {
  150454. /**
  150455. * The promise associated with this deferred object.
  150456. */
  150457. readonly promise: Promise<T>;
  150458. private _resolve;
  150459. private _reject;
  150460. /**
  150461. * The resolve method of the promise associated with this deferred object.
  150462. */
  150463. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  150464. /**
  150465. * The reject method of the promise associated with this deferred object.
  150466. */
  150467. get reject(): (reason?: any) => void;
  150468. /**
  150469. * Constructor for this deferred object.
  150470. */
  150471. constructor();
  150472. }
  150473. }
  150474. declare module BABYLON {
  150475. /**
  150476. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  150477. */
  150478. export class MeshExploder {
  150479. private _centerMesh;
  150480. private _meshes;
  150481. private _meshesOrigins;
  150482. private _toCenterVectors;
  150483. private _scaledDirection;
  150484. private _newPosition;
  150485. private _centerPosition;
  150486. /**
  150487. * Explodes meshes from a center mesh.
  150488. * @param meshes The meshes to explode.
  150489. * @param centerMesh The mesh to be center of explosion.
  150490. */
  150491. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  150492. private _setCenterMesh;
  150493. /**
  150494. * Get class name
  150495. * @returns "MeshExploder"
  150496. */
  150497. getClassName(): string;
  150498. /**
  150499. * "Exploded meshes"
  150500. * @returns Array of meshes with the centerMesh at index 0.
  150501. */
  150502. getMeshes(): Array<Mesh>;
  150503. /**
  150504. * Explodes meshes giving a specific direction
  150505. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  150506. */
  150507. explode(direction?: number): void;
  150508. }
  150509. }
  150510. declare module BABYLON {
  150511. /**
  150512. * Class used to help managing file picking and drag'n'drop
  150513. */
  150514. export class FilesInput {
  150515. /**
  150516. * List of files ready to be loaded
  150517. */
  150518. static get FilesToLoad(): {
  150519. [key: string]: File;
  150520. };
  150521. /**
  150522. * Callback called when a file is processed
  150523. */
  150524. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  150525. private _engine;
  150526. private _currentScene;
  150527. private _sceneLoadedCallback;
  150528. private _progressCallback;
  150529. private _additionalRenderLoopLogicCallback;
  150530. private _textureLoadingCallback;
  150531. private _startingProcessingFilesCallback;
  150532. private _onReloadCallback;
  150533. private _errorCallback;
  150534. private _elementToMonitor;
  150535. private _sceneFileToLoad;
  150536. private _filesToLoad;
  150537. /**
  150538. * Creates a new FilesInput
  150539. * @param engine defines the rendering engine
  150540. * @param scene defines the hosting scene
  150541. * @param sceneLoadedCallback callback called when scene is loaded
  150542. * @param progressCallback callback called to track progress
  150543. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  150544. * @param textureLoadingCallback callback called when a texture is loading
  150545. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  150546. * @param onReloadCallback callback called when a reload is requested
  150547. * @param errorCallback callback call if an error occurs
  150548. */
  150549. 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>);
  150550. private _dragEnterHandler;
  150551. private _dragOverHandler;
  150552. private _dropHandler;
  150553. /**
  150554. * Calls this function to listen to drag'n'drop events on a specific DOM element
  150555. * @param elementToMonitor defines the DOM element to track
  150556. */
  150557. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  150558. /** Gets the current list of files to load */
  150559. get filesToLoad(): File[];
  150560. /**
  150561. * Release all associated resources
  150562. */
  150563. dispose(): void;
  150564. private renderFunction;
  150565. private drag;
  150566. private drop;
  150567. private _traverseFolder;
  150568. private _processFiles;
  150569. /**
  150570. * Load files from a drop event
  150571. * @param event defines the drop event to use as source
  150572. */
  150573. loadFiles(event: any): void;
  150574. private _processReload;
  150575. /**
  150576. * Reload the current scene from the loaded files
  150577. */
  150578. reload(): void;
  150579. }
  150580. }
  150581. declare module BABYLON {
  150582. /**
  150583. * Defines the root class used to create scene optimization to use with SceneOptimizer
  150584. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150585. */
  150586. export class SceneOptimization {
  150587. /**
  150588. * Defines the priority of this optimization (0 by default which means first in the list)
  150589. */
  150590. priority: number;
  150591. /**
  150592. * Gets a string describing the action executed by the current optimization
  150593. * @returns description string
  150594. */
  150595. getDescription(): string;
  150596. /**
  150597. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150598. * @param scene defines the current scene where to apply this optimization
  150599. * @param optimizer defines the current optimizer
  150600. * @returns true if everything that can be done was applied
  150601. */
  150602. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150603. /**
  150604. * Creates the SceneOptimization object
  150605. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150606. * @param desc defines the description associated with the optimization
  150607. */
  150608. constructor(
  150609. /**
  150610. * Defines the priority of this optimization (0 by default which means first in the list)
  150611. */
  150612. priority?: number);
  150613. }
  150614. /**
  150615. * Defines an optimization used to reduce the size of render target textures
  150616. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150617. */
  150618. export class TextureOptimization extends SceneOptimization {
  150619. /**
  150620. * Defines the priority of this optimization (0 by default which means first in the list)
  150621. */
  150622. priority: number;
  150623. /**
  150624. * 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
  150625. */
  150626. maximumSize: number;
  150627. /**
  150628. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150629. */
  150630. step: number;
  150631. /**
  150632. * Gets a string describing the action executed by the current optimization
  150633. * @returns description string
  150634. */
  150635. getDescription(): string;
  150636. /**
  150637. * Creates the TextureOptimization object
  150638. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150639. * @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
  150640. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150641. */
  150642. constructor(
  150643. /**
  150644. * Defines the priority of this optimization (0 by default which means first in the list)
  150645. */
  150646. priority?: number,
  150647. /**
  150648. * 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
  150649. */
  150650. maximumSize?: number,
  150651. /**
  150652. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150653. */
  150654. step?: number);
  150655. /**
  150656. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150657. * @param scene defines the current scene where to apply this optimization
  150658. * @param optimizer defines the current optimizer
  150659. * @returns true if everything that can be done was applied
  150660. */
  150661. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150662. }
  150663. /**
  150664. * Defines an optimization used to increase or decrease the rendering resolution
  150665. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150666. */
  150667. export class HardwareScalingOptimization extends SceneOptimization {
  150668. /**
  150669. * Defines the priority of this optimization (0 by default which means first in the list)
  150670. */
  150671. priority: number;
  150672. /**
  150673. * Defines the maximum scale to use (2 by default)
  150674. */
  150675. maximumScale: number;
  150676. /**
  150677. * Defines the step to use between two passes (0.5 by default)
  150678. */
  150679. step: number;
  150680. private _currentScale;
  150681. private _directionOffset;
  150682. /**
  150683. * Gets a string describing the action executed by the current optimization
  150684. * @return description string
  150685. */
  150686. getDescription(): string;
  150687. /**
  150688. * Creates the HardwareScalingOptimization object
  150689. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150690. * @param maximumScale defines the maximum scale to use (2 by default)
  150691. * @param step defines the step to use between two passes (0.5 by default)
  150692. */
  150693. constructor(
  150694. /**
  150695. * Defines the priority of this optimization (0 by default which means first in the list)
  150696. */
  150697. priority?: number,
  150698. /**
  150699. * Defines the maximum scale to use (2 by default)
  150700. */
  150701. maximumScale?: number,
  150702. /**
  150703. * Defines the step to use between two passes (0.5 by default)
  150704. */
  150705. step?: number);
  150706. /**
  150707. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150708. * @param scene defines the current scene where to apply this optimization
  150709. * @param optimizer defines the current optimizer
  150710. * @returns true if everything that can be done was applied
  150711. */
  150712. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150713. }
  150714. /**
  150715. * Defines an optimization used to remove shadows
  150716. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150717. */
  150718. export class ShadowsOptimization extends SceneOptimization {
  150719. /**
  150720. * Gets a string describing the action executed by the current optimization
  150721. * @return description string
  150722. */
  150723. getDescription(): string;
  150724. /**
  150725. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150726. * @param scene defines the current scene where to apply this optimization
  150727. * @param optimizer defines the current optimizer
  150728. * @returns true if everything that can be done was applied
  150729. */
  150730. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150731. }
  150732. /**
  150733. * Defines an optimization used to turn post-processes off
  150734. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150735. */
  150736. export class PostProcessesOptimization extends SceneOptimization {
  150737. /**
  150738. * Gets a string describing the action executed by the current optimization
  150739. * @return description string
  150740. */
  150741. getDescription(): string;
  150742. /**
  150743. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150744. * @param scene defines the current scene where to apply this optimization
  150745. * @param optimizer defines the current optimizer
  150746. * @returns true if everything that can be done was applied
  150747. */
  150748. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150749. }
  150750. /**
  150751. * Defines an optimization used to turn lens flares off
  150752. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150753. */
  150754. export class LensFlaresOptimization extends SceneOptimization {
  150755. /**
  150756. * Gets a string describing the action executed by the current optimization
  150757. * @return description string
  150758. */
  150759. getDescription(): string;
  150760. /**
  150761. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150762. * @param scene defines the current scene where to apply this optimization
  150763. * @param optimizer defines the current optimizer
  150764. * @returns true if everything that can be done was applied
  150765. */
  150766. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150767. }
  150768. /**
  150769. * Defines an optimization based on user defined callback.
  150770. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150771. */
  150772. export class CustomOptimization extends SceneOptimization {
  150773. /**
  150774. * Callback called to apply the custom optimization.
  150775. */
  150776. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  150777. /**
  150778. * Callback called to get custom description
  150779. */
  150780. onGetDescription: () => string;
  150781. /**
  150782. * Gets a string describing the action executed by the current optimization
  150783. * @returns description string
  150784. */
  150785. getDescription(): string;
  150786. /**
  150787. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150788. * @param scene defines the current scene where to apply this optimization
  150789. * @param optimizer defines the current optimizer
  150790. * @returns true if everything that can be done was applied
  150791. */
  150792. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150793. }
  150794. /**
  150795. * Defines an optimization used to turn particles off
  150796. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150797. */
  150798. export class ParticlesOptimization extends SceneOptimization {
  150799. /**
  150800. * Gets a string describing the action executed by the current optimization
  150801. * @return description string
  150802. */
  150803. getDescription(): string;
  150804. /**
  150805. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150806. * @param scene defines the current scene where to apply this optimization
  150807. * @param optimizer defines the current optimizer
  150808. * @returns true if everything that can be done was applied
  150809. */
  150810. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150811. }
  150812. /**
  150813. * Defines an optimization used to turn render targets off
  150814. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150815. */
  150816. export class RenderTargetsOptimization extends SceneOptimization {
  150817. /**
  150818. * Gets a string describing the action executed by the current optimization
  150819. * @return description string
  150820. */
  150821. getDescription(): string;
  150822. /**
  150823. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150824. * @param scene defines the current scene where to apply this optimization
  150825. * @param optimizer defines the current optimizer
  150826. * @returns true if everything that can be done was applied
  150827. */
  150828. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150829. }
  150830. /**
  150831. * Defines an optimization used to merge meshes with compatible materials
  150832. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150833. */
  150834. export class MergeMeshesOptimization extends SceneOptimization {
  150835. private static _UpdateSelectionTree;
  150836. /**
  150837. * Gets or sets a boolean which defines if optimization octree has to be updated
  150838. */
  150839. static get UpdateSelectionTree(): boolean;
  150840. /**
  150841. * Gets or sets a boolean which defines if optimization octree has to be updated
  150842. */
  150843. static set UpdateSelectionTree(value: boolean);
  150844. /**
  150845. * Gets a string describing the action executed by the current optimization
  150846. * @return description string
  150847. */
  150848. getDescription(): string;
  150849. private _canBeMerged;
  150850. /**
  150851. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150852. * @param scene defines the current scene where to apply this optimization
  150853. * @param optimizer defines the current optimizer
  150854. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  150855. * @returns true if everything that can be done was applied
  150856. */
  150857. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  150858. }
  150859. /**
  150860. * Defines a list of options used by SceneOptimizer
  150861. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150862. */
  150863. export class SceneOptimizerOptions {
  150864. /**
  150865. * Defines the target frame rate to reach (60 by default)
  150866. */
  150867. targetFrameRate: number;
  150868. /**
  150869. * Defines the interval between two checkes (2000ms by default)
  150870. */
  150871. trackerDuration: number;
  150872. /**
  150873. * Gets the list of optimizations to apply
  150874. */
  150875. optimizations: SceneOptimization[];
  150876. /**
  150877. * Creates a new list of options used by SceneOptimizer
  150878. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  150879. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  150880. */
  150881. constructor(
  150882. /**
  150883. * Defines the target frame rate to reach (60 by default)
  150884. */
  150885. targetFrameRate?: number,
  150886. /**
  150887. * Defines the interval between two checkes (2000ms by default)
  150888. */
  150889. trackerDuration?: number);
  150890. /**
  150891. * Add a new optimization
  150892. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  150893. * @returns the current SceneOptimizerOptions
  150894. */
  150895. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  150896. /**
  150897. * Add a new custom optimization
  150898. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  150899. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  150900. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150901. * @returns the current SceneOptimizerOptions
  150902. */
  150903. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  150904. /**
  150905. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  150906. * @param targetFrameRate defines the target frame rate (60 by default)
  150907. * @returns a SceneOptimizerOptions object
  150908. */
  150909. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150910. /**
  150911. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  150912. * @param targetFrameRate defines the target frame rate (60 by default)
  150913. * @returns a SceneOptimizerOptions object
  150914. */
  150915. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150916. /**
  150917. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  150918. * @param targetFrameRate defines the target frame rate (60 by default)
  150919. * @returns a SceneOptimizerOptions object
  150920. */
  150921. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150922. }
  150923. /**
  150924. * Class used to run optimizations in order to reach a target frame rate
  150925. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150926. */
  150927. export class SceneOptimizer implements IDisposable {
  150928. private _isRunning;
  150929. private _options;
  150930. private _scene;
  150931. private _currentPriorityLevel;
  150932. private _targetFrameRate;
  150933. private _trackerDuration;
  150934. private _currentFrameRate;
  150935. private _sceneDisposeObserver;
  150936. private _improvementMode;
  150937. /**
  150938. * Defines an observable called when the optimizer reaches the target frame rate
  150939. */
  150940. onSuccessObservable: Observable<SceneOptimizer>;
  150941. /**
  150942. * Defines an observable called when the optimizer enables an optimization
  150943. */
  150944. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  150945. /**
  150946. * Defines an observable called when the optimizer is not able to reach the target frame rate
  150947. */
  150948. onFailureObservable: Observable<SceneOptimizer>;
  150949. /**
  150950. * Gets a boolean indicating if the optimizer is in improvement mode
  150951. */
  150952. get isInImprovementMode(): boolean;
  150953. /**
  150954. * Gets the current priority level (0 at start)
  150955. */
  150956. get currentPriorityLevel(): number;
  150957. /**
  150958. * Gets the current frame rate checked by the SceneOptimizer
  150959. */
  150960. get currentFrameRate(): number;
  150961. /**
  150962. * Gets or sets the current target frame rate (60 by default)
  150963. */
  150964. get targetFrameRate(): number;
  150965. /**
  150966. * Gets or sets the current target frame rate (60 by default)
  150967. */
  150968. set targetFrameRate(value: number);
  150969. /**
  150970. * Gets or sets the current interval between two checks (every 2000ms by default)
  150971. */
  150972. get trackerDuration(): number;
  150973. /**
  150974. * Gets or sets the current interval between two checks (every 2000ms by default)
  150975. */
  150976. set trackerDuration(value: number);
  150977. /**
  150978. * Gets the list of active optimizations
  150979. */
  150980. get optimizations(): SceneOptimization[];
  150981. /**
  150982. * Creates a new SceneOptimizer
  150983. * @param scene defines the scene to work on
  150984. * @param options defines the options to use with the SceneOptimizer
  150985. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  150986. * @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)
  150987. */
  150988. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  150989. /**
  150990. * Stops the current optimizer
  150991. */
  150992. stop(): void;
  150993. /**
  150994. * Reset the optimizer to initial step (current priority level = 0)
  150995. */
  150996. reset(): void;
  150997. /**
  150998. * Start the optimizer. By default it will try to reach a specific framerate
  150999. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  151000. */
  151001. start(): void;
  151002. private _checkCurrentState;
  151003. /**
  151004. * Release all resources
  151005. */
  151006. dispose(): void;
  151007. /**
  151008. * Helper function to create a SceneOptimizer with one single line of code
  151009. * @param scene defines the scene to work on
  151010. * @param options defines the options to use with the SceneOptimizer
  151011. * @param onSuccess defines a callback to call on success
  151012. * @param onFailure defines a callback to call on failure
  151013. * @returns the new SceneOptimizer object
  151014. */
  151015. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  151016. }
  151017. }
  151018. declare module BABYLON {
  151019. /**
  151020. * Class used to serialize a scene into a string
  151021. */
  151022. export class SceneSerializer {
  151023. /**
  151024. * Clear cache used by a previous serialization
  151025. */
  151026. static ClearCache(): void;
  151027. /**
  151028. * Serialize a scene into a JSON compatible object
  151029. * @param scene defines the scene to serialize
  151030. * @returns a JSON compatible object
  151031. */
  151032. static Serialize(scene: Scene): any;
  151033. /**
  151034. * Serialize a mesh into a JSON compatible object
  151035. * @param toSerialize defines the mesh to serialize
  151036. * @param withParents defines if parents must be serialized as well
  151037. * @param withChildren defines if children must be serialized as well
  151038. * @returns a JSON compatible object
  151039. */
  151040. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  151041. }
  151042. }
  151043. declare module BABYLON {
  151044. /**
  151045. * Class used to host texture specific utilities
  151046. */
  151047. export class TextureTools {
  151048. /**
  151049. * Uses the GPU to create a copy texture rescaled at a given size
  151050. * @param texture Texture to copy from
  151051. * @param width defines the desired width
  151052. * @param height defines the desired height
  151053. * @param useBilinearMode defines if bilinear mode has to be used
  151054. * @return the generated texture
  151055. */
  151056. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  151057. }
  151058. }
  151059. declare module BABYLON {
  151060. /**
  151061. * This represents the different options available for the video capture.
  151062. */
  151063. export interface VideoRecorderOptions {
  151064. /** Defines the mime type of the video. */
  151065. mimeType: string;
  151066. /** Defines the FPS the video should be recorded at. */
  151067. fps: number;
  151068. /** Defines the chunk size for the recording data. */
  151069. recordChunckSize: number;
  151070. /** The audio tracks to attach to the recording. */
  151071. audioTracks?: MediaStreamTrack[];
  151072. }
  151073. /**
  151074. * This can help with recording videos from BabylonJS.
  151075. * This is based on the available WebRTC functionalities of the browser.
  151076. *
  151077. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  151078. */
  151079. export class VideoRecorder {
  151080. private static readonly _defaultOptions;
  151081. /**
  151082. * Returns whether or not the VideoRecorder is available in your browser.
  151083. * @param engine Defines the Babylon Engine.
  151084. * @returns true if supported otherwise false.
  151085. */
  151086. static IsSupported(engine: Engine): boolean;
  151087. private readonly _options;
  151088. private _canvas;
  151089. private _mediaRecorder;
  151090. private _recordedChunks;
  151091. private _fileName;
  151092. private _resolve;
  151093. private _reject;
  151094. /**
  151095. * True when a recording is already in progress.
  151096. */
  151097. get isRecording(): boolean;
  151098. /**
  151099. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  151100. * @param engine Defines the BabylonJS Engine you wish to record.
  151101. * @param options Defines options that can be used to customize the capture.
  151102. */
  151103. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  151104. /**
  151105. * Stops the current recording before the default capture timeout passed in the startRecording function.
  151106. */
  151107. stopRecording(): void;
  151108. /**
  151109. * Starts recording the canvas for a max duration specified in parameters.
  151110. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  151111. * If null no automatic download will start and you can rely on the promise to get the data back.
  151112. * @param maxDuration Defines the maximum recording time in seconds.
  151113. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  151114. * @return A promise callback at the end of the recording with the video data in Blob.
  151115. */
  151116. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  151117. /**
  151118. * Releases internal resources used during the recording.
  151119. */
  151120. dispose(): void;
  151121. private _handleDataAvailable;
  151122. private _handleError;
  151123. private _handleStop;
  151124. }
  151125. }
  151126. declare module BABYLON {
  151127. /**
  151128. * Class containing a set of static utilities functions for screenshots
  151129. */
  151130. export class ScreenshotTools {
  151131. /**
  151132. * Captures a screenshot of the current rendering
  151133. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151134. * @param engine defines the rendering engine
  151135. * @param camera defines the source camera
  151136. * @param size This parameter can be set to a single number or to an object with the
  151137. * following (optional) properties: precision, width, height. If a single number is passed,
  151138. * it will be used for both width and height. If an object is passed, the screenshot size
  151139. * will be derived from the parameters. The precision property is a multiplier allowing
  151140. * rendering at a higher or lower resolution
  151141. * @param successCallback defines the callback receives a single parameter which contains the
  151142. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151143. * src parameter of an <img> to display it
  151144. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151145. * Check your browser for supported MIME types
  151146. */
  151147. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  151148. /**
  151149. * Captures a screenshot of the current rendering
  151150. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151151. * @param engine defines the rendering engine
  151152. * @param camera defines the source camera
  151153. * @param size This parameter can be set to a single number or to an object with the
  151154. * following (optional) properties: precision, width, height. If a single number is passed,
  151155. * it will be used for both width and height. If an object is passed, the screenshot size
  151156. * will be derived from the parameters. The precision property is a multiplier allowing
  151157. * rendering at a higher or lower resolution
  151158. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151159. * Check your browser for supported MIME types
  151160. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151161. * to the src parameter of an <img> to display it
  151162. */
  151163. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  151164. /**
  151165. * Generates an image screenshot from the specified camera.
  151166. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151167. * @param engine The engine to use for rendering
  151168. * @param camera The camera to use for rendering
  151169. * @param size This parameter can be set to a single number or to an object with the
  151170. * following (optional) properties: precision, width, height. If a single number is passed,
  151171. * it will be used for both width and height. If an object is passed, the screenshot size
  151172. * will be derived from the parameters. The precision property is a multiplier allowing
  151173. * rendering at a higher or lower resolution
  151174. * @param successCallback The callback receives a single parameter which contains the
  151175. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151176. * src parameter of an <img> to display it
  151177. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151178. * Check your browser for supported MIME types
  151179. * @param samples Texture samples (default: 1)
  151180. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151181. * @param fileName A name for for the downloaded file.
  151182. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151183. */
  151184. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  151185. /**
  151186. * Generates an image screenshot from the specified camera.
  151187. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151188. * @param engine The engine to use for rendering
  151189. * @param camera The camera to use for rendering
  151190. * @param size This parameter can be set to a single number or to an object with the
  151191. * following (optional) properties: precision, width, height. If a single number is passed,
  151192. * it will be used for both width and height. If an object is passed, the screenshot size
  151193. * will be derived from the parameters. The precision property is a multiplier allowing
  151194. * rendering at a higher or lower resolution
  151195. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151196. * Check your browser for supported MIME types
  151197. * @param samples Texture samples (default: 1)
  151198. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151199. * @param fileName A name for for the downloaded file.
  151200. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151201. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151202. * to the src parameter of an <img> to display it
  151203. */
  151204. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  151205. /**
  151206. * Gets height and width for screenshot size
  151207. * @private
  151208. */
  151209. private static _getScreenshotSize;
  151210. }
  151211. }
  151212. declare module BABYLON {
  151213. /**
  151214. * Interface for a data buffer
  151215. */
  151216. export interface IDataBuffer {
  151217. /**
  151218. * Reads bytes from the data buffer.
  151219. * @param byteOffset The byte offset to read
  151220. * @param byteLength The byte length to read
  151221. * @returns A promise that resolves when the bytes are read
  151222. */
  151223. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  151224. /**
  151225. * The byte length of the buffer.
  151226. */
  151227. readonly byteLength: number;
  151228. }
  151229. /**
  151230. * Utility class for reading from a data buffer
  151231. */
  151232. export class DataReader {
  151233. /**
  151234. * The data buffer associated with this data reader.
  151235. */
  151236. readonly buffer: IDataBuffer;
  151237. /**
  151238. * The current byte offset from the beginning of the data buffer.
  151239. */
  151240. byteOffset: number;
  151241. private _dataView;
  151242. private _dataByteOffset;
  151243. /**
  151244. * Constructor
  151245. * @param buffer The buffer to read
  151246. */
  151247. constructor(buffer: IDataBuffer);
  151248. /**
  151249. * Loads the given byte length.
  151250. * @param byteLength The byte length to load
  151251. * @returns A promise that resolves when the load is complete
  151252. */
  151253. loadAsync(byteLength: number): Promise<void>;
  151254. /**
  151255. * Read a unsigned 32-bit integer from the currently loaded data range.
  151256. * @returns The 32-bit integer read
  151257. */
  151258. readUint32(): number;
  151259. /**
  151260. * Read a byte array from the currently loaded data range.
  151261. * @param byteLength The byte length to read
  151262. * @returns The byte array read
  151263. */
  151264. readUint8Array(byteLength: number): Uint8Array;
  151265. /**
  151266. * Read a string from the currently loaded data range.
  151267. * @param byteLength The byte length to read
  151268. * @returns The string read
  151269. */
  151270. readString(byteLength: number): string;
  151271. /**
  151272. * Skips the given byte length the currently loaded data range.
  151273. * @param byteLength The byte length to skip
  151274. */
  151275. skipBytes(byteLength: number): void;
  151276. }
  151277. }
  151278. declare module BABYLON {
  151279. /**
  151280. * Class for storing data to local storage if available or in-memory storage otherwise
  151281. */
  151282. export class DataStorage {
  151283. private static _Storage;
  151284. private static _GetStorage;
  151285. /**
  151286. * Reads a string from the data storage
  151287. * @param key The key to read
  151288. * @param defaultValue The value if the key doesn't exist
  151289. * @returns The string value
  151290. */
  151291. static ReadString(key: string, defaultValue: string): string;
  151292. /**
  151293. * Writes a string to the data storage
  151294. * @param key The key to write
  151295. * @param value The value to write
  151296. */
  151297. static WriteString(key: string, value: string): void;
  151298. /**
  151299. * Reads a boolean from the data storage
  151300. * @param key The key to read
  151301. * @param defaultValue The value if the key doesn't exist
  151302. * @returns The boolean value
  151303. */
  151304. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  151305. /**
  151306. * Writes a boolean to the data storage
  151307. * @param key The key to write
  151308. * @param value The value to write
  151309. */
  151310. static WriteBoolean(key: string, value: boolean): void;
  151311. /**
  151312. * Reads a number from the data storage
  151313. * @param key The key to read
  151314. * @param defaultValue The value if the key doesn't exist
  151315. * @returns The number value
  151316. */
  151317. static ReadNumber(key: string, defaultValue: number): number;
  151318. /**
  151319. * Writes a number to the data storage
  151320. * @param key The key to write
  151321. * @param value The value to write
  151322. */
  151323. static WriteNumber(key: string, value: number): void;
  151324. }
  151325. }
  151326. declare module BABYLON {
  151327. /**
  151328. * An interface for all Hit test features
  151329. */
  151330. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  151331. /**
  151332. * Triggered when new babylon (transformed) hit test results are available
  151333. */
  151334. onHitTestResultObservable: Observable<T[]>;
  151335. }
  151336. /**
  151337. * Options used for hit testing
  151338. */
  151339. export interface IWebXRLegacyHitTestOptions {
  151340. /**
  151341. * Only test when user interacted with the scene. Default - hit test every frame
  151342. */
  151343. testOnPointerDownOnly?: boolean;
  151344. /**
  151345. * The node to use to transform the local results to world coordinates
  151346. */
  151347. worldParentNode?: TransformNode;
  151348. }
  151349. /**
  151350. * Interface defining the babylon result of raycasting/hit-test
  151351. */
  151352. export interface IWebXRLegacyHitResult {
  151353. /**
  151354. * Transformation matrix that can be applied to a node that will put it in the hit point location
  151355. */
  151356. transformationMatrix: Matrix;
  151357. /**
  151358. * The native hit test result
  151359. */
  151360. xrHitResult: XRHitResult | XRHitTestResult;
  151361. }
  151362. /**
  151363. * The currently-working hit-test module.
  151364. * Hit test (or Ray-casting) is used to interact with the real world.
  151365. * For further information read here - https://github.com/immersive-web/hit-test
  151366. */
  151367. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  151368. /**
  151369. * options to use when constructing this feature
  151370. */
  151371. readonly options: IWebXRLegacyHitTestOptions;
  151372. private _direction;
  151373. private _mat;
  151374. private _onSelectEnabled;
  151375. private _origin;
  151376. /**
  151377. * The module's name
  151378. */
  151379. static readonly Name: string;
  151380. /**
  151381. * The (Babylon) version of this module.
  151382. * This is an integer representing the implementation version.
  151383. * This number does not correspond to the WebXR specs version
  151384. */
  151385. static readonly Version: number;
  151386. /**
  151387. * Populated with the last native XR Hit Results
  151388. */
  151389. lastNativeXRHitResults: XRHitResult[];
  151390. /**
  151391. * Triggered when new babylon (transformed) hit test results are available
  151392. */
  151393. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  151394. /**
  151395. * Creates a new instance of the (legacy version) hit test feature
  151396. * @param _xrSessionManager an instance of WebXRSessionManager
  151397. * @param options options to use when constructing this feature
  151398. */
  151399. constructor(_xrSessionManager: WebXRSessionManager,
  151400. /**
  151401. * options to use when constructing this feature
  151402. */
  151403. options?: IWebXRLegacyHitTestOptions);
  151404. /**
  151405. * execute a hit test with an XR Ray
  151406. *
  151407. * @param xrSession a native xrSession that will execute this hit test
  151408. * @param xrRay the ray (position and direction) to use for ray-casting
  151409. * @param referenceSpace native XR reference space to use for the hit-test
  151410. * @param filter filter function that will filter the results
  151411. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  151412. */
  151413. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  151414. /**
  151415. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  151416. * @param event the (select) event to use to select with
  151417. * @param referenceSpace the reference space to use for this hit test
  151418. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  151419. */
  151420. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  151421. /**
  151422. * attach this feature
  151423. * Will usually be called by the features manager
  151424. *
  151425. * @returns true if successful.
  151426. */
  151427. attach(): boolean;
  151428. /**
  151429. * detach this feature.
  151430. * Will usually be called by the features manager
  151431. *
  151432. * @returns true if successful.
  151433. */
  151434. detach(): boolean;
  151435. /**
  151436. * Dispose this feature and all of the resources attached
  151437. */
  151438. dispose(): void;
  151439. protected _onXRFrame(frame: XRFrame): void;
  151440. private _onHitTestResults;
  151441. private _onSelect;
  151442. }
  151443. }
  151444. declare module BABYLON {
  151445. /**
  151446. * Options used for hit testing (version 2)
  151447. */
  151448. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  151449. /**
  151450. * Do not create a permanent hit test. Will usually be used when only
  151451. * transient inputs are needed.
  151452. */
  151453. disablePermanentHitTest?: boolean;
  151454. /**
  151455. * Enable transient (for example touch-based) hit test inspections
  151456. */
  151457. enableTransientHitTest?: boolean;
  151458. /**
  151459. * Offset ray for the permanent hit test
  151460. */
  151461. offsetRay?: Vector3;
  151462. /**
  151463. * Offset ray for the transient hit test
  151464. */
  151465. transientOffsetRay?: Vector3;
  151466. /**
  151467. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  151468. */
  151469. useReferenceSpace?: boolean;
  151470. }
  151471. /**
  151472. * Interface defining the babylon result of hit-test
  151473. */
  151474. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  151475. /**
  151476. * The input source that generated this hit test (if transient)
  151477. */
  151478. inputSource?: XRInputSource;
  151479. /**
  151480. * Is this a transient hit test
  151481. */
  151482. isTransient?: boolean;
  151483. /**
  151484. * Position of the hit test result
  151485. */
  151486. position: Vector3;
  151487. /**
  151488. * Rotation of the hit test result
  151489. */
  151490. rotationQuaternion: Quaternion;
  151491. /**
  151492. * The native hit test result
  151493. */
  151494. xrHitResult: XRHitTestResult;
  151495. }
  151496. /**
  151497. * The currently-working hit-test module.
  151498. * Hit test (or Ray-casting) is used to interact with the real world.
  151499. * For further information read here - https://github.com/immersive-web/hit-test
  151500. *
  151501. * Tested on chrome (mobile) 80.
  151502. */
  151503. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  151504. /**
  151505. * options to use when constructing this feature
  151506. */
  151507. readonly options: IWebXRHitTestOptions;
  151508. private _tmpMat;
  151509. private _tmpPos;
  151510. private _tmpQuat;
  151511. private _transientXrHitTestSource;
  151512. private _xrHitTestSource;
  151513. private initHitTestSource;
  151514. /**
  151515. * The module's name
  151516. */
  151517. static readonly Name: string;
  151518. /**
  151519. * The (Babylon) version of this module.
  151520. * This is an integer representing the implementation version.
  151521. * This number does not correspond to the WebXR specs version
  151522. */
  151523. static readonly Version: number;
  151524. /**
  151525. * When set to true, each hit test will have its own position/rotation objects
  151526. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  151527. * the developers will clone them or copy them as they see fit.
  151528. */
  151529. autoCloneTransformation: boolean;
  151530. /**
  151531. * Triggered when new babylon (transformed) hit test results are available
  151532. */
  151533. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  151534. /**
  151535. * Use this to temporarily pause hit test checks.
  151536. */
  151537. paused: boolean;
  151538. /**
  151539. * Creates a new instance of the hit test feature
  151540. * @param _xrSessionManager an instance of WebXRSessionManager
  151541. * @param options options to use when constructing this feature
  151542. */
  151543. constructor(_xrSessionManager: WebXRSessionManager,
  151544. /**
  151545. * options to use when constructing this feature
  151546. */
  151547. options?: IWebXRHitTestOptions);
  151548. /**
  151549. * attach this feature
  151550. * Will usually be called by the features manager
  151551. *
  151552. * @returns true if successful.
  151553. */
  151554. attach(): boolean;
  151555. /**
  151556. * detach this feature.
  151557. * Will usually be called by the features manager
  151558. *
  151559. * @returns true if successful.
  151560. */
  151561. detach(): boolean;
  151562. /**
  151563. * Dispose this feature and all of the resources attached
  151564. */
  151565. dispose(): void;
  151566. protected _onXRFrame(frame: XRFrame): void;
  151567. private _processWebXRHitTestResult;
  151568. }
  151569. }
  151570. declare module BABYLON {
  151571. /**
  151572. * Configuration options of the anchor system
  151573. */
  151574. export interface IWebXRAnchorSystemOptions {
  151575. /**
  151576. * a node that will be used to convert local to world coordinates
  151577. */
  151578. worldParentNode?: TransformNode;
  151579. /**
  151580. * If set to true a reference of the created anchors will be kept until the next session starts
  151581. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  151582. */
  151583. doNotRemoveAnchorsOnSessionEnded?: boolean;
  151584. }
  151585. /**
  151586. * A babylon container for an XR Anchor
  151587. */
  151588. export interface IWebXRAnchor {
  151589. /**
  151590. * A babylon-assigned ID for this anchor
  151591. */
  151592. id: number;
  151593. /**
  151594. * Transformation matrix to apply to an object attached to this anchor
  151595. */
  151596. transformationMatrix: Matrix;
  151597. /**
  151598. * The native anchor object
  151599. */
  151600. xrAnchor: XRAnchor;
  151601. /**
  151602. * if defined, this object will be constantly updated by the anchor's position and rotation
  151603. */
  151604. attachedNode?: TransformNode;
  151605. }
  151606. /**
  151607. * An implementation of the anchor system for WebXR.
  151608. * For further information see https://github.com/immersive-web/anchors/
  151609. */
  151610. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  151611. private _options;
  151612. private _lastFrameDetected;
  151613. private _trackedAnchors;
  151614. private _referenceSpaceForFrameAnchors;
  151615. private _futureAnchors;
  151616. /**
  151617. * The module's name
  151618. */
  151619. static readonly Name: string;
  151620. /**
  151621. * The (Babylon) version of this module.
  151622. * This is an integer representing the implementation version.
  151623. * This number does not correspond to the WebXR specs version
  151624. */
  151625. static readonly Version: number;
  151626. /**
  151627. * Observers registered here will be executed when a new anchor was added to the session
  151628. */
  151629. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  151630. /**
  151631. * Observers registered here will be executed when an anchor was removed from the session
  151632. */
  151633. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  151634. /**
  151635. * Observers registered here will be executed when an existing anchor updates
  151636. * This can execute N times every frame
  151637. */
  151638. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  151639. /**
  151640. * Set the reference space to use for anchor creation, when not using a hit test.
  151641. * Will default to the session's reference space if not defined
  151642. */
  151643. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  151644. /**
  151645. * constructs a new anchor system
  151646. * @param _xrSessionManager an instance of WebXRSessionManager
  151647. * @param _options configuration object for this feature
  151648. */
  151649. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  151650. private _tmpVector;
  151651. private _tmpQuaternion;
  151652. private _populateTmpTransformation;
  151653. /**
  151654. * Create a new anchor point using a hit test result at a specific point in the scene
  151655. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  151656. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  151657. *
  151658. * @param hitTestResult The hit test result to use for this anchor creation
  151659. * @param position an optional position offset for this anchor
  151660. * @param rotationQuaternion an optional rotation offset for this anchor
  151661. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  151662. */
  151663. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  151664. /**
  151665. * Add a new anchor at a specific position and rotation
  151666. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  151667. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  151668. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  151669. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  151670. *
  151671. * @param position the position in which to add an anchor
  151672. * @param rotationQuaternion an optional rotation for the anchor transformation
  151673. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  151674. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  151675. */
  151676. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  151677. /**
  151678. * detach this feature.
  151679. * Will usually be called by the features manager
  151680. *
  151681. * @returns true if successful.
  151682. */
  151683. detach(): boolean;
  151684. /**
  151685. * Dispose this feature and all of the resources attached
  151686. */
  151687. dispose(): void;
  151688. protected _onXRFrame(frame: XRFrame): void;
  151689. /**
  151690. * avoiding using Array.find for global support.
  151691. * @param xrAnchor the plane to find in the array
  151692. */
  151693. private _findIndexInAnchorArray;
  151694. private _updateAnchorWithXRFrame;
  151695. private _createAnchorAtTransformation;
  151696. }
  151697. }
  151698. declare module BABYLON {
  151699. /**
  151700. * Options used in the plane detector module
  151701. */
  151702. export interface IWebXRPlaneDetectorOptions {
  151703. /**
  151704. * The node to use to transform the local results to world coordinates
  151705. */
  151706. worldParentNode?: TransformNode;
  151707. /**
  151708. * If set to true a reference of the created planes will be kept until the next session starts
  151709. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  151710. */
  151711. doNotRemovePlanesOnSessionEnded?: boolean;
  151712. }
  151713. /**
  151714. * A babylon interface for a WebXR plane.
  151715. * A Plane is actually a polygon, built from N points in space
  151716. *
  151717. * Supported in chrome 79, not supported in canary 81 ATM
  151718. */
  151719. export interface IWebXRPlane {
  151720. /**
  151721. * a babylon-assigned ID for this polygon
  151722. */
  151723. id: number;
  151724. /**
  151725. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  151726. */
  151727. polygonDefinition: Array<Vector3>;
  151728. /**
  151729. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  151730. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  151731. */
  151732. transformationMatrix: Matrix;
  151733. /**
  151734. * the native xr-plane object
  151735. */
  151736. xrPlane: XRPlane;
  151737. }
  151738. /**
  151739. * The plane detector is used to detect planes in the real world when in AR
  151740. * For more information see https://github.com/immersive-web/real-world-geometry/
  151741. */
  151742. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  151743. private _options;
  151744. private _detectedPlanes;
  151745. private _enabled;
  151746. private _lastFrameDetected;
  151747. /**
  151748. * The module's name
  151749. */
  151750. static readonly Name: string;
  151751. /**
  151752. * The (Babylon) version of this module.
  151753. * This is an integer representing the implementation version.
  151754. * This number does not correspond to the WebXR specs version
  151755. */
  151756. static readonly Version: number;
  151757. /**
  151758. * Observers registered here will be executed when a new plane was added to the session
  151759. */
  151760. onPlaneAddedObservable: Observable<IWebXRPlane>;
  151761. /**
  151762. * Observers registered here will be executed when a plane is no longer detected in the session
  151763. */
  151764. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  151765. /**
  151766. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  151767. * This can execute N times every frame
  151768. */
  151769. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  151770. /**
  151771. * construct a new Plane Detector
  151772. * @param _xrSessionManager an instance of xr Session manager
  151773. * @param _options configuration to use when constructing this feature
  151774. */
  151775. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  151776. /**
  151777. * detach this feature.
  151778. * Will usually be called by the features manager
  151779. *
  151780. * @returns true if successful.
  151781. */
  151782. detach(): boolean;
  151783. /**
  151784. * Dispose this feature and all of the resources attached
  151785. */
  151786. dispose(): void;
  151787. protected _onXRFrame(frame: XRFrame): void;
  151788. private _init;
  151789. private _updatePlaneWithXRPlane;
  151790. /**
  151791. * avoiding using Array.find for global support.
  151792. * @param xrPlane the plane to find in the array
  151793. */
  151794. private findIndexInPlaneArray;
  151795. }
  151796. }
  151797. declare module BABYLON {
  151798. /**
  151799. * Options interface for the background remover plugin
  151800. */
  151801. export interface IWebXRBackgroundRemoverOptions {
  151802. /**
  151803. * Further background meshes to disable when entering AR
  151804. */
  151805. backgroundMeshes?: AbstractMesh[];
  151806. /**
  151807. * flags to configure the removal of the environment helper.
  151808. * If not set, the entire background will be removed. If set, flags should be set as well.
  151809. */
  151810. environmentHelperRemovalFlags?: {
  151811. /**
  151812. * Should the skybox be removed (default false)
  151813. */
  151814. skyBox?: boolean;
  151815. /**
  151816. * Should the ground be removed (default false)
  151817. */
  151818. ground?: boolean;
  151819. };
  151820. /**
  151821. * don't disable the environment helper
  151822. */
  151823. ignoreEnvironmentHelper?: boolean;
  151824. }
  151825. /**
  151826. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  151827. */
  151828. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  151829. /**
  151830. * read-only options to be used in this module
  151831. */
  151832. readonly options: IWebXRBackgroundRemoverOptions;
  151833. /**
  151834. * The module's name
  151835. */
  151836. static readonly Name: string;
  151837. /**
  151838. * The (Babylon) version of this module.
  151839. * This is an integer representing the implementation version.
  151840. * This number does not correspond to the WebXR specs version
  151841. */
  151842. static readonly Version: number;
  151843. /**
  151844. * registered observers will be triggered when the background state changes
  151845. */
  151846. onBackgroundStateChangedObservable: Observable<boolean>;
  151847. /**
  151848. * constructs a new background remover module
  151849. * @param _xrSessionManager the session manager for this module
  151850. * @param options read-only options to be used in this module
  151851. */
  151852. constructor(_xrSessionManager: WebXRSessionManager,
  151853. /**
  151854. * read-only options to be used in this module
  151855. */
  151856. options?: IWebXRBackgroundRemoverOptions);
  151857. /**
  151858. * attach this feature
  151859. * Will usually be called by the features manager
  151860. *
  151861. * @returns true if successful.
  151862. */
  151863. attach(): boolean;
  151864. /**
  151865. * detach this feature.
  151866. * Will usually be called by the features manager
  151867. *
  151868. * @returns true if successful.
  151869. */
  151870. detach(): boolean;
  151871. /**
  151872. * Dispose this feature and all of the resources attached
  151873. */
  151874. dispose(): void;
  151875. protected _onXRFrame(_xrFrame: XRFrame): void;
  151876. private _setBackgroundState;
  151877. }
  151878. }
  151879. declare module BABYLON {
  151880. /**
  151881. * Options for the controller physics feature
  151882. */
  151883. export class IWebXRControllerPhysicsOptions {
  151884. /**
  151885. * Should the headset get its own impostor
  151886. */
  151887. enableHeadsetImpostor?: boolean;
  151888. /**
  151889. * Optional parameters for the headset impostor
  151890. */
  151891. headsetImpostorParams?: {
  151892. /**
  151893. * The type of impostor to create. Default is sphere
  151894. */
  151895. impostorType: number;
  151896. /**
  151897. * the size of the impostor. Defaults to 10cm
  151898. */
  151899. impostorSize?: number | {
  151900. width: number;
  151901. height: number;
  151902. depth: number;
  151903. };
  151904. /**
  151905. * Friction definitions
  151906. */
  151907. friction?: number;
  151908. /**
  151909. * Restitution
  151910. */
  151911. restitution?: number;
  151912. };
  151913. /**
  151914. * The physics properties of the future impostors
  151915. */
  151916. physicsProperties?: {
  151917. /**
  151918. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  151919. * Note that this requires a physics engine that supports mesh impostors!
  151920. */
  151921. useControllerMesh?: boolean;
  151922. /**
  151923. * The type of impostor to create. Default is sphere
  151924. */
  151925. impostorType?: number;
  151926. /**
  151927. * the size of the impostor. Defaults to 10cm
  151928. */
  151929. impostorSize?: number | {
  151930. width: number;
  151931. height: number;
  151932. depth: number;
  151933. };
  151934. /**
  151935. * Friction definitions
  151936. */
  151937. friction?: number;
  151938. /**
  151939. * Restitution
  151940. */
  151941. restitution?: number;
  151942. };
  151943. /**
  151944. * the xr input to use with this pointer selection
  151945. */
  151946. xrInput: WebXRInput;
  151947. }
  151948. /**
  151949. * Add physics impostor to your webxr controllers,
  151950. * including naive calculation of their linear and angular velocity
  151951. */
  151952. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  151953. private readonly _options;
  151954. private _attachController;
  151955. private _controllers;
  151956. private _debugMode;
  151957. private _delta;
  151958. private _headsetImpostor?;
  151959. private _headsetMesh?;
  151960. private _lastTimestamp;
  151961. private _tmpQuaternion;
  151962. private _tmpVector;
  151963. /**
  151964. * The module's name
  151965. */
  151966. static readonly Name: string;
  151967. /**
  151968. * The (Babylon) version of this module.
  151969. * This is an integer representing the implementation version.
  151970. * This number does not correspond to the webxr specs version
  151971. */
  151972. static readonly Version: number;
  151973. /**
  151974. * Construct a new Controller Physics Feature
  151975. * @param _xrSessionManager the corresponding xr session manager
  151976. * @param _options options to create this feature with
  151977. */
  151978. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  151979. /**
  151980. * @hidden
  151981. * enable debugging - will show console outputs and the impostor mesh
  151982. */
  151983. _enablePhysicsDebug(): void;
  151984. /**
  151985. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  151986. * @param xrController the controller to add
  151987. */
  151988. addController(xrController: WebXRInputSource): void;
  151989. /**
  151990. * attach this feature
  151991. * Will usually be called by the features manager
  151992. *
  151993. * @returns true if successful.
  151994. */
  151995. attach(): boolean;
  151996. /**
  151997. * detach this feature.
  151998. * Will usually be called by the features manager
  151999. *
  152000. * @returns true if successful.
  152001. */
  152002. detach(): boolean;
  152003. /**
  152004. * Get the headset impostor, if enabled
  152005. * @returns the impostor
  152006. */
  152007. getHeadsetImpostor(): PhysicsImpostor | undefined;
  152008. /**
  152009. * Get the physics impostor of a specific controller.
  152010. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  152011. * @param controller the controller or the controller id of which to get the impostor
  152012. * @returns the impostor or null
  152013. */
  152014. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  152015. /**
  152016. * Update the physics properties provided in the constructor
  152017. * @param newProperties the new properties object
  152018. */
  152019. setPhysicsProperties(newProperties: {
  152020. impostorType?: number;
  152021. impostorSize?: number | {
  152022. width: number;
  152023. height: number;
  152024. depth: number;
  152025. };
  152026. friction?: number;
  152027. restitution?: number;
  152028. }): void;
  152029. protected _onXRFrame(_xrFrame: any): void;
  152030. private _detachController;
  152031. }
  152032. }
  152033. declare module BABYLON {
  152034. /**
  152035. * The motion controller class for all microsoft mixed reality controllers
  152036. */
  152037. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  152038. protected readonly _mapping: {
  152039. defaultButton: {
  152040. valueNodeName: string;
  152041. unpressedNodeName: string;
  152042. pressedNodeName: string;
  152043. };
  152044. defaultAxis: {
  152045. valueNodeName: string;
  152046. minNodeName: string;
  152047. maxNodeName: string;
  152048. };
  152049. buttons: {
  152050. "xr-standard-trigger": {
  152051. rootNodeName: string;
  152052. componentProperty: string;
  152053. states: string[];
  152054. };
  152055. "xr-standard-squeeze": {
  152056. rootNodeName: string;
  152057. componentProperty: string;
  152058. states: string[];
  152059. };
  152060. "xr-standard-touchpad": {
  152061. rootNodeName: string;
  152062. labelAnchorNodeName: string;
  152063. touchPointNodeName: string;
  152064. };
  152065. "xr-standard-thumbstick": {
  152066. rootNodeName: string;
  152067. componentProperty: string;
  152068. states: string[];
  152069. };
  152070. };
  152071. axes: {
  152072. "xr-standard-touchpad": {
  152073. "x-axis": {
  152074. rootNodeName: string;
  152075. };
  152076. "y-axis": {
  152077. rootNodeName: string;
  152078. };
  152079. };
  152080. "xr-standard-thumbstick": {
  152081. "x-axis": {
  152082. rootNodeName: string;
  152083. };
  152084. "y-axis": {
  152085. rootNodeName: string;
  152086. };
  152087. };
  152088. };
  152089. };
  152090. /**
  152091. * The base url used to load the left and right controller models
  152092. */
  152093. static MODEL_BASE_URL: string;
  152094. /**
  152095. * The name of the left controller model file
  152096. */
  152097. static MODEL_LEFT_FILENAME: string;
  152098. /**
  152099. * The name of the right controller model file
  152100. */
  152101. static MODEL_RIGHT_FILENAME: string;
  152102. profileId: string;
  152103. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152104. protected _getFilenameAndPath(): {
  152105. filename: string;
  152106. path: string;
  152107. };
  152108. protected _getModelLoadingConstraints(): boolean;
  152109. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152110. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152111. protected _updateModel(): void;
  152112. }
  152113. }
  152114. declare module BABYLON {
  152115. /**
  152116. * The motion controller class for oculus touch (quest, rift).
  152117. * This class supports legacy mapping as well the standard xr mapping
  152118. */
  152119. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  152120. private _forceLegacyControllers;
  152121. private _modelRootNode;
  152122. /**
  152123. * The base url used to load the left and right controller models
  152124. */
  152125. static MODEL_BASE_URL: string;
  152126. /**
  152127. * The name of the left controller model file
  152128. */
  152129. static MODEL_LEFT_FILENAME: string;
  152130. /**
  152131. * The name of the right controller model file
  152132. */
  152133. static MODEL_RIGHT_FILENAME: string;
  152134. /**
  152135. * Base Url for the Quest controller model.
  152136. */
  152137. static QUEST_MODEL_BASE_URL: string;
  152138. profileId: string;
  152139. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  152140. protected _getFilenameAndPath(): {
  152141. filename: string;
  152142. path: string;
  152143. };
  152144. protected _getModelLoadingConstraints(): boolean;
  152145. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152146. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152147. protected _updateModel(): void;
  152148. /**
  152149. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  152150. * between the touch and touch 2.
  152151. */
  152152. private _isQuest;
  152153. }
  152154. }
  152155. declare module BABYLON {
  152156. /**
  152157. * The motion controller class for the standard HTC-Vive controllers
  152158. */
  152159. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  152160. private _modelRootNode;
  152161. /**
  152162. * The base url used to load the left and right controller models
  152163. */
  152164. static MODEL_BASE_URL: string;
  152165. /**
  152166. * File name for the controller model.
  152167. */
  152168. static MODEL_FILENAME: string;
  152169. profileId: string;
  152170. /**
  152171. * Create a new Vive motion controller object
  152172. * @param scene the scene to use to create this controller
  152173. * @param gamepadObject the corresponding gamepad object
  152174. * @param handedness the handedness of the controller
  152175. */
  152176. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152177. protected _getFilenameAndPath(): {
  152178. filename: string;
  152179. path: string;
  152180. };
  152181. protected _getModelLoadingConstraints(): boolean;
  152182. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152183. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152184. protected _updateModel(): void;
  152185. }
  152186. }
  152187. declare module BABYLON {
  152188. /**
  152189. * A cursor which tracks a point on a path
  152190. */
  152191. export class PathCursor {
  152192. private path;
  152193. /**
  152194. * Stores path cursor callbacks for when an onchange event is triggered
  152195. */
  152196. private _onchange;
  152197. /**
  152198. * The value of the path cursor
  152199. */
  152200. value: number;
  152201. /**
  152202. * The animation array of the path cursor
  152203. */
  152204. animations: Animation[];
  152205. /**
  152206. * Initializes the path cursor
  152207. * @param path The path to track
  152208. */
  152209. constructor(path: Path2);
  152210. /**
  152211. * Gets the cursor point on the path
  152212. * @returns A point on the path cursor at the cursor location
  152213. */
  152214. getPoint(): Vector3;
  152215. /**
  152216. * Moves the cursor ahead by the step amount
  152217. * @param step The amount to move the cursor forward
  152218. * @returns This path cursor
  152219. */
  152220. moveAhead(step?: number): PathCursor;
  152221. /**
  152222. * Moves the cursor behind by the step amount
  152223. * @param step The amount to move the cursor back
  152224. * @returns This path cursor
  152225. */
  152226. moveBack(step?: number): PathCursor;
  152227. /**
  152228. * Moves the cursor by the step amount
  152229. * If the step amount is greater than one, an exception is thrown
  152230. * @param step The amount to move the cursor
  152231. * @returns This path cursor
  152232. */
  152233. move(step: number): PathCursor;
  152234. /**
  152235. * Ensures that the value is limited between zero and one
  152236. * @returns This path cursor
  152237. */
  152238. private ensureLimits;
  152239. /**
  152240. * Runs onchange callbacks on change (used by the animation engine)
  152241. * @returns This path cursor
  152242. */
  152243. private raiseOnChange;
  152244. /**
  152245. * Executes a function on change
  152246. * @param f A path cursor onchange callback
  152247. * @returns This path cursor
  152248. */
  152249. onchange(f: (cursor: PathCursor) => void): PathCursor;
  152250. }
  152251. }
  152252. declare module BABYLON {
  152253. /** @hidden */
  152254. export var blurPixelShader: {
  152255. name: string;
  152256. shader: string;
  152257. };
  152258. }
  152259. declare module BABYLON {
  152260. /** @hidden */
  152261. export var pointCloudVertexDeclaration: {
  152262. name: string;
  152263. shader: string;
  152264. };
  152265. }
  152266. // Mixins
  152267. interface Window {
  152268. mozIndexedDB: IDBFactory;
  152269. webkitIndexedDB: IDBFactory;
  152270. msIndexedDB: IDBFactory;
  152271. webkitURL: typeof URL;
  152272. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  152273. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  152274. WebGLRenderingContext: WebGLRenderingContext;
  152275. MSGesture: MSGesture;
  152276. CANNON: any;
  152277. AudioContext: AudioContext;
  152278. webkitAudioContext: AudioContext;
  152279. PointerEvent: any;
  152280. Math: Math;
  152281. Uint8Array: Uint8ArrayConstructor;
  152282. Float32Array: Float32ArrayConstructor;
  152283. mozURL: typeof URL;
  152284. msURL: typeof URL;
  152285. VRFrameData: any; // WebVR, from specs 1.1
  152286. DracoDecoderModule: any;
  152287. setImmediate(handler: (...args: any[]) => void): number;
  152288. }
  152289. interface HTMLCanvasElement {
  152290. requestPointerLock(): void;
  152291. msRequestPointerLock?(): void;
  152292. mozRequestPointerLock?(): void;
  152293. webkitRequestPointerLock?(): void;
  152294. /** Track wether a record is in progress */
  152295. isRecording: boolean;
  152296. /** Capture Stream method defined by some browsers */
  152297. captureStream(fps?: number): MediaStream;
  152298. }
  152299. interface CanvasRenderingContext2D {
  152300. msImageSmoothingEnabled: boolean;
  152301. }
  152302. interface MouseEvent {
  152303. mozMovementX: number;
  152304. mozMovementY: number;
  152305. webkitMovementX: number;
  152306. webkitMovementY: number;
  152307. msMovementX: number;
  152308. msMovementY: number;
  152309. }
  152310. interface Navigator {
  152311. mozGetVRDevices: (any: any) => any;
  152312. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152313. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152314. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152315. webkitGetGamepads(): Gamepad[];
  152316. msGetGamepads(): Gamepad[];
  152317. webkitGamepads(): Gamepad[];
  152318. }
  152319. interface HTMLVideoElement {
  152320. mozSrcObject: any;
  152321. }
  152322. interface Math {
  152323. fround(x: number): number;
  152324. imul(a: number, b: number): number;
  152325. }
  152326. interface WebGLRenderingContext {
  152327. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  152328. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  152329. vertexAttribDivisor(index: number, divisor: number): void;
  152330. createVertexArray(): any;
  152331. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  152332. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  152333. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  152334. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  152335. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  152336. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  152337. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  152338. // Queries
  152339. createQuery(): WebGLQuery;
  152340. deleteQuery(query: WebGLQuery): void;
  152341. beginQuery(target: number, query: WebGLQuery): void;
  152342. endQuery(target: number): void;
  152343. getQueryParameter(query: WebGLQuery, pname: number): any;
  152344. getQuery(target: number, pname: number): any;
  152345. MAX_SAMPLES: number;
  152346. RGBA8: number;
  152347. READ_FRAMEBUFFER: number;
  152348. DRAW_FRAMEBUFFER: number;
  152349. UNIFORM_BUFFER: number;
  152350. HALF_FLOAT_OES: number;
  152351. RGBA16F: number;
  152352. RGBA32F: number;
  152353. R32F: number;
  152354. RG32F: number;
  152355. RGB32F: number;
  152356. R16F: number;
  152357. RG16F: number;
  152358. RGB16F: number;
  152359. RED: number;
  152360. RG: number;
  152361. R8: number;
  152362. RG8: number;
  152363. UNSIGNED_INT_24_8: number;
  152364. DEPTH24_STENCIL8: number;
  152365. MIN: number;
  152366. MAX: number;
  152367. /* Multiple Render Targets */
  152368. drawBuffers(buffers: number[]): void;
  152369. readBuffer(src: number): void;
  152370. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  152371. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  152372. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  152373. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  152374. // Occlusion Query
  152375. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  152376. ANY_SAMPLES_PASSED: number;
  152377. QUERY_RESULT_AVAILABLE: number;
  152378. QUERY_RESULT: number;
  152379. }
  152380. interface WebGLProgram {
  152381. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  152382. }
  152383. interface EXT_disjoint_timer_query {
  152384. QUERY_COUNTER_BITS_EXT: number;
  152385. TIME_ELAPSED_EXT: number;
  152386. TIMESTAMP_EXT: number;
  152387. GPU_DISJOINT_EXT: number;
  152388. QUERY_RESULT_EXT: number;
  152389. QUERY_RESULT_AVAILABLE_EXT: number;
  152390. queryCounterEXT(query: WebGLQuery, target: number): void;
  152391. createQueryEXT(): WebGLQuery;
  152392. beginQueryEXT(target: number, query: WebGLQuery): void;
  152393. endQueryEXT(target: number): void;
  152394. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  152395. deleteQueryEXT(query: WebGLQuery): void;
  152396. }
  152397. interface WebGLUniformLocation {
  152398. _currentState: any;
  152399. }
  152400. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  152401. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  152402. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  152403. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  152404. interface WebGLRenderingContext {
  152405. readonly RASTERIZER_DISCARD: number;
  152406. readonly DEPTH_COMPONENT24: number;
  152407. readonly TEXTURE_3D: number;
  152408. readonly TEXTURE_2D_ARRAY: number;
  152409. readonly TEXTURE_COMPARE_FUNC: number;
  152410. readonly TEXTURE_COMPARE_MODE: number;
  152411. readonly COMPARE_REF_TO_TEXTURE: number;
  152412. readonly TEXTURE_WRAP_R: number;
  152413. readonly HALF_FLOAT: number;
  152414. readonly RGB8: number;
  152415. readonly RED_INTEGER: number;
  152416. readonly RG_INTEGER: number;
  152417. readonly RGB_INTEGER: number;
  152418. readonly RGBA_INTEGER: number;
  152419. readonly R8_SNORM: number;
  152420. readonly RG8_SNORM: number;
  152421. readonly RGB8_SNORM: number;
  152422. readonly RGBA8_SNORM: number;
  152423. readonly R8I: number;
  152424. readonly RG8I: number;
  152425. readonly RGB8I: number;
  152426. readonly RGBA8I: number;
  152427. readonly R8UI: number;
  152428. readonly RG8UI: number;
  152429. readonly RGB8UI: number;
  152430. readonly RGBA8UI: number;
  152431. readonly R16I: number;
  152432. readonly RG16I: number;
  152433. readonly RGB16I: number;
  152434. readonly RGBA16I: number;
  152435. readonly R16UI: number;
  152436. readonly RG16UI: number;
  152437. readonly RGB16UI: number;
  152438. readonly RGBA16UI: number;
  152439. readonly R32I: number;
  152440. readonly RG32I: number;
  152441. readonly RGB32I: number;
  152442. readonly RGBA32I: number;
  152443. readonly R32UI: number;
  152444. readonly RG32UI: number;
  152445. readonly RGB32UI: number;
  152446. readonly RGBA32UI: number;
  152447. readonly RGB10_A2UI: number;
  152448. readonly R11F_G11F_B10F: number;
  152449. readonly RGB9_E5: number;
  152450. readonly RGB10_A2: number;
  152451. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  152452. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  152453. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  152454. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  152455. readonly DEPTH_COMPONENT32F: number;
  152456. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  152457. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  152458. 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;
  152459. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  152460. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  152461. readonly TRANSFORM_FEEDBACK: number;
  152462. readonly INTERLEAVED_ATTRIBS: number;
  152463. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  152464. createTransformFeedback(): WebGLTransformFeedback;
  152465. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  152466. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  152467. beginTransformFeedback(primitiveMode: number): void;
  152468. endTransformFeedback(): void;
  152469. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  152470. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152471. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152472. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152473. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  152474. }
  152475. interface ImageBitmap {
  152476. readonly width: number;
  152477. readonly height: number;
  152478. close(): void;
  152479. }
  152480. interface WebGLQuery extends WebGLObject {
  152481. }
  152482. declare var WebGLQuery: {
  152483. prototype: WebGLQuery;
  152484. new(): WebGLQuery;
  152485. };
  152486. interface WebGLSampler extends WebGLObject {
  152487. }
  152488. declare var WebGLSampler: {
  152489. prototype: WebGLSampler;
  152490. new(): WebGLSampler;
  152491. };
  152492. interface WebGLSync extends WebGLObject {
  152493. }
  152494. declare var WebGLSync: {
  152495. prototype: WebGLSync;
  152496. new(): WebGLSync;
  152497. };
  152498. interface WebGLTransformFeedback extends WebGLObject {
  152499. }
  152500. declare var WebGLTransformFeedback: {
  152501. prototype: WebGLTransformFeedback;
  152502. new(): WebGLTransformFeedback;
  152503. };
  152504. interface WebGLVertexArrayObject extends WebGLObject {
  152505. }
  152506. declare var WebGLVertexArrayObject: {
  152507. prototype: WebGLVertexArrayObject;
  152508. new(): WebGLVertexArrayObject;
  152509. };
  152510. // Type definitions for WebVR API
  152511. // Project: https://w3c.github.io/webvr/
  152512. // Definitions by: six a <https://github.com/lostfictions>
  152513. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  152514. interface VRDisplay extends EventTarget {
  152515. /**
  152516. * Dictionary of capabilities describing the VRDisplay.
  152517. */
  152518. readonly capabilities: VRDisplayCapabilities;
  152519. /**
  152520. * z-depth defining the far plane of the eye view frustum
  152521. * enables mapping of values in the render target depth
  152522. * attachment to scene coordinates. Initially set to 10000.0.
  152523. */
  152524. depthFar: number;
  152525. /**
  152526. * z-depth defining the near plane of the eye view frustum
  152527. * enables mapping of values in the render target depth
  152528. * attachment to scene coordinates. Initially set to 0.01.
  152529. */
  152530. depthNear: number;
  152531. /**
  152532. * An identifier for this distinct VRDisplay. Used as an
  152533. * association point in the Gamepad API.
  152534. */
  152535. readonly displayId: number;
  152536. /**
  152537. * A display name, a user-readable name identifying it.
  152538. */
  152539. readonly displayName: string;
  152540. readonly isConnected: boolean;
  152541. readonly isPresenting: boolean;
  152542. /**
  152543. * If this VRDisplay supports room-scale experiences, the optional
  152544. * stage attribute contains details on the room-scale parameters.
  152545. */
  152546. readonly stageParameters: VRStageParameters | null;
  152547. /**
  152548. * Passing the value returned by `requestAnimationFrame` to
  152549. * `cancelAnimationFrame` will unregister the callback.
  152550. * @param handle Define the hanle of the request to cancel
  152551. */
  152552. cancelAnimationFrame(handle: number): void;
  152553. /**
  152554. * Stops presenting to the VRDisplay.
  152555. * @returns a promise to know when it stopped
  152556. */
  152557. exitPresent(): Promise<void>;
  152558. /**
  152559. * Return the current VREyeParameters for the given eye.
  152560. * @param whichEye Define the eye we want the parameter for
  152561. * @returns the eye parameters
  152562. */
  152563. getEyeParameters(whichEye: string): VREyeParameters;
  152564. /**
  152565. * Populates the passed VRFrameData with the information required to render
  152566. * the current frame.
  152567. * @param frameData Define the data structure to populate
  152568. * @returns true if ok otherwise false
  152569. */
  152570. getFrameData(frameData: VRFrameData): boolean;
  152571. /**
  152572. * Get the layers currently being presented.
  152573. * @returns the list of VR layers
  152574. */
  152575. getLayers(): VRLayer[];
  152576. /**
  152577. * Return a VRPose containing the future predicted pose of the VRDisplay
  152578. * when the current frame will be presented. The value returned will not
  152579. * change until JavaScript has returned control to the browser.
  152580. *
  152581. * The VRPose will contain the position, orientation, velocity,
  152582. * and acceleration of each of these properties.
  152583. * @returns the pose object
  152584. */
  152585. getPose(): VRPose;
  152586. /**
  152587. * Return the current instantaneous pose of the VRDisplay, with no
  152588. * prediction applied.
  152589. * @returns the current instantaneous pose
  152590. */
  152591. getImmediatePose(): VRPose;
  152592. /**
  152593. * The callback passed to `requestAnimationFrame` will be called
  152594. * any time a new frame should be rendered. When the VRDisplay is
  152595. * presenting the callback will be called at the native refresh
  152596. * rate of the HMD. When not presenting this function acts
  152597. * identically to how window.requestAnimationFrame acts. Content should
  152598. * make no assumptions of frame rate or vsync behavior as the HMD runs
  152599. * asynchronously from other displays and at differing refresh rates.
  152600. * @param callback Define the eaction to run next frame
  152601. * @returns the request handle it
  152602. */
  152603. requestAnimationFrame(callback: FrameRequestCallback): number;
  152604. /**
  152605. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  152606. * Repeat calls while already presenting will update the VRLayers being displayed.
  152607. * @param layers Define the list of layer to present
  152608. * @returns a promise to know when the request has been fulfilled
  152609. */
  152610. requestPresent(layers: VRLayer[]): Promise<void>;
  152611. /**
  152612. * Reset the pose for this display, treating its current position and
  152613. * orientation as the "origin/zero" values. VRPose.position,
  152614. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  152615. * updated when calling resetPose(). This should be called in only
  152616. * sitting-space experiences.
  152617. */
  152618. resetPose(): void;
  152619. /**
  152620. * The VRLayer provided to the VRDisplay will be captured and presented
  152621. * in the HMD. Calling this function has the same effect on the source
  152622. * canvas as any other operation that uses its source image, and canvases
  152623. * created without preserveDrawingBuffer set to true will be cleared.
  152624. * @param pose Define the pose to submit
  152625. */
  152626. submitFrame(pose?: VRPose): void;
  152627. }
  152628. declare var VRDisplay: {
  152629. prototype: VRDisplay;
  152630. new(): VRDisplay;
  152631. };
  152632. interface VRLayer {
  152633. leftBounds?: number[] | Float32Array | null;
  152634. rightBounds?: number[] | Float32Array | null;
  152635. source?: HTMLCanvasElement | null;
  152636. }
  152637. interface VRDisplayCapabilities {
  152638. readonly canPresent: boolean;
  152639. readonly hasExternalDisplay: boolean;
  152640. readonly hasOrientation: boolean;
  152641. readonly hasPosition: boolean;
  152642. readonly maxLayers: number;
  152643. }
  152644. interface VREyeParameters {
  152645. /** @deprecated */
  152646. readonly fieldOfView: VRFieldOfView;
  152647. readonly offset: Float32Array;
  152648. readonly renderHeight: number;
  152649. readonly renderWidth: number;
  152650. }
  152651. interface VRFieldOfView {
  152652. readonly downDegrees: number;
  152653. readonly leftDegrees: number;
  152654. readonly rightDegrees: number;
  152655. readonly upDegrees: number;
  152656. }
  152657. interface VRFrameData {
  152658. readonly leftProjectionMatrix: Float32Array;
  152659. readonly leftViewMatrix: Float32Array;
  152660. readonly pose: VRPose;
  152661. readonly rightProjectionMatrix: Float32Array;
  152662. readonly rightViewMatrix: Float32Array;
  152663. readonly timestamp: number;
  152664. }
  152665. interface VRPose {
  152666. readonly angularAcceleration: Float32Array | null;
  152667. readonly angularVelocity: Float32Array | null;
  152668. readonly linearAcceleration: Float32Array | null;
  152669. readonly linearVelocity: Float32Array | null;
  152670. readonly orientation: Float32Array | null;
  152671. readonly position: Float32Array | null;
  152672. readonly timestamp: number;
  152673. }
  152674. interface VRStageParameters {
  152675. sittingToStandingTransform?: Float32Array;
  152676. sizeX?: number;
  152677. sizeY?: number;
  152678. }
  152679. interface Navigator {
  152680. getVRDisplays(): Promise<VRDisplay[]>;
  152681. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  152682. }
  152683. interface Window {
  152684. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  152685. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  152686. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  152687. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  152688. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  152689. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  152690. }
  152691. interface Gamepad {
  152692. readonly displayId: number;
  152693. }
  152694. type XRSessionMode =
  152695. | "inline"
  152696. | "immersive-vr"
  152697. | "immersive-ar";
  152698. type XRReferenceSpaceType =
  152699. | "viewer"
  152700. | "local"
  152701. | "local-floor"
  152702. | "bounded-floor"
  152703. | "unbounded";
  152704. type XREnvironmentBlendMode =
  152705. | "opaque"
  152706. | "additive"
  152707. | "alpha-blend";
  152708. type XRVisibilityState =
  152709. | "visible"
  152710. | "visible-blurred"
  152711. | "hidden";
  152712. type XRHandedness =
  152713. | "none"
  152714. | "left"
  152715. | "right";
  152716. type XRTargetRayMode =
  152717. | "gaze"
  152718. | "tracked-pointer"
  152719. | "screen";
  152720. type XREye =
  152721. | "none"
  152722. | "left"
  152723. | "right";
  152724. type XREventType =
  152725. | "devicechange"
  152726. | "visibilitychange"
  152727. | "end"
  152728. | "inputsourceschange"
  152729. | "select"
  152730. | "selectstart"
  152731. | "selectend"
  152732. | "squeeze"
  152733. | "squeezestart"
  152734. | "squeezeend"
  152735. | "reset";
  152736. interface XRSpace extends EventTarget {
  152737. }
  152738. interface XRRenderState {
  152739. depthNear?: number;
  152740. depthFar?: number;
  152741. inlineVerticalFieldOfView?: number;
  152742. baseLayer?: XRWebGLLayer;
  152743. }
  152744. interface XRInputSource {
  152745. handedness: XRHandedness;
  152746. targetRayMode: XRTargetRayMode;
  152747. targetRaySpace: XRSpace;
  152748. gripSpace: XRSpace | undefined;
  152749. gamepad: Gamepad | undefined;
  152750. profiles: Array<string>;
  152751. }
  152752. interface XRSessionInit {
  152753. optionalFeatures?: string[];
  152754. requiredFeatures?: string[];
  152755. }
  152756. interface XRSession {
  152757. addEventListener: Function;
  152758. removeEventListener: Function;
  152759. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  152760. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  152761. requestAnimationFrame: Function;
  152762. end(): Promise<void>;
  152763. renderState: XRRenderState;
  152764. inputSources: Array<XRInputSource>;
  152765. // hit test
  152766. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  152767. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  152768. // legacy AR hit test
  152769. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  152770. // legacy plane detection
  152771. updateWorldTrackingState(options: {
  152772. planeDetectionState?: { enabled: boolean; }
  152773. }): void;
  152774. }
  152775. interface XRReferenceSpace extends XRSpace {
  152776. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  152777. onreset: any;
  152778. }
  152779. type XRPlaneSet = Set<XRPlane>;
  152780. type XRAnchorSet = Set<XRAnchor>;
  152781. interface XRFrame {
  152782. session: XRSession;
  152783. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  152784. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  152785. // AR
  152786. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  152787. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  152788. // Anchors
  152789. trackedAnchors?: XRAnchorSet;
  152790. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  152791. // Planes
  152792. worldInformation: {
  152793. detectedPlanes?: XRPlaneSet;
  152794. };
  152795. }
  152796. interface XRViewerPose extends XRPose {
  152797. views: Array<XRView>;
  152798. }
  152799. interface XRPose {
  152800. transform: XRRigidTransform;
  152801. emulatedPosition: boolean;
  152802. }
  152803. interface XRWebGLLayerOptions {
  152804. antialias?: boolean;
  152805. depth?: boolean;
  152806. stencil?: boolean;
  152807. alpha?: boolean;
  152808. multiview?: boolean;
  152809. framebufferScaleFactor?: number;
  152810. }
  152811. declare var XRWebGLLayer: {
  152812. prototype: XRWebGLLayer;
  152813. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  152814. };
  152815. interface XRWebGLLayer {
  152816. framebuffer: WebGLFramebuffer;
  152817. framebufferWidth: number;
  152818. framebufferHeight: number;
  152819. getViewport: Function;
  152820. }
  152821. declare class XRRigidTransform {
  152822. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  152823. position: DOMPointReadOnly;
  152824. orientation: DOMPointReadOnly;
  152825. matrix: Float32Array;
  152826. inverse: XRRigidTransform;
  152827. }
  152828. interface XRView {
  152829. eye: XREye;
  152830. projectionMatrix: Float32Array;
  152831. transform: XRRigidTransform;
  152832. }
  152833. interface XRInputSourceChangeEvent {
  152834. session: XRSession;
  152835. removed: Array<XRInputSource>;
  152836. added: Array<XRInputSource>;
  152837. }
  152838. interface XRInputSourceEvent extends Event {
  152839. readonly frame: XRFrame;
  152840. readonly inputSource: XRInputSource;
  152841. }
  152842. // Experimental(er) features
  152843. declare class XRRay {
  152844. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  152845. origin: DOMPointReadOnly;
  152846. direction: DOMPointReadOnly;
  152847. matrix: Float32Array;
  152848. }
  152849. declare enum XRHitTestTrackableType {
  152850. "point",
  152851. "plane"
  152852. }
  152853. interface XRHitResult {
  152854. hitMatrix: Float32Array;
  152855. }
  152856. interface XRTransientInputHitTestResult {
  152857. readonly inputSource: XRInputSource;
  152858. readonly results: Array<XRHitTestResult>;
  152859. }
  152860. interface XRHitTestResult {
  152861. getPose(baseSpace: XRSpace): XRPose | undefined;
  152862. // When anchor system is enabled
  152863. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  152864. }
  152865. interface XRHitTestSource {
  152866. cancel(): void;
  152867. }
  152868. interface XRTransientInputHitTestSource {
  152869. cancel(): void;
  152870. }
  152871. interface XRHitTestOptionsInit {
  152872. space: XRSpace;
  152873. entityTypes?: Array<XRHitTestTrackableType>;
  152874. offsetRay?: XRRay;
  152875. }
  152876. interface XRTransientInputHitTestOptionsInit {
  152877. profile: string;
  152878. entityTypes?: Array<XRHitTestTrackableType>;
  152879. offsetRay?: XRRay;
  152880. }
  152881. interface XRAnchor {
  152882. anchorSpace: XRSpace;
  152883. delete(): void;
  152884. }
  152885. interface XRPlane {
  152886. orientation: "Horizontal" | "Vertical";
  152887. planeSpace: XRSpace;
  152888. polygon: Array<DOMPointReadOnly>;
  152889. lastChangedTime: number;
  152890. }